blob: 7ed47f66ddd1fe8a6f09f24b548536ff04fd8660 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200217 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100221 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200222 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200223 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200224 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200225 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100226 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200227 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200228 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200229 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200230 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200231 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200232 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100233 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100234 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430235 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100236 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100237 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800238 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200239 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200240 ALC889A_INTEL,
241 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200242 ALC888_ASUS_M90V,
243 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200244 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100245 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200246 ALC883_SONY_VAIO_TT,
Takashi Iwai49535502009-06-30 15:28:30 +0200247 ALC882_AUTO,
248 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200249};
250
Kailang Yangdf694da2005-12-05 19:42:22 +0100251/* for GPIO Poll */
252#define GPIO_MASK 0x03
253
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200254/* extra amp-initialization sequence types */
255enum {
256 ALC_INIT_NONE,
257 ALC_INIT_DEFAULT,
258 ALC_INIT_GPIO1,
259 ALC_INIT_GPIO2,
260 ALC_INIT_GPIO3,
261};
262
Takashi Iwai6c819492009-08-10 18:47:44 +0200263struct alc_mic_route {
264 hda_nid_t pin;
265 unsigned char mux_idx;
266 unsigned char amix_idx;
267};
268
269#define MUX_IDX_UNDEF ((unsigned char)-1)
270
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271struct alc_spec {
272 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100273 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100275 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100276 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Kailang Yangdf694da2005-12-05 19:42:22 +0100278 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200279 * don't forget NULL
280 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200281 */
282 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200284 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 struct hda_pcm_stream *stream_analog_playback;
286 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100287 struct hda_pcm_stream *stream_analog_alt_playback;
288 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200290 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 struct hda_pcm_stream *stream_digital_playback;
292 struct hda_pcm_stream *stream_digital_capture;
293
294 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200295 struct hda_multi_out multiout; /* playback set-up
296 * max_channels, dacs must be set
297 * dig_out_nid and hp_nid are optional
298 */
Takashi Iwai63300792008-01-24 15:31:36 +0100299 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100300 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100301 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* capture */
304 unsigned int num_adc_nids;
305 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100306 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200307 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200310 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 const struct hda_input_mux *input_mux;
312 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200313 struct alc_mic_route ext_mic;
314 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100317 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200319 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200320 int const_channel_count;
321 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100324 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200325
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200326 /* dynamic controls, init_verbs and input_mux */
327 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200328 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200329 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200330 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai49535502009-06-30 15:28:30 +0200331 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
332 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100333
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100334 /* hooks */
335 void (*init_hook)(struct hda_codec *codec);
336 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
337
Takashi Iwai834be882006-03-01 14:16:17 +0100338 /* for pin sensing */
339 unsigned int sense_updated: 1;
340 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100341 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200342 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200343
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100344 /* other flags */
345 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200346 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100347
Takashi Iwai2134ea42008-01-10 16:53:55 +0100348 /* for virtual master */
349 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200350#ifdef CONFIG_SND_HDA_POWER_SAVE
351 struct hda_loopback_check loopback;
352#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200353
354 /* for PLL fix */
355 hda_nid_t pll_nid;
356 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100357};
358
359/*
360 * configuration template - to be copied to the spec instance
361 */
362struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200363 struct snd_kcontrol_new *mixers[5]; /* should be identical size
364 * with spec
365 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100366 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100367 const struct hda_verb *init_verbs[5];
368 unsigned int num_dacs;
369 hda_nid_t *dac_nids;
370 hda_nid_t dig_out_nid; /* optional */
371 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800372 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100373 unsigned int num_adc_nids;
374 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100375 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100376 hda_nid_t dig_in_nid;
377 unsigned int num_channel_mode;
378 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200379 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200380 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200381 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100382 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100383 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200384 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100385 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200386#ifdef CONFIG_SND_HDA_POWER_SAVE
387 struct hda_amp_list *loopbacks;
388#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389};
390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
392/*
393 * input MUX handling
394 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200395static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
396 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397{
398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
399 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200400 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
401 if (mux_idx >= spec->num_mux_defs)
402 mux_idx = 0;
403 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404}
405
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200406static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct alc_spec *spec = codec->spec;
411 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
412
413 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
414 return 0;
415}
416
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200417static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419{
420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
421 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100422 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100424 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100425 hda_nid_t nid = spec->capsrc_nids ?
426 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200427 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428
Takashi Iwaicd896c32008-11-18 12:36:33 +0100429 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
430 imux = &spec->input_mux[mux_idx];
431
Takashi Iwaia22d5432009-07-27 12:54:26 +0200432 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200433 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100434 /* Matrix-mixer style (e.g. ALC882) */
435 unsigned int *cur_val = &spec->cur_mux[adc_idx];
436 unsigned int i, idx;
437
438 idx = ucontrol->value.enumerated.item[0];
439 if (idx >= imux->num_items)
440 idx = imux->num_items - 1;
441 if (*cur_val == idx)
442 return 0;
443 for (i = 0; i < imux->num_items; i++) {
444 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
445 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
446 imux->items[i].index,
447 HDA_AMP_MUTE, v);
448 }
449 *cur_val = idx;
450 return 1;
451 } else {
452 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100453 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100454 &spec->cur_mux[adc_idx]);
455 }
456}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200457
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458/*
459 * channel mode setting
460 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
462 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463{
464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
465 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100466 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
467 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468}
469
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_ch_mode_get(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 Iwaid2a6d7d2005-11-17 11:06:29 +0100475 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200477 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200480static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
481 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482{
483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200485 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
486 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200487 &spec->ext_channel_count);
488 if (err >= 0 && !spec->const_channel_count) {
489 spec->multiout.max_channels = spec->ext_channel_count;
490 if (spec->need_dac_fix)
491 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
492 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200493 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494}
495
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200498 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100499 * being part of a format specifier. Maximum allowed length of a value is
500 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100501 *
502 * Note: some retasking pin complexes seem to ignore requests for input
503 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
504 * are requested. Therefore order this list so that this behaviour will not
505 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200506 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
507 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200508 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100510 "Mic 50pc bias", "Mic 80pc bias",
511 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512};
513static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100514 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515};
516/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200517 * in the pin being assumed to be exclusively an input or an output pin. In
518 * addition, "input" pins may or may not process the mic bias option
519 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
520 * accept requests for bias as of chip versions up to March 2006) and/or
521 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200523#define ALC_PIN_DIR_IN 0x00
524#define ALC_PIN_DIR_OUT 0x01
525#define ALC_PIN_DIR_INOUT 0x02
526#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
527#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528
Kailang Yangea1fb292008-08-26 12:58:38 +0200529/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530 * For each direction the minimum and maximum values are given.
531 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200532static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 { 0, 2 }, /* ALC_PIN_DIR_IN */
534 { 3, 4 }, /* ALC_PIN_DIR_OUT */
535 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200536 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
537 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538};
539#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
540#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
541#define alc_pin_mode_n_items(_dir) \
542 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
543
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200546{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 unsigned int item_num = uinfo->value.enumerated.item;
548 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
549
550 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200551 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
553
554 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
555 item_num = alc_pin_mode_min(dir);
556 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200557 return 0;
558}
559
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
565 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200567 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
569 AC_VERB_GET_PIN_WIDGET_CONTROL,
570 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200571
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100572 /* Find enumerated value for current pinctl setting */
573 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2c2009-08-02 13:30:45 +0200574 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 return 0;
578}
579
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200580static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
581 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582{
583 signed int change;
584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
585 hda_nid_t nid = kcontrol->private_value & 0xffff;
586 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
587 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200588 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
589 AC_VERB_GET_PIN_WIDGET_CONTROL,
590 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200592 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593 val = alc_pin_mode_min(dir);
594
595 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100596 if (change) {
597 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200598 snd_hda_codec_write_cache(codec, nid, 0,
599 AC_VERB_SET_PIN_WIDGET_CONTROL,
600 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100601
Kailang Yangea1fb292008-08-26 12:58:38 +0200602 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100603 * for the requested pin mode. Enum values of 2 or less are
604 * input modes.
605 *
606 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200607 * reduces noise slightly (particularly on input) so we'll
608 * do it. However, having both input and output buffers
609 * enabled simultaneously doesn't seem to be problematic if
610 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100611 */
612 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200613 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
614 HDA_AMP_MUTE, HDA_AMP_MUTE);
615 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
616 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100617 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200618 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
619 HDA_AMP_MUTE, HDA_AMP_MUTE);
620 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
621 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100622 }
623 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200624 return change;
625}
626
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200628 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100629 .info = alc_pin_mode_info, \
630 .get = alc_pin_mode_get, \
631 .put = alc_pin_mode_put, \
632 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100633
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100634/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
635 * together using a mask with more than one bit set. This control is
636 * currently used only by the ALC260 test model. At this stage they are not
637 * needed for any "production" models.
638 */
639#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200640#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200641
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200642static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100644{
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 hda_nid_t nid = kcontrol->private_value & 0xffff;
647 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
648 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200649 unsigned int val = snd_hda_codec_read(codec, nid, 0,
650 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651
652 *valp = (val & mask) != 0;
653 return 0;
654}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200655static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100657{
658 signed int change;
659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
660 hda_nid_t nid = kcontrol->private_value & 0xffff;
661 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
662 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200663 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
664 AC_VERB_GET_GPIO_DATA,
665 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100666
667 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200668 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
669 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100670 gpio_data &= ~mask;
671 else
672 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200673 snd_hda_codec_write_cache(codec, nid, 0,
674 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100675
676 return change;
677}
678#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
679 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
680 .info = alc_gpio_data_info, \
681 .get = alc_gpio_data_get, \
682 .put = alc_gpio_data_put, \
683 .private_value = nid | (mask<<16) }
684#endif /* CONFIG_SND_DEBUG */
685
Jonathan Woithe92621f12006-02-28 11:47:47 +0100686/* A switch control to allow the enabling of the digital IO pins on the
687 * ALC260. This is incredibly simplistic; the intention of this control is
688 * to provide something in the test model allowing digital outputs to be
689 * identified if present. If models are found which can utilise these
690 * outputs a more complete mixer control can be devised for those models if
691 * necessary.
692 */
693#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200694#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200695
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200696static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
697 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100698{
699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
700 hda_nid_t nid = kcontrol->private_value & 0xffff;
701 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
702 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100704 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705
706 *valp = (val & mask) != 0;
707 return 0;
708}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200709static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100711{
712 signed int change;
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 hda_nid_t nid = kcontrol->private_value & 0xffff;
715 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
716 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100718 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100720
721 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100723 if (val==0)
724 ctrl_data &= ~mask;
725 else
726 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200727 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
728 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100729
730 return change;
731}
732#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
733 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
734 .info = alc_spdif_ctrl_info, \
735 .get = alc_spdif_ctrl_get, \
736 .put = alc_spdif_ctrl_put, \
737 .private_value = nid | (mask<<16) }
738#endif /* CONFIG_SND_DEBUG */
739
Jonathan Woithef8225f62008-01-08 12:16:54 +0100740/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
741 * Again, this is only used in the ALC26x test models to help identify when
742 * the EAPD line must be asserted for features to work.
743 */
744#ifdef CONFIG_SND_DEBUG
745#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
746
747static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_value *ucontrol)
749{
750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
751 hda_nid_t nid = kcontrol->private_value & 0xffff;
752 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
753 long *valp = ucontrol->value.integer.value;
754 unsigned int val = snd_hda_codec_read(codec, nid, 0,
755 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
756
757 *valp = (val & mask) != 0;
758 return 0;
759}
760
761static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
762 struct snd_ctl_elem_value *ucontrol)
763{
764 int change;
765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
766 hda_nid_t nid = kcontrol->private_value & 0xffff;
767 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
768 long val = *ucontrol->value.integer.value;
769 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
770 AC_VERB_GET_EAPD_BTLENABLE,
771 0x00);
772
773 /* Set/unset the masked control bit(s) as needed */
774 change = (!val ? 0 : mask) != (ctrl_data & mask);
775 if (!val)
776 ctrl_data &= ~mask;
777 else
778 ctrl_data |= mask;
779 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
780 ctrl_data);
781
782 return change;
783}
784
785#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
786 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
787 .info = alc_eapd_ctrl_info, \
788 .get = alc_eapd_ctrl_get, \
789 .put = alc_eapd_ctrl_put, \
790 .private_value = nid | (mask<<16) }
791#endif /* CONFIG_SND_DEBUG */
792
Kailang Yangdf694da2005-12-05 19:42:22 +0100793/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100794 * set up the input pin config (depending on the given auto-pin type)
795 */
796static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
797 int auto_pin_type)
798{
799 unsigned int val = PIN_IN;
800
801 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
802 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100803 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100804 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
805 if (pincap & AC_PINCAP_VREF_80)
806 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200807 else if (pincap & AC_PINCAP_VREF_50)
808 val = PIN_VREF50;
809 else if (pincap & AC_PINCAP_VREF_100)
810 val = PIN_VREF100;
811 else if (pincap & AC_PINCAP_VREF_GRD)
812 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100813 }
814 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
815}
816
817/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100818 */
819static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
820{
821 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
822 return;
823 spec->mixers[spec->num_mixers++] = mix;
824}
825
826static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
827{
828 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
829 return;
830 spec->init_verbs[spec->num_init_verbs++] = verb;
831}
832
Takashi Iwaidaead532008-11-28 12:55:36 +0100833#ifdef CONFIG_PROC_FS
834/*
835 * hook for proc
836 */
837static void print_realtek_coef(struct snd_info_buffer *buffer,
838 struct hda_codec *codec, hda_nid_t nid)
839{
840 int coeff;
841
842 if (nid != 0x20)
843 return;
844 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
845 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
846 coeff = snd_hda_codec_read(codec, nid, 0,
847 AC_VERB_GET_COEF_INDEX, 0);
848 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
849}
850#else
851#define print_realtek_coef NULL
852#endif
853
Takashi Iwaid88897e2008-10-31 15:01:37 +0100854/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100855 * set up from the preset table
856 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200857static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200858 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100859{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200860 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100861 int i;
862
863 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100864 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100865 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200866 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
867 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100868 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200869
Kailang Yangdf694da2005-12-05 19:42:22 +0100870 spec->channel_mode = preset->channel_mode;
871 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200872 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200873 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100874
Hector Martin3b315d72009-06-02 10:54:19 +0200875 if (preset->const_channel_count)
876 spec->multiout.max_channels = preset->const_channel_count;
877 else
878 spec->multiout.max_channels = spec->channel_mode[0].channels;
879 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100880
881 spec->multiout.num_dacs = preset->num_dacs;
882 spec->multiout.dac_nids = preset->dac_nids;
883 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800884 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100885 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200886
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200887 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200888 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200889 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100890 spec->input_mux = preset->input_mux;
891
892 spec->num_adc_nids = preset->num_adc_nids;
893 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100894 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100895 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100896
897 spec->unsol_event = preset->unsol_event;
898 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200899#ifdef CONFIG_SND_HDA_POWER_SAVE
900 spec->loopback.amplist = preset->loopbacks;
901#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200902
903 if (preset->setup)
904 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100905}
906
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200907/* Enable GPIO mask and set output */
908static struct hda_verb alc_gpio1_init_verbs[] = {
909 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
911 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
912 { }
913};
914
915static struct hda_verb alc_gpio2_init_verbs[] = {
916 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
918 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
919 { }
920};
921
Kailang Yangbdd148a2007-05-08 15:19:08 +0200922static struct hda_verb alc_gpio3_init_verbs[] = {
923 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
925 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
926 { }
927};
928
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200929/*
930 * Fix hardware PLL issue
931 * On some codecs, the analog PLL gating control must be off while
932 * the default value is 1.
933 */
934static void alc_fix_pll(struct hda_codec *codec)
935{
936 struct alc_spec *spec = codec->spec;
937 unsigned int val;
938
939 if (!spec->pll_nid)
940 return;
941 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
942 spec->pll_coef_idx);
943 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
944 AC_VERB_GET_PROC_COEF, 0);
945 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
946 spec->pll_coef_idx);
947 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
948 val & ~(1 << spec->pll_coef_bit));
949}
950
951static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
952 unsigned int coef_idx, unsigned int coef_bit)
953{
954 struct alc_spec *spec = codec->spec;
955 spec->pll_nid = nid;
956 spec->pll_coef_idx = coef_idx;
957 spec->pll_coef_bit = coef_bit;
958 alc_fix_pll(codec);
959}
960
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200961static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200962{
963 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200964 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200965 unsigned int nid = spec->autocfg.hp_pins[0];
966 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200967
Takashi Iwai261c2402009-06-25 08:13:40 +0200968 pincap = snd_hda_query_pin_caps(codec, nid);
969 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
970 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200971 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200972 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200973 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
974 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
975 nid = spec->autocfg.speaker_pins[i];
976 if (!nid)
977 break;
978 snd_hda_codec_write(codec, nid, 0,
979 AC_VERB_SET_PIN_WIDGET_CONTROL,
980 spec->jack_present ? 0 : PIN_OUT);
981 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200982}
983
Takashi Iwai6c819492009-08-10 18:47:44 +0200984static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
985 hda_nid_t nid)
986{
987 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
988 int i, nums;
989
990 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
991 for (i = 0; i < nums; i++)
992 if (conn[i] == nid)
993 return i;
994 return -1;
995}
996
Kailang Yang7fb0d782008-10-15 11:12:35 +0200997static void alc_mic_automute(struct hda_codec *codec)
998{
999 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001000 struct alc_mic_route *dead, *alive;
1001 unsigned int present, type;
1002 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001003
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001004 if (!spec->auto_mic)
1005 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001006 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1007 return;
1008 if (snd_BUG_ON(!spec->adc_nids))
1009 return;
1010
1011 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1012
1013 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1014 AC_VERB_GET_PIN_SENSE, 0);
1015 present &= AC_PINSENSE_PRESENCE;
1016 if (present) {
1017 alive = &spec->ext_mic;
1018 dead = &spec->int_mic;
1019 } else {
1020 alive = &spec->int_mic;
1021 dead = &spec->ext_mic;
1022 }
1023
Takashi Iwai6c819492009-08-10 18:47:44 +02001024 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1025 if (type == AC_WID_AUD_MIX) {
1026 /* Matrix-mixer style (e.g. ALC882) */
1027 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1028 alive->mux_idx,
1029 HDA_AMP_MUTE, 0);
1030 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1031 dead->mux_idx,
1032 HDA_AMP_MUTE, HDA_AMP_MUTE);
1033 } else {
1034 /* MUX style (e.g. ALC880) */
1035 snd_hda_codec_write_cache(codec, cap_nid, 0,
1036 AC_VERB_SET_CONNECT_SEL,
1037 alive->mux_idx);
1038 }
1039
1040 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001041}
1042
Kailang Yangc9b58002007-10-16 14:30:01 +02001043/* unsolicited event for HP jack sensing */
1044static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1045{
1046 if (codec->vendor_id == 0x10ec0880)
1047 res >>= 28;
1048 else
1049 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001050 switch (res) {
1051 case ALC880_HP_EVENT:
1052 alc_automute_pin(codec);
1053 break;
1054 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001055 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001056 break;
1057 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001058}
1059
1060static void alc_inithook(struct hda_codec *codec)
1061{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001062 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001063 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001064}
1065
Kailang Yangf9423e72008-05-27 12:32:25 +02001066/* additional initialization for ALC888 variants */
1067static void alc888_coef_init(struct hda_codec *codec)
1068{
1069 unsigned int tmp;
1070
1071 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1072 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001074 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001075 /* alc888S-VC */
1076 snd_hda_codec_read(codec, 0x20, 0,
1077 AC_VERB_SET_PROC_COEF, 0x830);
1078 else
1079 /* alc888-VB */
1080 snd_hda_codec_read(codec, 0x20, 0,
1081 AC_VERB_SET_PROC_COEF, 0x3030);
1082}
1083
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001084static void alc889_coef_init(struct hda_codec *codec)
1085{
1086 unsigned int tmp;
1087
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1089 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1092}
1093
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001094static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098 switch (type) {
1099 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1101 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001103 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1104 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001106 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1107 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001108 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001109 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001110 case 0x10ec0260:
1111 snd_hda_codec_write(codec, 0x0f, 0,
1112 AC_VERB_SET_EAPD_BTLENABLE, 2);
1113 snd_hda_codec_write(codec, 0x10, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1115 break;
1116 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001117 case 0x10ec0267:
1118 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001119 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001120 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001121 case 0x10ec0660:
1122 case 0x10ec0662:
1123 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001124 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001125 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001126 snd_hda_codec_write(codec, 0x14, 0,
1127 AC_VERB_SET_EAPD_BTLENABLE, 2);
1128 snd_hda_codec_write(codec, 0x15, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001131 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 switch (codec->vendor_id) {
1133 case 0x10ec0260:
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_COEF_INDEX, 7);
1136 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1137 AC_VERB_GET_PROC_COEF, 0);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_COEF_INDEX, 7);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_PROC_COEF,
1142 tmp | 0x2010);
1143 break;
1144 case 0x10ec0262:
1145 case 0x10ec0880:
1146 case 0x10ec0882:
1147 case 0x10ec0883:
1148 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001149 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001150 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001151 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001152 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001153 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001154 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001156 case 0x10ec0267:
1157 case 0x10ec0268:
1158 snd_hda_codec_write(codec, 0x20, 0,
1159 AC_VERB_SET_COEF_INDEX, 7);
1160 tmp = snd_hda_codec_read(codec, 0x20, 0,
1161 AC_VERB_GET_PROC_COEF, 0);
1162 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001163 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001164 snd_hda_codec_write(codec, 0x20, 0,
1165 AC_VERB_SET_PROC_COEF,
1166 tmp | 0x3000);
1167 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001168 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001169 break;
1170 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001171}
Kailang Yangea1fb292008-08-26 12:58:38 +02001172
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173static void alc_init_auto_hp(struct hda_codec *codec)
1174{
1175 struct alc_spec *spec = codec->spec;
1176
1177 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001178 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001179
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001181 if (spec->autocfg.line_out_pins[0] &&
1182 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001183 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001184 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 else
1186 return;
1187 }
1188
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001189 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1190 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001191 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1192 AC_VERB_SET_UNSOLICITED_ENABLE,
1193 AC_USRSP_EN | ALC880_HP_EVENT);
1194 spec->unsol_event = alc_sku_unsol_event;
1195}
1196
Takashi Iwai6c819492009-08-10 18:47:44 +02001197static void alc_init_auto_mic(struct hda_codec *codec)
1198{
1199 struct alc_spec *spec = codec->spec;
1200 struct auto_pin_cfg *cfg = &spec->autocfg;
1201 hda_nid_t fixed, ext;
1202 int i;
1203
1204 /* there must be only two mic inputs exclusively */
1205 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1206 if (cfg->input_pins[i])
1207 return;
1208
1209 fixed = ext = 0;
1210 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1211 hda_nid_t nid = cfg->input_pins[i];
1212 unsigned int defcfg;
1213 if (!nid)
1214 return;
1215 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1216 switch (get_defcfg_connect(defcfg)) {
1217 case AC_JACK_PORT_FIXED:
1218 if (fixed)
1219 return; /* already occupied */
1220 fixed = nid;
1221 break;
1222 case AC_JACK_PORT_COMPLEX:
1223 if (ext)
1224 return; /* already occupied */
1225 ext = nid;
1226 break;
1227 default:
1228 return; /* invalid entry */
1229 }
1230 }
1231 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1232 return; /* no unsol support */
1233 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1234 ext, fixed);
1235 spec->ext_mic.pin = ext;
1236 spec->int_mic.pin = fixed;
1237 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1238 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1239 spec->auto_mic = 1;
1240 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1241 AC_VERB_SET_UNSOLICITED_ENABLE,
1242 AC_USRSP_EN | ALC880_MIC_EVENT);
1243 spec->unsol_event = alc_sku_unsol_event;
1244}
1245
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001246/* check subsystem ID and set up device-specific initialization;
1247 * return 1 if initialized, 0 if invalid SSID
1248 */
1249/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1250 * 31 ~ 16 : Manufacture ID
1251 * 15 ~ 8 : SKU ID
1252 * 7 ~ 0 : Assembly ID
1253 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1254 */
1255static int alc_subsystem_id(struct hda_codec *codec,
1256 hda_nid_t porta, hda_nid_t porte,
1257 hda_nid_t portd)
1258{
1259 unsigned int ass, tmp, i;
1260 unsigned nid;
1261 struct alc_spec *spec = codec->spec;
1262
1263 ass = codec->subsystem_id & 0xffff;
1264 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1265 goto do_sku;
1266
1267 /* invalid SSID, check the special NID pin defcfg instead */
1268 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001269 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001270 * 29~21 : reserve
1271 * 20 : PCBEEP input
1272 * 19~16 : Check sum (15:1)
1273 * 15~1 : Custom
1274 * 0 : override
1275 */
1276 nid = 0x1d;
1277 if (codec->vendor_id == 0x10ec0260)
1278 nid = 0x17;
1279 ass = snd_hda_codec_get_pincfg(codec, nid);
1280 snd_printd("realtek: No valid SSID, "
1281 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001282 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001283 if (!(ass & 1) && !(ass & 0x100000))
1284 return 0;
1285 if ((ass >> 30) != 1) /* no physical connection */
1286 return 0;
1287
1288 /* check sum */
1289 tmp = 0;
1290 for (i = 1; i < 16; i++) {
1291 if ((ass >> i) & 1)
1292 tmp++;
1293 }
1294 if (((ass >> 16) & 0xf) != tmp)
1295 return 0;
1296do_sku:
1297 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1298 ass & 0xffff, codec->vendor_id);
1299 /*
1300 * 0 : override
1301 * 1 : Swap Jack
1302 * 2 : 0 --> Desktop, 1 --> Laptop
1303 * 3~5 : External Amplifier control
1304 * 7~6 : Reserved
1305 */
1306 tmp = (ass & 0x38) >> 3; /* external Amp control */
1307 switch (tmp) {
1308 case 1:
1309 spec->init_amp = ALC_INIT_GPIO1;
1310 break;
1311 case 3:
1312 spec->init_amp = ALC_INIT_GPIO2;
1313 break;
1314 case 7:
1315 spec->init_amp = ALC_INIT_GPIO3;
1316 break;
1317 case 5:
1318 spec->init_amp = ALC_INIT_DEFAULT;
1319 break;
1320 }
1321
1322 /* is laptop or Desktop and enable the function "Mute internal speaker
1323 * when the external headphone out jack is plugged"
1324 */
1325 if (!(ass & 0x8000))
1326 return 1;
1327 /*
1328 * 10~8 : Jack location
1329 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1330 * 14~13: Resvered
1331 * 15 : 1 --> enable the function "Mute internal speaker
1332 * when the external headphone out jack is plugged"
1333 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 if (!spec->autocfg.hp_pins[0]) {
1335 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1336 if (tmp == 0)
1337 spec->autocfg.hp_pins[0] = porta;
1338 else if (tmp == 1)
1339 spec->autocfg.hp_pins[0] = porte;
1340 else if (tmp == 2)
1341 spec->autocfg.hp_pins[0] = portd;
1342 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001343 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001344 }
1345
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001346 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001347 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001348 return 1;
1349}
Kailang Yangea1fb292008-08-26 12:58:38 +02001350
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001351static void alc_ssid_check(struct hda_codec *codec,
1352 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1353{
1354 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1355 struct alc_spec *spec = codec->spec;
1356 snd_printd("realtek: "
1357 "Enable default setup for auto mode as fallback\n");
1358 spec->init_amp = ALC_INIT_DEFAULT;
1359 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001360 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001361 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001362}
1363
Takashi Iwai41e41f12005-06-08 14:48:49 +02001364/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001365 * Fix-up pin default configurations
1366 */
1367
1368struct alc_pincfg {
1369 hda_nid_t nid;
1370 u32 val;
1371};
1372
1373static void alc_fix_pincfg(struct hda_codec *codec,
1374 const struct snd_pci_quirk *quirk,
1375 const struct alc_pincfg **pinfix)
1376{
1377 const struct alc_pincfg *cfg;
1378
1379 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1380 if (!quirk)
1381 return;
1382
1383 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001384 for (; cfg->nid; cfg++)
1385 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001386}
1387
1388/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001389 * ALC888
1390 */
1391
1392/*
1393 * 2ch mode
1394 */
1395static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1396/* Mic-in jack as mic in */
1397 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1398 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1399/* Line-in jack as Line in */
1400 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1401 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1402/* Line-Out as Front */
1403 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1404 { } /* end */
1405};
1406
1407/*
1408 * 4ch mode
1409 */
1410static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1411/* Mic-in jack as mic in */
1412 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1413 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1414/* Line-in jack as Surround */
1415 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1416 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1417/* Line-Out as Front */
1418 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1419 { } /* end */
1420};
1421
1422/*
1423 * 6ch mode
1424 */
1425static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1426/* Mic-in jack as CLFE */
1427 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1428 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1429/* Line-in jack as Surround */
1430 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1431 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1432/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1433 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1434 { } /* end */
1435};
1436
1437/*
1438 * 8ch mode
1439 */
1440static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1441/* Mic-in jack as CLFE */
1442 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1443 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1444/* Line-in jack as Surround */
1445 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1446 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1447/* Line-Out as Side */
1448 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1449 { } /* end */
1450};
1451
1452static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1453 { 2, alc888_4ST_ch2_intel_init },
1454 { 4, alc888_4ST_ch4_intel_init },
1455 { 6, alc888_4ST_ch6_intel_init },
1456 { 8, alc888_4ST_ch8_intel_init },
1457};
1458
1459/*
1460 * ALC888 Fujitsu Siemens Amillo xa3530
1461 */
1462
1463static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1464/* Front Mic: set to PIN_IN (empty by default) */
1465 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1466/* Connect Internal HP to Front */
1467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1469 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1470/* Connect Bass HP to Front */
1471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1473 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1474/* Connect Line-Out side jack (SPDIF) to Side */
1475 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1476 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1478/* Connect Mic jack to CLFE */
1479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1482/* Connect Line-in jack to Surround */
1483 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1485 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1486/* Connect HP out jack to Front */
1487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1490/* Enable unsolicited event for HP jack and Line-out jack */
1491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1492 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1493 {}
1494};
1495
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001496static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001497{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001498 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001499 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001500 hda_nid_t nid;
1501 int i;
1502
1503 spec->jack_present = 0;
1504 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1505 nid = spec->autocfg.hp_pins[i];
1506 if (!nid)
1507 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001508 pincap = snd_hda_query_pin_caps(codec, nid);
1509 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1510 snd_hda_codec_read(codec, nid, 0,
1511 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001512 val = snd_hda_codec_read(codec, nid, 0,
1513 AC_VERB_GET_PIN_SENSE, 0);
1514 if (val & AC_PINSENSE_PRESENCE) {
1515 spec->jack_present = 1;
1516 break;
1517 }
1518 }
1519
1520 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001521 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001522 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1523 nid = spec->autocfg.speaker_pins[i];
1524 if (!nid)
1525 break;
1526 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1527 HDA_AMP_MUTE, mute);
1528 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001529}
1530
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001531static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1532 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001533{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001534 if (codec->vendor_id == 0x10ec0880)
1535 res >>= 28;
1536 else
1537 res >>= 26;
1538 if (res == ALC880_HP_EVENT)
1539 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001540}
1541
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001542static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001543{
1544 struct alc_spec *spec = codec->spec;
1545
1546 spec->autocfg.hp_pins[0] = 0x15;
1547 spec->autocfg.speaker_pins[0] = 0x14;
1548 spec->autocfg.speaker_pins[1] = 0x16;
1549 spec->autocfg.speaker_pins[2] = 0x17;
1550 spec->autocfg.speaker_pins[3] = 0x19;
1551 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001552}
1553
1554static void alc889_intel_init_hook(struct hda_codec *codec)
1555{
1556 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001557 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001558}
1559
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001560static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001561{
1562 struct alc_spec *spec = codec->spec;
1563
1564 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1565 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1566 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1567 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001568}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001569
1570/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001571 * ALC888 Acer Aspire 4930G model
1572 */
1573
1574static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1575/* Front Mic: set to PIN_IN (empty by default) */
1576 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1577/* Unselect Front Mic by default in input mixer 3 */
1578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001579/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001580 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1581/* Connect Internal HP to front */
1582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1583 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1584 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1585/* Connect HP out to front */
1586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1588 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1589 { }
1590};
1591
Hector Martin3b315d72009-06-02 10:54:19 +02001592/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001593 * ALC888 Acer Aspire 6530G model
1594 */
1595
1596static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1597/* Bias voltage on for external mic port */
1598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001599/* Front Mic: set to PIN_IN (empty by default) */
1600 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1601/* Unselect Front Mic by default in input mixer 3 */
1602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001603/* Enable unsolicited event for HP jack */
1604 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1605/* Enable speaker output */
1606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1608/* Enable headphone output */
1609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1612 { }
1613};
1614
1615/*
Hector Martin018df412009-06-04 00:13:40 +02001616 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001617 */
1618
Hector Martin018df412009-06-04 00:13:40 +02001619static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001620/* Front Mic: set to PIN_IN (empty by default) */
1621 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1622/* Unselect Front Mic by default in input mixer 3 */
1623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1624/* Enable unsolicited event for HP jack */
1625 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1626/* Connect Internal Front to Front */
1627 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1628 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1629 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1630/* Connect Internal Rear to Rear */
1631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1634/* Connect Internal CLFE to CLFE */
1635 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1637 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1638/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1642/* Enable all DACs */
1643/* DAC DISABLE/MUTE 1? */
1644/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1645 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1646 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1647/* DAC DISABLE/MUTE 2? */
1648/* some bit here disables the other DACs. Init=0x4900 */
1649 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1650 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1651/* Enable amplifiers */
1652 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1653 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001654/* DMIC fix
1655 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1656 * which makes the stereo useless. However, either the mic or the ALC889
1657 * makes the signal become a difference/sum signal instead of standard
1658 * stereo, which is annoying. So instead we flip this bit which makes the
1659 * codec replicate the sum signal to both channels, turning it into a
1660 * normal mono mic.
1661 */
1662/* DMIC_CONTROL? Init value = 0x0001 */
1663 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1664 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001665 { }
1666};
1667
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001668static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001669 /* Front mic only available on one ADC */
1670 {
1671 .num_items = 4,
1672 .items = {
1673 { "Mic", 0x0 },
1674 { "Line", 0x2 },
1675 { "CD", 0x4 },
1676 { "Front Mic", 0xb },
1677 },
1678 },
1679 {
1680 .num_items = 3,
1681 .items = {
1682 { "Mic", 0x0 },
1683 { "Line", 0x2 },
1684 { "CD", 0x4 },
1685 },
1686 }
1687};
1688
Tony Vroond2fd4b02009-06-21 00:40:10 +01001689static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1690 /* Interal mic only available on one ADC */
1691 {
Tony Vroon684a8842009-06-26 09:27:50 +01001692 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001693 .items = {
1694 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001695 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001696 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001697 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001698 { "Int Mic", 0xb },
1699 },
1700 },
1701 {
Tony Vroon684a8842009-06-26 09:27:50 +01001702 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001703 .items = {
1704 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001705 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001707 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001708 },
1709 }
1710};
1711
Hector Martin018df412009-06-04 00:13:40 +02001712static struct hda_input_mux alc889_capture_sources[3] = {
1713 /* Digital mic only available on first "ADC" */
1714 {
1715 .num_items = 5,
1716 .items = {
1717 { "Mic", 0x0 },
1718 { "Line", 0x2 },
1719 { "CD", 0x4 },
1720 { "Front Mic", 0xb },
1721 { "Input Mix", 0xa },
1722 },
1723 },
1724 {
1725 .num_items = 4,
1726 .items = {
1727 { "Mic", 0x0 },
1728 { "Line", 0x2 },
1729 { "CD", 0x4 },
1730 { "Input Mix", 0xa },
1731 },
1732 },
1733 {
1734 .num_items = 4,
1735 .items = {
1736 { "Mic", 0x0 },
1737 { "Line", 0x2 },
1738 { "CD", 0x4 },
1739 { "Input Mix", 0xa },
1740 },
1741 }
1742};
1743
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001744static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001745 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1746 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1747 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1748 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1749 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1750 HDA_OUTPUT),
1751 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1752 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1753 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1754 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001763 { } /* end */
1764};
1765
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001766static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001767{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001768 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001769
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001770 spec->autocfg.hp_pins[0] = 0x15;
1771 spec->autocfg.speaker_pins[0] = 0x14;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001772}
1773
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001774static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001775{
1776 struct alc_spec *spec = codec->spec;
1777
1778 spec->autocfg.hp_pins[0] = 0x15;
1779 spec->autocfg.speaker_pins[0] = 0x14;
1780 spec->autocfg.speaker_pins[1] = 0x16;
1781 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001782}
1783
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001784static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001785{
1786 struct alc_spec *spec = codec->spec;
1787
1788 spec->autocfg.hp_pins[0] = 0x15;
1789 spec->autocfg.speaker_pins[0] = 0x14;
1790 spec->autocfg.speaker_pins[1] = 0x16;
1791 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001792}
1793
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001794/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001795 * ALC880 3-stack model
1796 *
1797 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001798 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1799 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800 */
1801
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001802static hda_nid_t alc880_dac_nids[4] = {
1803 /* front, rear, clfe, rear_surr */
1804 0x02, 0x05, 0x04, 0x03
1805};
1806
1807static hda_nid_t alc880_adc_nids[3] = {
1808 /* ADC0-2 */
1809 0x07, 0x08, 0x09,
1810};
1811
1812/* The datasheet says the node 0x07 is connected from inputs,
1813 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001814 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001816static hda_nid_t alc880_adc_nids_alt[2] = {
1817 /* ADC1-2 */
1818 0x08, 0x09,
1819};
1820
1821#define ALC880_DIGOUT_NID 0x06
1822#define ALC880_DIGIN_NID 0x0a
1823
1824static struct hda_input_mux alc880_capture_source = {
1825 .num_items = 4,
1826 .items = {
1827 { "Mic", 0x0 },
1828 { "Front Mic", 0x3 },
1829 { "Line", 0x2 },
1830 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832};
1833
1834/* channel source setting (2/6 channel selection for 3-stack) */
1835/* 2ch mode */
1836static struct hda_verb alc880_threestack_ch2_init[] = {
1837 /* set line-in to input, mute it */
1838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1840 /* set mic-in to input vref 80%, mute it */
1841 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843 { } /* end */
1844};
1845
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001846/* 6ch mode */
1847static struct hda_verb alc880_threestack_ch6_init[] = {
1848 /* set line-in to output, unmute it */
1849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1851 /* set mic-in to output, unmute it */
1852 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1853 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1854 { } /* end */
1855};
1856
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001857static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001858 { 2, alc880_threestack_ch2_init },
1859 { 6, alc880_threestack_ch6_init },
1860};
1861
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001862static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001864 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001865 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001866 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1868 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001869 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1870 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1872 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1874 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1877 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1878 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001880 {
1881 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1882 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001883 .info = alc_ch_mode_info,
1884 .get = alc_ch_mode_get,
1885 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001886 },
1887 { } /* end */
1888};
1889
1890/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001891static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1892 struct snd_ctl_elem_info *uinfo)
1893{
1894 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1895 struct alc_spec *spec = codec->spec;
1896 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001897
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001898 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001899 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1900 HDA_INPUT);
1901 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001902 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001903 return err;
1904}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001905
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001906static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1907 unsigned int size, unsigned int __user *tlv)
1908{
1909 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1910 struct alc_spec *spec = codec->spec;
1911 int err;
1912
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001913 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001914 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1915 HDA_INPUT);
1916 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001917 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001918 return err;
1919}
1920
1921typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1922 struct snd_ctl_elem_value *ucontrol);
1923
1924static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1925 struct snd_ctl_elem_value *ucontrol,
1926 getput_call_t func)
1927{
1928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1929 struct alc_spec *spec = codec->spec;
1930 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1931 int err;
1932
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001933 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001934 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1935 3, 0, HDA_INPUT);
1936 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001937 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001938 return err;
1939}
1940
1941static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1942 struct snd_ctl_elem_value *ucontrol)
1943{
1944 return alc_cap_getput_caller(kcontrol, ucontrol,
1945 snd_hda_mixer_amp_volume_get);
1946}
1947
1948static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1949 struct snd_ctl_elem_value *ucontrol)
1950{
1951 return alc_cap_getput_caller(kcontrol, ucontrol,
1952 snd_hda_mixer_amp_volume_put);
1953}
1954
1955/* capture mixer elements */
1956#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1957
1958static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1959 struct snd_ctl_elem_value *ucontrol)
1960{
1961 return alc_cap_getput_caller(kcontrol, ucontrol,
1962 snd_hda_mixer_amp_switch_get);
1963}
1964
1965static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1966 struct snd_ctl_elem_value *ucontrol)
1967{
1968 return alc_cap_getput_caller(kcontrol, ucontrol,
1969 snd_hda_mixer_amp_switch_put);
1970}
1971
Takashi Iwaia23b6882009-03-23 15:21:36 +01001972#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001973 { \
1974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1975 .name = "Capture Switch", \
1976 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1977 .count = num, \
1978 .info = alc_cap_sw_info, \
1979 .get = alc_cap_sw_get, \
1980 .put = alc_cap_sw_put, \
1981 }, \
1982 { \
1983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1984 .name = "Capture Volume", \
1985 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1986 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1987 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1988 .count = num, \
1989 .info = alc_cap_vol_info, \
1990 .get = alc_cap_vol_get, \
1991 .put = alc_cap_vol_put, \
1992 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001993 }
1994
1995#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001996 { \
1997 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1998 /* .name = "Capture Source", */ \
1999 .name = "Input Source", \
2000 .count = num, \
2001 .info = alc_mux_enum_info, \
2002 .get = alc_mux_enum_get, \
2003 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002004 }
2005
2006#define DEFINE_CAPMIX(num) \
2007static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2008 _DEFINE_CAPMIX(num), \
2009 _DEFINE_CAPSRC(num), \
2010 { } /* end */ \
2011}
2012
2013#define DEFINE_CAPMIX_NOSRC(num) \
2014static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2015 _DEFINE_CAPMIX(num), \
2016 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002017}
2018
2019/* up to three ADCs */
2020DEFINE_CAPMIX(1);
2021DEFINE_CAPMIX(2);
2022DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002023DEFINE_CAPMIX_NOSRC(1);
2024DEFINE_CAPMIX_NOSRC(2);
2025DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002026
2027/*
2028 * ALC880 5-stack model
2029 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002030 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2031 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002032 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2033 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2034 */
2035
2036/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002037static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002038 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002039 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040 { } /* end */
2041};
2042
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002043/* channel source setting (6/8 channel selection for 5-stack) */
2044/* 6ch mode */
2045static struct hda_verb alc880_fivestack_ch6_init[] = {
2046 /* set line-in to input, mute it */
2047 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2048 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002049 { } /* end */
2050};
2051
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002052/* 8ch mode */
2053static struct hda_verb alc880_fivestack_ch8_init[] = {
2054 /* set line-in to output, unmute it */
2055 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2056 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2057 { } /* end */
2058};
2059
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002060static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002061 { 6, alc880_fivestack_ch6_init },
2062 { 8, alc880_fivestack_ch8_init },
2063};
2064
2065
2066/*
2067 * ALC880 6-stack model
2068 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002069 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2070 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2072 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2073 */
2074
2075static hda_nid_t alc880_6st_dac_nids[4] = {
2076 /* front, rear, clfe, rear_surr */
2077 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002078};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002079
2080static struct hda_input_mux alc880_6stack_capture_source = {
2081 .num_items = 4,
2082 .items = {
2083 { "Mic", 0x0 },
2084 { "Front Mic", 0x1 },
2085 { "Line", 0x2 },
2086 { "CD", 0x4 },
2087 },
2088};
2089
2090/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002091static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002092 { 8, NULL },
2093};
2094
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002095static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002096 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002098 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002099 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002100 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2101 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002102 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2103 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002104 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002105 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2113 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002114 {
2115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2116 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002117 .info = alc_ch_mode_info,
2118 .get = alc_ch_mode_get,
2119 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002120 },
2121 { } /* end */
2122};
2123
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002124
2125/*
2126 * ALC880 W810 model
2127 *
2128 * W810 has rear IO for:
2129 * Front (DAC 02)
2130 * Surround (DAC 03)
2131 * Center/LFE (DAC 04)
2132 * Digital out (06)
2133 *
2134 * The system also has a pair of internal speakers, and a headphone jack.
2135 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002136 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002137 * There is a variable resistor to control the speaker or headphone
2138 * volume. This is a hardware-only device without a software API.
2139 *
2140 * Plugging headphones in will disable the internal speakers. This is
2141 * implemented in hardware, not via the driver using jack sense. In
2142 * a similar fashion, plugging into the rear socket marked "front" will
2143 * disable both the speakers and headphones.
2144 *
2145 * For input, there's a microphone jack, and an "audio in" jack.
2146 * These may not do anything useful with this driver yet, because I
2147 * haven't setup any initialization verbs for these yet...
2148 */
2149
2150static hda_nid_t alc880_w810_dac_nids[3] = {
2151 /* front, rear/surround, clfe */
2152 0x02, 0x03, 0x04
2153};
2154
2155/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002156static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002157 { 6, NULL }
2158};
2159
2160/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002161static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002163 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002164 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002165 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002166 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2167 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002168 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2169 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2171 { } /* end */
2172};
2173
2174
2175/*
2176 * Z710V model
2177 *
2178 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002179 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2180 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181 */
2182
2183static hda_nid_t alc880_z71v_dac_nids[1] = {
2184 0x02
2185};
2186#define ALC880_Z71V_HP_DAC 0x03
2187
2188/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002189static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002190 { 2, NULL }
2191};
2192
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002193static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002195 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002196 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002197 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2202 { } /* end */
2203};
2204
2205
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002206/*
2207 * ALC880 F1734 model
2208 *
2209 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2210 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2211 */
2212
2213static hda_nid_t alc880_f1734_dac_nids[1] = {
2214 0x03
2215};
2216#define ALC880_F1734_HP_DAC 0x02
2217
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002218static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002219 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002220 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002221 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2222 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002223 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2224 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002227 { } /* end */
2228};
2229
Takashi Iwai937b4162008-02-11 14:52:36 +01002230static struct hda_input_mux alc880_f1734_capture_source = {
2231 .num_items = 2,
2232 .items = {
2233 { "Mic", 0x1 },
2234 { "CD", 0x4 },
2235 },
2236};
2237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002238
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239/*
2240 * ALC880 ASUS model
2241 *
2242 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2243 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2244 * Mic = 0x18, Line = 0x1a
2245 */
2246
2247#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2248#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2249
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002250static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002254 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002255 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2256 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002257 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2258 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002259 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2260 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2261 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2262 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002265 {
2266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2267 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002268 .info = alc_ch_mode_info,
2269 .get = alc_ch_mode_get,
2270 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002271 },
2272 { } /* end */
2273};
2274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275/*
2276 * ALC880 ASUS W1V model
2277 *
2278 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2279 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2280 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2281 */
2282
2283/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002284static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2286 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002287 { } /* end */
2288};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002289
Kailang Yangdf694da2005-12-05 19:42:22 +01002290/* TCL S700 */
2291static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2292 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2294 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2296 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2299 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2300 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002301 { } /* end */
2302};
2303
Kailang Yangccc656c2006-10-17 12:32:26 +02002304/* Uniwill */
2305static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002306 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2307 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2308 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2309 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002310 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2312 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2313 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2315 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2317 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2320 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2321 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002322 {
2323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2324 .name = "Channel Mode",
2325 .info = alc_ch_mode_info,
2326 .get = alc_ch_mode_get,
2327 .put = alc_ch_mode_put,
2328 },
2329 { } /* end */
2330};
2331
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002332static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2333 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2334 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2336 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2337 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2338 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2339 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2340 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2341 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2342 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2343 { } /* end */
2344};
2345
Kailang Yangccc656c2006-10-17 12:32:26 +02002346static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002347 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2348 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2349 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2350 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2353 { } /* end */
2354};
2355
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002357 * virtual master controls
2358 */
2359
2360/*
2361 * slave controls for virtual master
2362 */
2363static const char *alc_slave_vols[] = {
2364 "Front Playback Volume",
2365 "Surround Playback Volume",
2366 "Center Playback Volume",
2367 "LFE Playback Volume",
2368 "Side Playback Volume",
2369 "Headphone Playback Volume",
2370 "Speaker Playback Volume",
2371 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002372 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002373 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002374 NULL,
2375};
2376
2377static const char *alc_slave_sws[] = {
2378 "Front Playback Switch",
2379 "Surround Playback Switch",
2380 "Center Playback Switch",
2381 "LFE Playback Switch",
2382 "Side Playback Switch",
2383 "Headphone Playback Switch",
2384 "Speaker Playback Switch",
2385 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002386 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002387 NULL,
2388};
2389
2390/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002391 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002393
2394static void alc_free_kctls(struct hda_codec *codec);
2395
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002396/* additional beep mixers; the actual parameters are overwritten at build */
2397static struct snd_kcontrol_new alc_beep_mixer[] = {
2398 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2399 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2400 { } /* end */
2401};
2402
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403static int alc_build_controls(struct hda_codec *codec)
2404{
2405 struct alc_spec *spec = codec->spec;
2406 int err;
2407 int i;
2408
2409 for (i = 0; i < spec->num_mixers; i++) {
2410 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2411 if (err < 0)
2412 return err;
2413 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002414 if (spec->cap_mixer) {
2415 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2416 if (err < 0)
2417 return err;
2418 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002419 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002420 err = snd_hda_create_spdif_out_ctls(codec,
2421 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 if (err < 0)
2423 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002424 if (!spec->no_analog) {
2425 err = snd_hda_create_spdif_share_sw(codec,
2426 &spec->multiout);
2427 if (err < 0)
2428 return err;
2429 spec->multiout.share_spdif = 1;
2430 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 }
2432 if (spec->dig_in_nid) {
2433 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2434 if (err < 0)
2435 return err;
2436 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002437
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002438 /* create beep controls if needed */
2439 if (spec->beep_amp) {
2440 struct snd_kcontrol_new *knew;
2441 for (knew = alc_beep_mixer; knew->name; knew++) {
2442 struct snd_kcontrol *kctl;
2443 kctl = snd_ctl_new1(knew, codec);
2444 if (!kctl)
2445 return -ENOMEM;
2446 kctl->private_value = spec->beep_amp;
2447 err = snd_hda_ctl_add(codec, kctl);
2448 if (err < 0)
2449 return err;
2450 }
2451 }
2452
Takashi Iwai2134ea42008-01-10 16:53:55 +01002453 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002454 if (!spec->no_analog &&
2455 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002456 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002457 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002458 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002459 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002460 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002461 if (err < 0)
2462 return err;
2463 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002464 if (!spec->no_analog &&
2465 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002466 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2467 NULL, alc_slave_sws);
2468 if (err < 0)
2469 return err;
2470 }
2471
Takashi Iwai603c4012008-07-30 15:01:44 +02002472 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 return 0;
2474}
2475
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002476
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477/*
2478 * initialize the codec volumes, etc
2479 */
2480
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002481/*
2482 * generic initialization of ADC, input mixers and output mixers
2483 */
2484static struct hda_verb alc880_volume_init_verbs[] = {
2485 /*
2486 * Unmute ADC0-2 and set the default input to mic-in
2487 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002488 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002490 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002492 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002495 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2496 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002497 * Note: PASD motherboards uses the Line In 2 as the input for front
2498 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002500 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002509 /*
2510 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002512 /* set vol=0 to output mixers */
2513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2517 /* set up input amps for analog loopback */
2518 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002525 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527
2528 { }
2529};
2530
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531/*
2532 * 3-stack pin configuration:
2533 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2534 */
2535static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2536 /*
2537 * preset connection lists of input pins
2538 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2539 */
2540 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2541 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2542 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2543
2544 /*
2545 * Set pin mode and muting
2546 */
2547 /* set front pin widgets 0x14 for output */
2548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2550 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2551 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2552 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2553 /* Mic2 (as headphone out) for HP output */
2554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2556 /* Line In pin widget for input */
2557 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2558 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2559 /* Line2 (as front mic) pin widget for input and vref at 80% */
2560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2562 /* CD pin widget for input */
2563 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2564
2565 { }
2566};
2567
2568/*
2569 * 5-stack pin configuration:
2570 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2571 * line-in/side = 0x1a, f-mic = 0x1b
2572 */
2573static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2574 /*
2575 * preset connection lists of input pins
2576 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2577 */
2578 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2579 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2580
2581 /*
2582 * Set pin mode and muting
2583 */
2584 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2588 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002589 /* unmute pins for output (no gain on this amp) */
2590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2594
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2598 /* Mic2 (as headphone out) for HP output */
2599 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002601 /* Line In pin widget for input */
2602 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2604 /* Line2 (as front mic) pin widget for input and vref at 80% */
2605 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2606 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2607 /* CD pin widget for input */
2608 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609
2610 { }
2611};
2612
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002613/*
2614 * W810 pin configuration:
2615 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2616 */
2617static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618 /* hphone/speaker input selector: front DAC */
2619 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2620
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2625 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2627
2628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002629 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002630
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 { }
2632};
2633
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634/*
2635 * Z71V pin configuration:
2636 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2637 */
2638static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002640 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002641 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002643
Takashi Iwai16ded522005-06-10 19:58:24 +02002644 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002647 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002648
2649 { }
2650};
2651
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002652/*
2653 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002654 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2655 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002656 */
2657static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2658 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2659
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002666 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2668
Takashi Iwai16ded522005-06-10 19:58:24 +02002669 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002671 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002676 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002678
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002679 { }
2680};
Takashi Iwai16ded522005-06-10 19:58:24 +02002681
Kailang Yangccc656c2006-10-17 12:32:26 +02002682/*
2683 * Uniwill pin configuration:
2684 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2685 * line = 0x1a
2686 */
2687static struct hda_verb alc880_uniwill_init_verbs[] = {
2688 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2689
2690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2696 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2697 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2704
2705 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2707 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2711 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2712 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2713 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2714
2715 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2716 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2717
2718 { }
2719};
2720
2721/*
2722* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002723* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002724 */
2725static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2726 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2727
2728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2735 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2737 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2739 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2740
2741 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2743 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2744 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2745 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2746 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2747
2748 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2749 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2750
2751 { }
2752};
2753
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002754static struct hda_verb alc880_beep_init_verbs[] = {
2755 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2756 { }
2757};
2758
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002759/* auto-toggle front mic */
2760static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2761{
2762 unsigned int present;
2763 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002764
2765 present = snd_hda_codec_read(codec, 0x18, 0,
2766 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002767 bits = present ? HDA_AMP_MUTE : 0;
2768 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002769}
2770
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002771static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002772{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002773 struct alc_spec *spec = codec->spec;
2774
2775 spec->autocfg.hp_pins[0] = 0x14;
2776 spec->autocfg.speaker_pins[0] = 0x15;
2777 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002778}
2779
2780static void alc880_uniwill_init_hook(struct hda_codec *codec)
2781{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002782 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002783 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002784}
2785
2786static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2787 unsigned int res)
2788{
2789 /* Looks like the unsol event is incompatible with the standard
2790 * definition. 4bit tag is placed at 28 bit!
2791 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002792 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002793 case ALC880_MIC_EVENT:
2794 alc880_uniwill_mic_automute(codec);
2795 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002796 default:
2797 alc_automute_amp_unsol_event(codec, res);
2798 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002799 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002800}
2801
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002802static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002803{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002804 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002805
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002806 spec->autocfg.hp_pins[0] = 0x14;
2807 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002808}
2809
2810static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2811{
2812 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002813
Kailang Yangccc656c2006-10-17 12:32:26 +02002814 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002815 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2816 present &= HDA_AMP_VOLMASK;
2817 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2818 HDA_AMP_VOLMASK, present);
2819 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2820 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002821}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002822
Kailang Yangccc656c2006-10-17 12:32:26 +02002823static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2824 unsigned int res)
2825{
2826 /* Looks like the unsol event is incompatible with the standard
2827 * definition. 4bit tag is placed at 28 bit!
2828 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002829 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002830 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002831 else
2832 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002833}
2834
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002835/*
2836 * F1734 pin configuration:
2837 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2838 */
2839static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002840 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002841 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2842 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2843 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2844 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2845
2846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2850
2851 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002853 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2855 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2857 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2859 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002860
Takashi Iwai937b4162008-02-11 14:52:36 +01002861 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2862 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2863
Takashi Iwai16ded522005-06-10 19:58:24 +02002864 { }
2865};
2866
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002867/*
2868 * ASUS pin configuration:
2869 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2870 */
2871static struct hda_verb alc880_pin_asus_init_verbs[] = {
2872 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2873 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2874 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2875 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2876
2877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2881 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2885
2886 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2888 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2894 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002895
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002896 { }
2897};
2898
2899/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002900#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2901#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002902#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002903
Kailang Yangdf694da2005-12-05 19:42:22 +01002904/* Clevo m520g init */
2905static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2906 /* headphone output */
2907 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2908 /* line-out */
2909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 /* Line-in */
2912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2914 /* CD */
2915 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2916 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 /* Mic1 (rear panel) */
2918 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2919 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 /* Mic2 (front panel) */
2921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2923 /* headphone */
2924 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 /* change to EAPD mode */
2927 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2928 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2929
2930 { }
2931};
2932
2933static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002934 /* change to EAPD mode */
2935 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2936 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2937
Kailang Yangdf694da2005-12-05 19:42:22 +01002938 /* Headphone output */
2939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2940 /* Front output*/
2941 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2943
2944 /* Line In pin widget for input */
2945 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2946 /* CD pin widget for input */
2947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2948 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2950
2951 /* change to EAPD mode */
2952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2953 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2954
2955 { }
2956};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002957
2958/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002959 * LG m1 express dual
2960 *
2961 * Pin assignment:
2962 * Rear Line-In/Out (blue): 0x14
2963 * Build-in Mic-In: 0x15
2964 * Speaker-out: 0x17
2965 * HP-Out (green): 0x1b
2966 * Mic-In/Out (red): 0x19
2967 * SPDIF-Out: 0x1e
2968 */
2969
2970/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2971static hda_nid_t alc880_lg_dac_nids[3] = {
2972 0x05, 0x02, 0x03
2973};
2974
2975/* seems analog CD is not working */
2976static struct hda_input_mux alc880_lg_capture_source = {
2977 .num_items = 3,
2978 .items = {
2979 { "Mic", 0x1 },
2980 { "Line", 0x5 },
2981 { "Internal Mic", 0x6 },
2982 },
2983};
2984
2985/* 2,4,6 channel modes */
2986static struct hda_verb alc880_lg_ch2_init[] = {
2987 /* set line-in and mic-in to input */
2988 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2989 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2990 { }
2991};
2992
2993static struct hda_verb alc880_lg_ch4_init[] = {
2994 /* set line-in to out and mic-in to input */
2995 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2996 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2997 { }
2998};
2999
3000static struct hda_verb alc880_lg_ch6_init[] = {
3001 /* set line-in and mic-in to output */
3002 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3003 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3004 { }
3005};
3006
3007static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3008 { 2, alc880_lg_ch2_init },
3009 { 4, alc880_lg_ch4_init },
3010 { 6, alc880_lg_ch6_init },
3011};
3012
3013static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003016 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3017 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3018 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3019 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3020 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3021 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3026 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3027 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3028 {
3029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3030 .name = "Channel Mode",
3031 .info = alc_ch_mode_info,
3032 .get = alc_ch_mode_get,
3033 .put = alc_ch_mode_put,
3034 },
3035 { } /* end */
3036};
3037
3038static struct hda_verb alc880_lg_init_verbs[] = {
3039 /* set capture source to mic-in */
3040 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3041 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3043 /* mute all amp mixer inputs */
3044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003047 /* line-in to input */
3048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3050 /* built-in mic */
3051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3053 /* speaker-out */
3054 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3056 /* mic-in to input */
3057 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3058 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 /* HP-out */
3061 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3063 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3064 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003066 { }
3067};
3068
3069/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003070static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003071{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003072 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003073
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003074 spec->autocfg.hp_pins[0] = 0x1b;
3075 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003076}
3077
3078/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003079 * LG LW20
3080 *
3081 * Pin assignment:
3082 * Speaker-out: 0x14
3083 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003084 * Built-in Mic-In: 0x19
3085 * Line-In: 0x1b
3086 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003087 * SPDIF-Out: 0x1e
3088 */
3089
Takashi Iwaid6815182006-03-23 16:06:23 +01003090static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003091 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003092 .items = {
3093 { "Mic", 0x0 },
3094 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003095 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003096 },
3097};
3098
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003099#define alc880_lg_lw_modes alc880_threestack_modes
3100
Takashi Iwaid6815182006-03-23 16:06:23 +01003101static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3103 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3104 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3105 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3106 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3107 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3108 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3109 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3114 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3115 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003116 {
3117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3118 .name = "Channel Mode",
3119 .info = alc_ch_mode_info,
3120 .get = alc_ch_mode_get,
3121 .put = alc_ch_mode_put,
3122 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003123 { } /* end */
3124};
3125
3126static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003127 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3128 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3129 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3130
Takashi Iwaid6815182006-03-23 16:06:23 +01003131 /* set capture source to mic-in */
3132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3133 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003136 /* speaker-out */
3137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3139 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3142 /* mic-in to input */
3143 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3144 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3145 /* built-in mic */
3146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3148 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003149 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003150 { }
3151};
3152
3153/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003154static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003155{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003156 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003157
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003158 spec->autocfg.hp_pins[0] = 0x1b;
3159 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003160}
3161
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003162static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3163 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3164 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3167 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3168 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3169 { } /* end */
3170};
3171
3172static struct hda_input_mux alc880_medion_rim_capture_source = {
3173 .num_items = 2,
3174 .items = {
3175 { "Mic", 0x0 },
3176 { "Internal Mic", 0x1 },
3177 },
3178};
3179
3180static struct hda_verb alc880_medion_rim_init_verbs[] = {
3181 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3182
3183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3184 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185
3186 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3187 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3188 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3189 /* Mic2 (as headphone out) for HP output */
3190 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3192 /* Internal Speaker */
3193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195
3196 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3197 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3198
3199 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3200 { }
3201};
3202
3203/* toggle speaker-output according to the hp-jack state */
3204static void alc880_medion_rim_automute(struct hda_codec *codec)
3205{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003206 struct alc_spec *spec = codec->spec;
3207 alc_automute_amp(codec);
3208 /* toggle EAPD */
3209 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003210 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3211 else
3212 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3213}
3214
3215static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3216 unsigned int res)
3217{
3218 /* Looks like the unsol event is incompatible with the standard
3219 * definition. 4bit tag is placed at 28 bit!
3220 */
3221 if ((res >> 28) == ALC880_HP_EVENT)
3222 alc880_medion_rim_automute(codec);
3223}
3224
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003225static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003226{
3227 struct alc_spec *spec = codec->spec;
3228
3229 spec->autocfg.hp_pins[0] = 0x14;
3230 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003231}
3232
Takashi Iwaicb53c622007-08-10 17:21:45 +02003233#ifdef CONFIG_SND_HDA_POWER_SAVE
3234static struct hda_amp_list alc880_loopbacks[] = {
3235 { 0x0b, HDA_INPUT, 0 },
3236 { 0x0b, HDA_INPUT, 1 },
3237 { 0x0b, HDA_INPUT, 2 },
3238 { 0x0b, HDA_INPUT, 3 },
3239 { 0x0b, HDA_INPUT, 4 },
3240 { } /* end */
3241};
3242
3243static struct hda_amp_list alc880_lg_loopbacks[] = {
3244 { 0x0b, HDA_INPUT, 1 },
3245 { 0x0b, HDA_INPUT, 6 },
3246 { 0x0b, HDA_INPUT, 7 },
3247 { } /* end */
3248};
3249#endif
3250
Takashi Iwaid6815182006-03-23 16:06:23 +01003251/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003252 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003253 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003254
Linus Torvalds1da177e2005-04-16 15:20:36 -07003255static int alc_init(struct hda_codec *codec)
3256{
3257 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003258 unsigned int i;
3259
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003260 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003261 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003262
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263 for (i = 0; i < spec->num_init_verbs; i++)
3264 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003265
3266 if (spec->init_hook)
3267 spec->init_hook(codec);
3268
Linus Torvalds1da177e2005-04-16 15:20:36 -07003269 return 0;
3270}
3271
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003272static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3273{
3274 struct alc_spec *spec = codec->spec;
3275
3276 if (spec->unsol_event)
3277 spec->unsol_event(codec, res);
3278}
3279
Takashi Iwaicb53c622007-08-10 17:21:45 +02003280#ifdef CONFIG_SND_HDA_POWER_SAVE
3281static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3282{
3283 struct alc_spec *spec = codec->spec;
3284 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3285}
3286#endif
3287
Linus Torvalds1da177e2005-04-16 15:20:36 -07003288/*
3289 * Analog playback callbacks
3290 */
3291static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3292 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003293 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003294{
3295 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003296 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3297 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003298}
3299
3300static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3301 struct hda_codec *codec,
3302 unsigned int stream_tag,
3303 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003304 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003305{
3306 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003307 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3308 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003309}
3310
3311static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3312 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003313 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003314{
3315 struct alc_spec *spec = codec->spec;
3316 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3317}
3318
3319/*
3320 * Digital out
3321 */
3322static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3323 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003324 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325{
3326 struct alc_spec *spec = codec->spec;
3327 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3328}
3329
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003330static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3331 struct hda_codec *codec,
3332 unsigned int stream_tag,
3333 unsigned int format,
3334 struct snd_pcm_substream *substream)
3335{
3336 struct alc_spec *spec = codec->spec;
3337 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3338 stream_tag, format, substream);
3339}
3340
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003341static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3342 struct hda_codec *codec,
3343 struct snd_pcm_substream *substream)
3344{
3345 struct alc_spec *spec = codec->spec;
3346 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3347}
3348
Linus Torvalds1da177e2005-04-16 15:20:36 -07003349static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3350 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003351 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003352{
3353 struct alc_spec *spec = codec->spec;
3354 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3355}
3356
3357/*
3358 * Analog capture
3359 */
Takashi Iwai63300792008-01-24 15:31:36 +01003360static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003361 struct hda_codec *codec,
3362 unsigned int stream_tag,
3363 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003364 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003365{
3366 struct alc_spec *spec = codec->spec;
3367
Takashi Iwai63300792008-01-24 15:31:36 +01003368 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369 stream_tag, 0, format);
3370 return 0;
3371}
3372
Takashi Iwai63300792008-01-24 15:31:36 +01003373static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003375 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003376{
3377 struct alc_spec *spec = codec->spec;
3378
Takashi Iwai888afa12008-03-18 09:57:50 +01003379 snd_hda_codec_cleanup_stream(codec,
3380 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003381 return 0;
3382}
3383
3384
3385/*
3386 */
3387static struct hda_pcm_stream alc880_pcm_analog_playback = {
3388 .substreams = 1,
3389 .channels_min = 2,
3390 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003391 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003392 .ops = {
3393 .open = alc880_playback_pcm_open,
3394 .prepare = alc880_playback_pcm_prepare,
3395 .cleanup = alc880_playback_pcm_cleanup
3396 },
3397};
3398
3399static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003400 .substreams = 1,
3401 .channels_min = 2,
3402 .channels_max = 2,
3403 /* NID is set in alc_build_pcms */
3404};
3405
3406static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3407 .substreams = 1,
3408 .channels_min = 2,
3409 .channels_max = 2,
3410 /* NID is set in alc_build_pcms */
3411};
3412
3413static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3414 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003415 .channels_min = 2,
3416 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003418 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003419 .prepare = alc880_alt_capture_pcm_prepare,
3420 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003421 },
3422};
3423
3424static struct hda_pcm_stream alc880_pcm_digital_playback = {
3425 .substreams = 1,
3426 .channels_min = 2,
3427 .channels_max = 2,
3428 /* NID is set in alc_build_pcms */
3429 .ops = {
3430 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003431 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003432 .prepare = alc880_dig_playback_pcm_prepare,
3433 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003434 },
3435};
3436
3437static struct hda_pcm_stream alc880_pcm_digital_capture = {
3438 .substreams = 1,
3439 .channels_min = 2,
3440 .channels_max = 2,
3441 /* NID is set in alc_build_pcms */
3442};
3443
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003444/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003445static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003446 .substreams = 0,
3447 .channels_min = 0,
3448 .channels_max = 0,
3449};
3450
Linus Torvalds1da177e2005-04-16 15:20:36 -07003451static int alc_build_pcms(struct hda_codec *codec)
3452{
3453 struct alc_spec *spec = codec->spec;
3454 struct hda_pcm *info = spec->pcm_rec;
3455 int i;
3456
3457 codec->num_pcms = 1;
3458 codec->pcm_info = info;
3459
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003460 if (spec->no_analog)
3461 goto skip_analog;
3462
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003463 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3464 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003465 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003466
Takashi Iwai4a471b72005-12-07 13:56:29 +01003467 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003468 if (snd_BUG_ON(!spec->multiout.dac_nids))
3469 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003470 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3471 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3472 }
3473 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003474 if (snd_BUG_ON(!spec->adc_nids))
3475 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003476 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3477 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3478 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003479
Takashi Iwai4a471b72005-12-07 13:56:29 +01003480 if (spec->channel_mode) {
3481 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3482 for (i = 0; i < spec->num_channel_mode; i++) {
3483 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3484 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3485 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003486 }
3487 }
3488
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003489 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003490 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003491 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003492 snprintf(spec->stream_name_digital,
3493 sizeof(spec->stream_name_digital),
3494 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003495 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003496 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003497 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003498 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003499 if (spec->dig_out_type)
3500 info->pcm_type = spec->dig_out_type;
3501 else
3502 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003503 if (spec->multiout.dig_out_nid &&
3504 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3506 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3507 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003508 if (spec->dig_in_nid &&
3509 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003510 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3511 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3512 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003513 /* FIXME: do we need this for all Realtek codec models? */
3514 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003515 }
3516
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003517 if (spec->no_analog)
3518 return 0;
3519
Takashi Iwaie08a0072006-09-07 17:52:14 +02003520 /* If the use of more than one ADC is requested for the current
3521 * model, configure a second analog capture-only PCM.
3522 */
3523 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003524 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3525 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003526 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003527 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003528 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003529 if (spec->alt_dac_nid) {
3530 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3531 *spec->stream_analog_alt_playback;
3532 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3533 spec->alt_dac_nid;
3534 } else {
3535 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3536 alc_pcm_null_stream;
3537 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3538 }
3539 if (spec->num_adc_nids > 1) {
3540 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3541 *spec->stream_analog_alt_capture;
3542 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3543 spec->adc_nids[1];
3544 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3545 spec->num_adc_nids - 1;
3546 } else {
3547 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3548 alc_pcm_null_stream;
3549 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003550 }
3551 }
3552
Linus Torvalds1da177e2005-04-16 15:20:36 -07003553 return 0;
3554}
3555
Takashi Iwai603c4012008-07-30 15:01:44 +02003556static void alc_free_kctls(struct hda_codec *codec)
3557{
3558 struct alc_spec *spec = codec->spec;
3559
3560 if (spec->kctls.list) {
3561 struct snd_kcontrol_new *kctl = spec->kctls.list;
3562 int i;
3563 for (i = 0; i < spec->kctls.used; i++)
3564 kfree(kctl[i].name);
3565 }
3566 snd_array_free(&spec->kctls);
3567}
3568
Linus Torvalds1da177e2005-04-16 15:20:36 -07003569static void alc_free(struct hda_codec *codec)
3570{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003572
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003573 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003574 return;
3575
Takashi Iwai603c4012008-07-30 15:01:44 +02003576 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003578 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003579}
3580
Takashi Iwaie044c392008-10-27 16:56:24 +01003581#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003582static int alc_resume(struct hda_codec *codec)
3583{
Takashi Iwaie044c392008-10-27 16:56:24 +01003584 codec->patch_ops.init(codec);
3585 snd_hda_codec_resume_amp(codec);
3586 snd_hda_codec_resume_cache(codec);
3587 return 0;
3588}
Takashi Iwaie044c392008-10-27 16:56:24 +01003589#endif
3590
Linus Torvalds1da177e2005-04-16 15:20:36 -07003591/*
3592 */
3593static struct hda_codec_ops alc_patch_ops = {
3594 .build_controls = alc_build_controls,
3595 .build_pcms = alc_build_pcms,
3596 .init = alc_init,
3597 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003598 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003599#ifdef SND_HDA_NEEDS_RESUME
3600 .resume = alc_resume,
3601#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003602#ifdef CONFIG_SND_HDA_POWER_SAVE
3603 .check_power_status = alc_check_power_status,
3604#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003605};
3606
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003607
3608/*
3609 * Test configuration for debugging
3610 *
3611 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3612 * enum controls.
3613 */
3614#ifdef CONFIG_SND_DEBUG
3615static hda_nid_t alc880_test_dac_nids[4] = {
3616 0x02, 0x03, 0x04, 0x05
3617};
3618
3619static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003620 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003621 .items = {
3622 { "In-1", 0x0 },
3623 { "In-2", 0x1 },
3624 { "In-3", 0x2 },
3625 { "In-4", 0x3 },
3626 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003627 { "Front", 0x5 },
3628 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003629 },
3630};
3631
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003632static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003633 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003634 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003635 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003636 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003637};
3638
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003639static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3640 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003641{
3642 static char *texts[] = {
3643 "N/A", "Line Out", "HP Out",
3644 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3645 };
3646 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3647 uinfo->count = 1;
3648 uinfo->value.enumerated.items = 8;
3649 if (uinfo->value.enumerated.item >= 8)
3650 uinfo->value.enumerated.item = 7;
3651 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3652 return 0;
3653}
3654
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003655static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3656 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003657{
3658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3659 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3660 unsigned int pin_ctl, item = 0;
3661
3662 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3663 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3664 if (pin_ctl & AC_PINCTL_OUT_EN) {
3665 if (pin_ctl & AC_PINCTL_HP_EN)
3666 item = 2;
3667 else
3668 item = 1;
3669 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3670 switch (pin_ctl & AC_PINCTL_VREFEN) {
3671 case AC_PINCTL_VREF_HIZ: item = 3; break;
3672 case AC_PINCTL_VREF_50: item = 4; break;
3673 case AC_PINCTL_VREF_GRD: item = 5; break;
3674 case AC_PINCTL_VREF_80: item = 6; break;
3675 case AC_PINCTL_VREF_100: item = 7; break;
3676 }
3677 }
3678 ucontrol->value.enumerated.item[0] = item;
3679 return 0;
3680}
3681
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003682static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3683 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003684{
3685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3686 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3687 static unsigned int ctls[] = {
3688 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3689 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3690 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3691 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3692 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3693 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3694 };
3695 unsigned int old_ctl, new_ctl;
3696
3697 old_ctl = snd_hda_codec_read(codec, nid, 0,
3698 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3699 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3700 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003701 int val;
3702 snd_hda_codec_write_cache(codec, nid, 0,
3703 AC_VERB_SET_PIN_WIDGET_CONTROL,
3704 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003705 val = ucontrol->value.enumerated.item[0] >= 3 ?
3706 HDA_AMP_MUTE : 0;
3707 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3708 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003709 return 1;
3710 }
3711 return 0;
3712}
3713
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003714static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3715 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003716{
3717 static char *texts[] = {
3718 "Front", "Surround", "CLFE", "Side"
3719 };
3720 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3721 uinfo->count = 1;
3722 uinfo->value.enumerated.items = 4;
3723 if (uinfo->value.enumerated.item >= 4)
3724 uinfo->value.enumerated.item = 3;
3725 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3726 return 0;
3727}
3728
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003729static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3730 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003731{
3732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3733 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3734 unsigned int sel;
3735
3736 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3737 ucontrol->value.enumerated.item[0] = sel & 3;
3738 return 0;
3739}
3740
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003741static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3742 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003743{
3744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3745 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3746 unsigned int sel;
3747
3748 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3749 if (ucontrol->value.enumerated.item[0] != sel) {
3750 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003751 snd_hda_codec_write_cache(codec, nid, 0,
3752 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003753 return 1;
3754 }
3755 return 0;
3756}
3757
3758#define PIN_CTL_TEST(xname,nid) { \
3759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3760 .name = xname, \
3761 .info = alc_test_pin_ctl_info, \
3762 .get = alc_test_pin_ctl_get, \
3763 .put = alc_test_pin_ctl_put, \
3764 .private_value = nid \
3765 }
3766
3767#define PIN_SRC_TEST(xname,nid) { \
3768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3769 .name = xname, \
3770 .info = alc_test_pin_src_info, \
3771 .get = alc_test_pin_src_get, \
3772 .put = alc_test_pin_src_put, \
3773 .private_value = nid \
3774 }
3775
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003776static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003777 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3778 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3779 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3780 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003781 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3782 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3783 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3784 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003785 PIN_CTL_TEST("Front Pin Mode", 0x14),
3786 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3787 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3788 PIN_CTL_TEST("Side Pin Mode", 0x17),
3789 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3790 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3791 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3792 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3793 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3794 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3795 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3796 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3797 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3798 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3799 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3800 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3801 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3802 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3803 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3804 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3805 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3806 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003807 {
3808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3809 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003810 .info = alc_ch_mode_info,
3811 .get = alc_ch_mode_get,
3812 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003813 },
3814 { } /* end */
3815};
3816
3817static struct hda_verb alc880_test_init_verbs[] = {
3818 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3825 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3826 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003827 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3830 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3831 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003832 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003833 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3836 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003837 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3839 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3841 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003842 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003843 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3844 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003845 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3846 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3847 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003848 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003849 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3850 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3852 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003853 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003855 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003857 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003859 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003860 /* Analog input/passthru */
3861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003866 { }
3867};
3868#endif
3869
Linus Torvalds1da177e2005-04-16 15:20:36 -07003870/*
3871 */
3872
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003873static const char *alc880_models[ALC880_MODEL_LAST] = {
3874 [ALC880_3ST] = "3stack",
3875 [ALC880_TCL_S700] = "tcl",
3876 [ALC880_3ST_DIG] = "3stack-digout",
3877 [ALC880_CLEVO] = "clevo",
3878 [ALC880_5ST] = "5stack",
3879 [ALC880_5ST_DIG] = "5stack-digout",
3880 [ALC880_W810] = "w810",
3881 [ALC880_Z71V] = "z71v",
3882 [ALC880_6ST] = "6stack",
3883 [ALC880_6ST_DIG] = "6stack-digout",
3884 [ALC880_ASUS] = "asus",
3885 [ALC880_ASUS_W1V] = "asus-w1v",
3886 [ALC880_ASUS_DIG] = "asus-dig",
3887 [ALC880_ASUS_DIG2] = "asus-dig2",
3888 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003889 [ALC880_UNIWILL_P53] = "uniwill-p53",
3890 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003891 [ALC880_F1734] = "F1734",
3892 [ALC880_LG] = "lg",
3893 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003894 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003895#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003896 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003897#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003898 [ALC880_AUTO] = "auto",
3899};
3900
3901static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003902 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003903 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3904 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3905 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3906 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3907 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3908 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3909 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3910 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003911 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3912 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003913 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3914 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3915 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3916 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3917 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3918 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3919 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3920 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3921 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3922 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003923 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003924 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3925 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3926 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003927 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003928 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003929 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3930 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003931 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3932 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003933 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3934 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3935 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3936 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003937 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3938 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003939 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003940 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003941 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003942 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003943 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3944 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003945 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003946 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003947 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003948 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003949 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003950 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003951 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003952 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003953 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3955 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003956 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003957 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3958 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3959 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3960 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003961 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3962 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003963 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003964 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003965 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3966 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003967 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3968 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3969 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003970 /* default Intel */
3971 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003972 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3973 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003974 {}
3975};
3976
Takashi Iwai16ded522005-06-10 19:58:24 +02003977/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003978 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003979 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003980static struct alc_config_preset alc880_presets[] = {
3981 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003982 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003983 .init_verbs = { alc880_volume_init_verbs,
3984 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003985 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003986 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003987 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3988 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003989 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003990 .input_mux = &alc880_capture_source,
3991 },
3992 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003993 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003994 .init_verbs = { alc880_volume_init_verbs,
3995 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003996 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003997 .dac_nids = alc880_dac_nids,
3998 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003999 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4000 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004001 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004002 .input_mux = &alc880_capture_source,
4003 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004004 [ALC880_TCL_S700] = {
4005 .mixers = { alc880_tcl_s700_mixer },
4006 .init_verbs = { alc880_volume_init_verbs,
4007 alc880_pin_tcl_S700_init_verbs,
4008 alc880_gpio2_init_verbs },
4009 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4010 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004011 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4012 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004013 .hp_nid = 0x03,
4014 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4015 .channel_mode = alc880_2_jack_modes,
4016 .input_mux = &alc880_capture_source,
4017 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004018 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004019 .mixers = { alc880_three_stack_mixer,
4020 alc880_five_stack_mixer},
4021 .init_verbs = { alc880_volume_init_verbs,
4022 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004023 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4024 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004025 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4026 .channel_mode = alc880_fivestack_modes,
4027 .input_mux = &alc880_capture_source,
4028 },
4029 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004030 .mixers = { alc880_three_stack_mixer,
4031 alc880_five_stack_mixer },
4032 .init_verbs = { alc880_volume_init_verbs,
4033 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004034 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4035 .dac_nids = alc880_dac_nids,
4036 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004037 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4038 .channel_mode = alc880_fivestack_modes,
4039 .input_mux = &alc880_capture_source,
4040 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004041 [ALC880_6ST] = {
4042 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004043 .init_verbs = { alc880_volume_init_verbs,
4044 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004045 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4046 .dac_nids = alc880_6st_dac_nids,
4047 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4048 .channel_mode = alc880_sixstack_modes,
4049 .input_mux = &alc880_6stack_capture_source,
4050 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004051 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004052 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004053 .init_verbs = { alc880_volume_init_verbs,
4054 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004055 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4056 .dac_nids = alc880_6st_dac_nids,
4057 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004058 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4059 .channel_mode = alc880_sixstack_modes,
4060 .input_mux = &alc880_6stack_capture_source,
4061 },
4062 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004064 .init_verbs = { alc880_volume_init_verbs,
4065 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004066 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004067 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4068 .dac_nids = alc880_w810_dac_nids,
4069 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004070 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4071 .channel_mode = alc880_w810_modes,
4072 .input_mux = &alc880_capture_source,
4073 },
4074 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004075 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004076 .init_verbs = { alc880_volume_init_verbs,
4077 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004078 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4079 .dac_nids = alc880_z71v_dac_nids,
4080 .dig_out_nid = ALC880_DIGOUT_NID,
4081 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004082 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4083 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004084 .input_mux = &alc880_capture_source,
4085 },
4086 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004087 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004088 .init_verbs = { alc880_volume_init_verbs,
4089 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004090 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4091 .dac_nids = alc880_f1734_dac_nids,
4092 .hp_nid = 0x02,
4093 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4094 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004095 .input_mux = &alc880_f1734_capture_source,
4096 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004097 .setup = alc880_uniwill_p53_setup,
4098 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004099 },
4100 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004101 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004102 .init_verbs = { alc880_volume_init_verbs,
4103 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 alc880_gpio1_init_verbs },
4105 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4106 .dac_nids = alc880_asus_dac_nids,
4107 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4108 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004109 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004110 .input_mux = &alc880_capture_source,
4111 },
4112 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004113 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004114 .init_verbs = { alc880_volume_init_verbs,
4115 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004116 alc880_gpio1_init_verbs },
4117 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4118 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004119 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004120 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4121 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004122 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004123 .input_mux = &alc880_capture_source,
4124 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004125 [ALC880_ASUS_DIG2] = {
4126 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004127 .init_verbs = { alc880_volume_init_verbs,
4128 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004129 alc880_gpio2_init_verbs }, /* use GPIO2 */
4130 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4131 .dac_nids = alc880_asus_dac_nids,
4132 .dig_out_nid = ALC880_DIGOUT_NID,
4133 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4134 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004135 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004136 .input_mux = &alc880_capture_source,
4137 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004138 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004139 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004140 .init_verbs = { alc880_volume_init_verbs,
4141 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 alc880_gpio1_init_verbs },
4143 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4144 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004145 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004146 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4147 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004148 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004149 .input_mux = &alc880_capture_source,
4150 },
4151 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004152 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004153 .init_verbs = { alc880_volume_init_verbs,
4154 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4156 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004157 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004158 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4159 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004160 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004161 .input_mux = &alc880_capture_source,
4162 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004163 [ALC880_UNIWILL] = {
4164 .mixers = { alc880_uniwill_mixer },
4165 .init_verbs = { alc880_volume_init_verbs,
4166 alc880_uniwill_init_verbs },
4167 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4168 .dac_nids = alc880_asus_dac_nids,
4169 .dig_out_nid = ALC880_DIGOUT_NID,
4170 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4171 .channel_mode = alc880_threestack_modes,
4172 .need_dac_fix = 1,
4173 .input_mux = &alc880_capture_source,
4174 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004175 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004176 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004177 },
4178 [ALC880_UNIWILL_P53] = {
4179 .mixers = { alc880_uniwill_p53_mixer },
4180 .init_verbs = { alc880_volume_init_verbs,
4181 alc880_uniwill_p53_init_verbs },
4182 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4183 .dac_nids = alc880_asus_dac_nids,
4184 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004185 .channel_mode = alc880_threestack_modes,
4186 .input_mux = &alc880_capture_source,
4187 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004188 .setup = alc880_uniwill_p53_setup,
4189 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004190 },
4191 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004192 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004193 .init_verbs = { alc880_volume_init_verbs,
4194 alc880_uniwill_p53_init_verbs,
4195 alc880_beep_init_verbs },
4196 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4197 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004198 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004199 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4200 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004201 .input_mux = &alc880_capture_source,
4202 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004203 .setup = alc880_uniwill_p53_setup,
4204 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004205 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004206 [ALC880_CLEVO] = {
4207 .mixers = { alc880_three_stack_mixer },
4208 .init_verbs = { alc880_volume_init_verbs,
4209 alc880_pin_clevo_init_verbs },
4210 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4211 .dac_nids = alc880_dac_nids,
4212 .hp_nid = 0x03,
4213 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4214 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004215 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004216 .input_mux = &alc880_capture_source,
4217 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004218 [ALC880_LG] = {
4219 .mixers = { alc880_lg_mixer },
4220 .init_verbs = { alc880_volume_init_verbs,
4221 alc880_lg_init_verbs },
4222 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4223 .dac_nids = alc880_lg_dac_nids,
4224 .dig_out_nid = ALC880_DIGOUT_NID,
4225 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4226 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004227 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004228 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004229 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004230 .setup = alc880_lg_setup,
4231 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004232#ifdef CONFIG_SND_HDA_POWER_SAVE
4233 .loopbacks = alc880_lg_loopbacks,
4234#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004235 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004236 [ALC880_LG_LW] = {
4237 .mixers = { alc880_lg_lw_mixer },
4238 .init_verbs = { alc880_volume_init_verbs,
4239 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004240 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004241 .dac_nids = alc880_dac_nids,
4242 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004243 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4244 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004245 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004246 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004247 .setup = alc880_lg_lw_setup,
4248 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004249 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004250 [ALC880_MEDION_RIM] = {
4251 .mixers = { alc880_medion_rim_mixer },
4252 .init_verbs = { alc880_volume_init_verbs,
4253 alc880_medion_rim_init_verbs,
4254 alc_gpio2_init_verbs },
4255 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4256 .dac_nids = alc880_dac_nids,
4257 .dig_out_nid = ALC880_DIGOUT_NID,
4258 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4259 .channel_mode = alc880_2_jack_modes,
4260 .input_mux = &alc880_medion_rim_capture_source,
4261 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004262 .setup = alc880_medion_rim_setup,
4263 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004264 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004265#ifdef CONFIG_SND_DEBUG
4266 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 .mixers = { alc880_test_mixer },
4268 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004269 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4270 .dac_nids = alc880_test_dac_nids,
4271 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004272 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4273 .channel_mode = alc880_test_modes,
4274 .input_mux = &alc880_test_capture_source,
4275 },
4276#endif
4277};
4278
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279/*
4280 * Automatic parse of I/O pins from the BIOS configuration
4281 */
4282
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283enum {
4284 ALC_CTL_WIDGET_VOL,
4285 ALC_CTL_WIDGET_MUTE,
4286 ALC_CTL_BIND_MUTE,
4287};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004288static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4290 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004291 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292};
4293
4294/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004295static int add_control(struct alc_spec *spec, int type, const char *name,
4296 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004298 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004299
Takashi Iwai603c4012008-07-30 15:01:44 +02004300 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4301 knew = snd_array_new(&spec->kctls);
4302 if (!knew)
4303 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004304 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004305 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004306 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004307 return -ENOMEM;
4308 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004309 return 0;
4310}
4311
4312#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4313#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4314#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4315#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4317#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4318#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4319#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4320#define ALC880_PIN_CD_NID 0x1c
4321
4322/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004323static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4324 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004325{
4326 hda_nid_t nid;
4327 int assigned[4];
4328 int i, j;
4329
4330 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004331 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332
4333 /* check the pins hardwired to audio widget */
4334 for (i = 0; i < cfg->line_outs; i++) {
4335 nid = cfg->line_out_pins[i];
4336 if (alc880_is_fixed_pin(nid)) {
4337 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004338 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004339 assigned[idx] = 1;
4340 }
4341 }
4342 /* left pins can be connect to any audio widget */
4343 for (i = 0; i < cfg->line_outs; i++) {
4344 nid = cfg->line_out_pins[i];
4345 if (alc880_is_fixed_pin(nid))
4346 continue;
4347 /* search for an empty channel */
4348 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004349 if (!assigned[j]) {
4350 spec->multiout.dac_nids[i] =
4351 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352 assigned[j] = 1;
4353 break;
4354 }
4355 }
4356 }
4357 spec->multiout.num_dacs = cfg->line_outs;
4358 return 0;
4359}
4360
4361/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004362static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4363 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364{
4365 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004366 static const char *chname[4] = {
4367 "Front", "Surround", NULL /*CLFE*/, "Side"
4368 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369 hda_nid_t nid;
4370 int i, err;
4371
4372 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004373 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374 continue;
4375 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4376 if (i == 2) {
4377 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004378 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4379 "Center Playback Volume",
4380 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4381 HDA_OUTPUT));
4382 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004383 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004384 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4385 "LFE Playback Volume",
4386 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4387 HDA_OUTPUT));
4388 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004389 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004390 err = add_control(spec, ALC_CTL_BIND_MUTE,
4391 "Center Playback Switch",
4392 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4393 HDA_INPUT));
4394 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004395 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004396 err = add_control(spec, ALC_CTL_BIND_MUTE,
4397 "LFE Playback Switch",
4398 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4399 HDA_INPUT));
4400 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 return err;
4402 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004403 const char *pfx;
4404 if (cfg->line_outs == 1 &&
4405 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4406 pfx = "Speaker";
4407 else
4408 pfx = chname[i];
4409 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004410 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4411 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4412 HDA_OUTPUT));
4413 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004414 return err;
Takashi Iwaicb162b62009-08-25 16:05:03 +02004415 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004416 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4417 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4418 HDA_INPUT));
4419 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004420 return err;
4421 }
4422 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004423 return 0;
4424}
4425
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004426/* add playback controls for speaker and HP outputs */
4427static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4428 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429{
4430 hda_nid_t nid;
4431 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004432 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004433
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004434 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004435 return 0;
4436
4437 if (alc880_is_fixed_pin(pin)) {
4438 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004439 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004440 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004441 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004442 else
4443 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004444 /* control HP volume/switch on the output mixer amp */
4445 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004446 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004447 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4448 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4449 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004451 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4453 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4454 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004455 return err;
4456 } else if (alc880_is_multi_pin(pin)) {
4457 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004459 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004460 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4461 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4462 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004463 return err;
4464 }
4465 return 0;
4466}
4467
4468/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4470 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004471 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472{
4473 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004474 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475
4476 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004477 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4478 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4479 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004480 return err;
4481 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004482 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4483 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4484 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004485 return err;
4486 return 0;
4487}
4488
Takashi Iwai05f5f472009-08-25 13:10:18 +02004489static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004491 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4492 return (pincap & AC_PINCAP_IN) != 0;
4493}
4494
4495/* create playback/capture controls for input pins */
4496static int alc_auto_create_input_ctls(struct hda_codec *codec,
4497 const struct auto_pin_cfg *cfg,
4498 hda_nid_t mixer,
4499 hda_nid_t cap1, hda_nid_t cap2)
4500{
4501 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004502 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004503 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004504
4505 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004506 hda_nid_t pin;
4507
4508 pin = cfg->input_pins[i];
4509 if (!alc_is_input_pin(codec, pin))
4510 continue;
4511
4512 if (mixer) {
4513 idx = get_connection_index(codec, mixer, pin);
4514 if (idx >= 0) {
4515 err = new_analog_input(spec, pin,
4516 auto_pin_cfg_labels[i],
4517 idx, mixer);
4518 if (err < 0)
4519 return err;
4520 }
4521 }
4522
4523 if (!cap1)
4524 continue;
4525 idx = get_connection_index(codec, cap1, pin);
4526 if (idx < 0 && cap2)
4527 idx = get_connection_index(codec, cap2, pin);
4528 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004529 imux->items[imux->num_items].label =
4530 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004531 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004532 imux->num_items++;
4533 }
4534 }
4535 return 0;
4536}
4537
Takashi Iwai05f5f472009-08-25 13:10:18 +02004538static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4539 const struct auto_pin_cfg *cfg)
4540{
4541 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4542}
4543
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004544static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4545 unsigned int pin_type)
4546{
4547 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4548 pin_type);
4549 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004550 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4551 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004552}
4553
Kailang Yangdf694da2005-12-05 19:42:22 +01004554static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4555 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004556 int dac_idx)
4557{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004558 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004559 /* need the manual connection? */
4560 if (alc880_is_multi_pin(nid)) {
4561 struct alc_spec *spec = codec->spec;
4562 int idx = alc880_multi_pin_idx(nid);
4563 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4564 AC_VERB_SET_CONNECT_SEL,
4565 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4566 }
4567}
4568
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004569static int get_pin_type(int line_out_type)
4570{
4571 if (line_out_type == AUTO_PIN_HP_OUT)
4572 return PIN_HP;
4573 else
4574 return PIN_OUT;
4575}
4576
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004577static void alc880_auto_init_multi_out(struct hda_codec *codec)
4578{
4579 struct alc_spec *spec = codec->spec;
4580 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004581
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004582 for (i = 0; i < spec->autocfg.line_outs; i++) {
4583 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004584 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4585 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004586 }
4587}
4588
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004589static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004590{
4591 struct alc_spec *spec = codec->spec;
4592 hda_nid_t pin;
4593
Takashi Iwai82bc9552006-03-21 11:24:42 +01004594 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004595 if (pin) /* connect to front */
4596 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004597 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004598 if (pin) /* connect to front */
4599 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4600}
4601
4602static void alc880_auto_init_analog_input(struct hda_codec *codec)
4603{
4604 struct alc_spec *spec = codec->spec;
4605 int i;
4606
4607 for (i = 0; i < AUTO_PIN_LAST; i++) {
4608 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004609 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004610 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004611 if (nid != ALC880_PIN_CD_NID &&
4612 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004613 snd_hda_codec_write(codec, nid, 0,
4614 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004615 AMP_OUT_MUTE);
4616 }
4617 }
4618}
4619
4620/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004621/* return 1 if successful, 0 if the proper config is not found,
4622 * or a negative error code
4623 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004624static int alc880_parse_auto_config(struct hda_codec *codec)
4625{
4626 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004627 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004628 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004629
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004630 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4631 alc880_ignore);
4632 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004634 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004635 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004636
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004637 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4638 if (err < 0)
4639 return err;
4640 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4641 if (err < 0)
4642 return err;
4643 err = alc880_auto_create_extra_out(spec,
4644 spec->autocfg.speaker_pins[0],
4645 "Speaker");
4646 if (err < 0)
4647 return err;
4648 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4649 "Headphone");
4650 if (err < 0)
4651 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004652 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004653 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004654 return err;
4655
4656 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4657
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004658 /* check multiple SPDIF-out (for recent codecs) */
4659 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4660 hda_nid_t dig_nid;
4661 err = snd_hda_get_connections(codec,
4662 spec->autocfg.dig_out_pins[i],
4663 &dig_nid, 1);
4664 if (err < 0)
4665 continue;
4666 if (!i)
4667 spec->multiout.dig_out_nid = dig_nid;
4668 else {
4669 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4670 spec->slave_dig_outs[i - 1] = dig_nid;
4671 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4672 break;
4673 }
4674 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004675 if (spec->autocfg.dig_in_pin)
4676 spec->dig_in_nid = ALC880_DIGIN_NID;
4677
Takashi Iwai603c4012008-07-30 15:01:44 +02004678 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004679 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680
Takashi Iwaid88897e2008-10-31 15:01:37 +01004681 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004683 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004684 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004685
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004686 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4687
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004688 return 1;
4689}
4690
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004691/* additional initialization for auto-configuration model */
4692static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004693{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004694 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004695 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004696 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004697 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004698 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004699 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004700}
4701
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004702/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4703 * one of two digital mic pins, e.g. on ALC272
4704 */
4705static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004706{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004707 struct alc_spec *spec = codec->spec;
4708 int i;
4709
4710 for (i = 0; i < spec->num_adc_nids; i++) {
4711 hda_nid_t cap = spec->capsrc_nids ?
4712 spec->capsrc_nids[i] : spec->adc_nids[i];
4713 int iidx, eidx;
4714
4715 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4716 if (iidx < 0)
4717 continue;
4718 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4719 if (eidx < 0)
4720 continue;
4721 spec->int_mic.mux_idx = iidx;
4722 spec->ext_mic.mux_idx = eidx;
4723 if (spec->capsrc_nids)
4724 spec->capsrc_nids += i;
4725 spec->adc_nids += i;
4726 spec->num_adc_nids = 1;
4727 return;
4728 }
4729 snd_printd(KERN_INFO "hda_codec: %s: "
4730 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4731 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4732 spec->auto_mic = 0; /* disable auto-mic to be sure */
4733}
4734
4735static void set_capture_mixer(struct hda_codec *codec)
4736{
4737 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004738 static struct snd_kcontrol_new *caps[2][3] = {
4739 { alc_capture_mixer_nosrc1,
4740 alc_capture_mixer_nosrc2,
4741 alc_capture_mixer_nosrc3 },
4742 { alc_capture_mixer1,
4743 alc_capture_mixer2,
4744 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004745 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004746 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4747 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004748 if (spec->auto_mic) {
4749 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004750 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004751 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004752 mux = 1;
4753 else
4754 mux = 0;
4755 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4756 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004757}
4758
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004759#define set_beep_amp(spec, nid, idx, dir) \
4760 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4761
4762/*
4763 * OK, here we have finally the patch for ALC880
4764 */
4765
Linus Torvalds1da177e2005-04-16 15:20:36 -07004766static int patch_alc880(struct hda_codec *codec)
4767{
4768 struct alc_spec *spec;
4769 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004770 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004772 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004773 if (spec == NULL)
4774 return -ENOMEM;
4775
4776 codec->spec = spec;
4777
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004778 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4779 alc880_models,
4780 alc880_cfg_tbl);
4781 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004782 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4783 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004784 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004785 }
4786
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004787 if (board_config == ALC880_AUTO) {
4788 /* automatic parse from the BIOS config */
4789 err = alc880_parse_auto_config(codec);
4790 if (err < 0) {
4791 alc_free(codec);
4792 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004793 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004794 printk(KERN_INFO
4795 "hda_codec: Cannot set up configuration "
4796 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004797 board_config = ALC880_3ST;
4798 }
4799 }
4800
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004801 err = snd_hda_attach_beep_device(codec, 0x1);
4802 if (err < 0) {
4803 alc_free(codec);
4804 return err;
4805 }
4806
Kailang Yangdf694da2005-12-05 19:42:22 +01004807 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004808 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004809
Linus Torvalds1da177e2005-04-16 15:20:36 -07004810 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4811 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004812 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004813
Linus Torvalds1da177e2005-04-16 15:20:36 -07004814 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4815 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4816
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004818 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004819 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004820 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004821 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004822 if (wcap != AC_WID_AUD_IN) {
4823 spec->adc_nids = alc880_adc_nids_alt;
4824 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004825 } else {
4826 spec->adc_nids = alc880_adc_nids;
4827 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004828 }
4829 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004830 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004831 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004832
Takashi Iwai2134ea42008-01-10 16:53:55 +01004833 spec->vmaster_nid = 0x0c;
4834
Linus Torvalds1da177e2005-04-16 15:20:36 -07004835 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004836 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004837 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004838#ifdef CONFIG_SND_HDA_POWER_SAVE
4839 if (!spec->loopback.amplist)
4840 spec->loopback.amplist = alc880_loopbacks;
4841#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004842 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004843
4844 return 0;
4845}
4846
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004847
Linus Torvalds1da177e2005-04-16 15:20:36 -07004848/*
4849 * ALC260 support
4850 */
4851
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004852static hda_nid_t alc260_dac_nids[1] = {
4853 /* front */
4854 0x02,
4855};
4856
4857static hda_nid_t alc260_adc_nids[1] = {
4858 /* ADC0 */
4859 0x04,
4860};
4861
Kailang Yangdf694da2005-12-05 19:42:22 +01004862static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004863 /* ADC1 */
4864 0x05,
4865};
4866
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004867/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4868 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4869 */
4870static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004871 /* ADC0, ADC1 */
4872 0x04, 0x05
4873};
4874
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004875#define ALC260_DIGOUT_NID 0x03
4876#define ALC260_DIGIN_NID 0x06
4877
4878static struct hda_input_mux alc260_capture_source = {
4879 .num_items = 4,
4880 .items = {
4881 { "Mic", 0x0 },
4882 { "Front Mic", 0x1 },
4883 { "Line", 0x2 },
4884 { "CD", 0x4 },
4885 },
4886};
4887
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004888/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004889 * headphone jack and the internal CD lines since these are the only pins at
4890 * which audio can appear. For flexibility, also allow the option of
4891 * recording the mixer output on the second ADC (ADC0 doesn't have a
4892 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004893 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004894static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4895 {
4896 .num_items = 3,
4897 .items = {
4898 { "Mic/Line", 0x0 },
4899 { "CD", 0x4 },
4900 { "Headphone", 0x2 },
4901 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004902 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004903 {
4904 .num_items = 4,
4905 .items = {
4906 { "Mic/Line", 0x0 },
4907 { "CD", 0x4 },
4908 { "Headphone", 0x2 },
4909 { "Mixer", 0x5 },
4910 },
4911 },
4912
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004913};
4914
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004915/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4916 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004917 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004918static struct hda_input_mux alc260_acer_capture_sources[2] = {
4919 {
4920 .num_items = 4,
4921 .items = {
4922 { "Mic", 0x0 },
4923 { "Line", 0x2 },
4924 { "CD", 0x4 },
4925 { "Headphone", 0x5 },
4926 },
4927 },
4928 {
4929 .num_items = 5,
4930 .items = {
4931 { "Mic", 0x0 },
4932 { "Line", 0x2 },
4933 { "CD", 0x4 },
4934 { "Headphone", 0x6 },
4935 { "Mixer", 0x5 },
4936 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004937 },
4938};
Michael Schwingencc959482009-02-22 18:58:45 +01004939
4940/* Maxdata Favorit 100XS */
4941static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4942 {
4943 .num_items = 2,
4944 .items = {
4945 { "Line/Mic", 0x0 },
4946 { "CD", 0x4 },
4947 },
4948 },
4949 {
4950 .num_items = 3,
4951 .items = {
4952 { "Line/Mic", 0x0 },
4953 { "CD", 0x4 },
4954 { "Mixer", 0x5 },
4955 },
4956 },
4957};
4958
Linus Torvalds1da177e2005-04-16 15:20:36 -07004959/*
4960 * This is just place-holder, so there's something for alc_build_pcms to look
4961 * at when it calculates the maximum number of channels. ALC260 has no mixer
4962 * element which allows changing the channel mode, so the verb list is
4963 * never used.
4964 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004965static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004966 { 2, NULL },
4967};
4968
Kailang Yangdf694da2005-12-05 19:42:22 +01004969
4970/* Mixer combinations
4971 *
4972 * basic: base_output + input + pc_beep + capture
4973 * HP: base_output + input + capture_alt
4974 * HP_3013: hp_3013 + input + capture
4975 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004976 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004977 */
4978
4979static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004980 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004981 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004982 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4983 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4984 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4985 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4986 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004987};
Kailang Yangdf694da2005-12-05 19:42:22 +01004988
4989static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004990 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4991 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4992 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4993 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4995 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4996 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004998 { } /* end */
4999};
5000
Takashi Iwaibec15c32008-01-28 18:16:30 +01005001/* update HP, line and mono out pins according to the master switch */
5002static void alc260_hp_master_update(struct hda_codec *codec,
5003 hda_nid_t hp, hda_nid_t line,
5004 hda_nid_t mono)
5005{
5006 struct alc_spec *spec = codec->spec;
5007 unsigned int val = spec->master_sw ? PIN_HP : 0;
5008 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005009 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005010 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005011 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005012 val);
5013 /* mono (speaker) depending on the HP jack sense */
5014 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005015 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005016 val);
5017}
5018
5019static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5020 struct snd_ctl_elem_value *ucontrol)
5021{
5022 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5023 struct alc_spec *spec = codec->spec;
5024 *ucontrol->value.integer.value = spec->master_sw;
5025 return 0;
5026}
5027
5028static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5029 struct snd_ctl_elem_value *ucontrol)
5030{
5031 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5032 struct alc_spec *spec = codec->spec;
5033 int val = !!*ucontrol->value.integer.value;
5034 hda_nid_t hp, line, mono;
5035
5036 if (val == spec->master_sw)
5037 return 0;
5038 spec->master_sw = val;
5039 hp = (kcontrol->private_value >> 16) & 0xff;
5040 line = (kcontrol->private_value >> 8) & 0xff;
5041 mono = kcontrol->private_value & 0xff;
5042 alc260_hp_master_update(codec, hp, line, mono);
5043 return 1;
5044}
5045
5046static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5047 {
5048 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5049 .name = "Master Playback Switch",
5050 .info = snd_ctl_boolean_mono_info,
5051 .get = alc260_hp_master_sw_get,
5052 .put = alc260_hp_master_sw_put,
5053 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5054 },
5055 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5056 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5057 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5058 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5059 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5060 HDA_OUTPUT),
5061 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5062 { } /* end */
5063};
5064
5065static struct hda_verb alc260_hp_unsol_verbs[] = {
5066 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5067 {},
5068};
5069
5070static void alc260_hp_automute(struct hda_codec *codec)
5071{
5072 struct alc_spec *spec = codec->spec;
5073 unsigned int present;
5074
5075 present = snd_hda_codec_read(codec, 0x10, 0,
5076 AC_VERB_GET_PIN_SENSE, 0);
5077 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5078 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5079}
5080
5081static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5082{
5083 if ((res >> 26) == ALC880_HP_EVENT)
5084 alc260_hp_automute(codec);
5085}
5086
Kailang Yangdf694da2005-12-05 19:42:22 +01005087static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005088 {
5089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5090 .name = "Master Playback Switch",
5091 .info = snd_ctl_boolean_mono_info,
5092 .get = alc260_hp_master_sw_get,
5093 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005094 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005095 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005096 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5097 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5098 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5099 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5100 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005102 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5103 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005104 { } /* end */
5105};
5106
Kailang Yang3f878302008-08-26 13:02:23 +02005107static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5108 .ops = &snd_hda_bind_vol,
5109 .values = {
5110 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5111 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5112 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5113 0
5114 },
5115};
5116
5117static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5118 .ops = &snd_hda_bind_sw,
5119 .values = {
5120 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5121 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5122 0
5123 },
5124};
5125
5126static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5127 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5128 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5129 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5131 { } /* end */
5132};
5133
Takashi Iwaibec15c32008-01-28 18:16:30 +01005134static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5136 {},
5137};
5138
5139static void alc260_hp_3013_automute(struct hda_codec *codec)
5140{
5141 struct alc_spec *spec = codec->spec;
5142 unsigned int present;
5143
5144 present = snd_hda_codec_read(codec, 0x15, 0,
5145 AC_VERB_GET_PIN_SENSE, 0);
5146 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005147 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005148}
5149
5150static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5151 unsigned int res)
5152{
5153 if ((res >> 26) == ALC880_HP_EVENT)
5154 alc260_hp_3013_automute(codec);
5155}
5156
Kailang Yang3f878302008-08-26 13:02:23 +02005157static void alc260_hp_3012_automute(struct hda_codec *codec)
5158{
5159 unsigned int present, bits;
5160
5161 present = snd_hda_codec_read(codec, 0x10, 0,
5162 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5163
5164 bits = present ? 0 : PIN_OUT;
5165 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5166 bits);
5167 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5168 bits);
5169 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5170 bits);
5171}
5172
5173static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5174 unsigned int res)
5175{
5176 if ((res >> 26) == ALC880_HP_EVENT)
5177 alc260_hp_3012_automute(codec);
5178}
5179
5180/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005181 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5182 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01005183static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005184 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005185 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005186 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005187 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5188 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5189 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5190 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005191 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005192 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5193 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005194 { } /* end */
5195};
5196
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005197/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5198 * versions of the ALC260 don't act on requests to enable mic bias from NID
5199 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5200 * datasheet doesn't mention this restriction. At this stage it's not clear
5201 * whether this behaviour is intentional or is a hardware bug in chip
5202 * revisions available in early 2006. Therefore for now allow the
5203 * "Headphone Jack Mode" control to span all choices, but if it turns out
5204 * that the lack of mic bias for this NID is intentional we could change the
5205 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5206 *
5207 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5208 * don't appear to make the mic bias available from the "line" jack, even
5209 * though the NID used for this jack (0x14) can supply it. The theory is
5210 * that perhaps Acer have included blocking capacitors between the ALC260
5211 * and the output jack. If this turns out to be the case for all such
5212 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5213 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005214 *
5215 * The C20x Tablet series have a mono internal speaker which is controlled
5216 * via the chip's Mono sum widget and pin complex, so include the necessary
5217 * controls for such models. On models without a "mono speaker" the control
5218 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005219 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005220static struct snd_kcontrol_new alc260_acer_mixer[] = {
5221 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5222 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005223 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005224 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005225 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005226 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005227 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005228 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5229 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5231 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5232 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5233 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5234 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5235 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005236 { } /* end */
5237};
5238
Michael Schwingencc959482009-02-22 18:58:45 +01005239/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5240 */
5241static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5242 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5243 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5244 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5245 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5246 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5247 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5248 { } /* end */
5249};
5250
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005251/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5252 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5253 */
5254static struct snd_kcontrol_new alc260_will_mixer[] = {
5255 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5256 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5258 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5259 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5260 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5261 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5262 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5263 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5264 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005265 { } /* end */
5266};
5267
5268/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5269 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5270 */
5271static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5272 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5273 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5275 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5276 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5277 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5278 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5279 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5280 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5281 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5282 { } /* end */
5283};
5284
Kailang Yangdf694da2005-12-05 19:42:22 +01005285/*
5286 * initialization verbs
5287 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005288static struct hda_verb alc260_init_verbs[] = {
5289 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005290 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005291 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005293 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005294 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005295 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005296 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005297 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005298 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005299 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005300 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005301 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005302 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005303 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005304 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005305 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005306 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5307 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005308 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005309 /* set connection select to line in (default select for this ADC) */
5310 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005311 /* mute capture amp left and right */
5312 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5313 /* set connection select to line in (default select for this ADC) */
5314 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005315 /* set vol=0 Line-Out mixer amp left and right */
5316 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5317 /* unmute pin widget amp left and right (no gain on this amp) */
5318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5319 /* set vol=0 HP mixer amp left and right */
5320 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5321 /* unmute pin widget amp left and right (no gain on this amp) */
5322 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5323 /* set vol=0 Mono mixer amp left and right */
5324 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5325 /* unmute pin widget amp left and right (no gain on this amp) */
5326 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5327 /* unmute LINE-2 out pin */
5328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005329 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5330 * Line In 2 = 0x03
5331 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005332 /* mute analog inputs */
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005338 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005339 /* mute Front out path */
5340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5342 /* mute Headphone out path */
5343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5344 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5345 /* mute Mono out path */
5346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5347 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005348 { }
5349};
5350
Takashi Iwai474167d2006-05-17 17:17:43 +02005351#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005352static struct hda_verb alc260_hp_init_verbs[] = {
5353 /* Headphone and output */
5354 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5355 /* mono output */
5356 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5357 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5358 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5359 /* Mic2 (front panel) pin widget for input and vref at 80% */
5360 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5361 /* Line In pin widget for input */
5362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5363 /* Line-2 pin widget for output */
5364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5365 /* CD pin widget for input */
5366 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5367 /* unmute amp left and right */
5368 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5369 /* set connection select to line in (default select for this ADC) */
5370 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5371 /* unmute Line-Out mixer amp left and right (volume = 0) */
5372 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5373 /* mute pin widget amp left and right (no gain on this amp) */
5374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5375 /* unmute HP mixer amp left and right (volume = 0) */
5376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5377 /* mute pin widget amp left and right (no gain on this amp) */
5378 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005379 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5380 * Line In 2 = 0x03
5381 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005382 /* mute analog inputs */
5383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005388 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5389 /* Unmute Front out path */
5390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5391 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5392 /* Unmute Headphone out path */
5393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5394 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5395 /* Unmute Mono out path */
5396 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5397 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5398 { }
5399};
Takashi Iwai474167d2006-05-17 17:17:43 +02005400#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005401
5402static struct hda_verb alc260_hp_3013_init_verbs[] = {
5403 /* Line out and output */
5404 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5405 /* mono output */
5406 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5407 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5408 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5409 /* Mic2 (front panel) pin widget for input and vref at 80% */
5410 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5411 /* Line In pin widget for input */
5412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5413 /* Headphone pin widget for output */
5414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5415 /* CD pin widget for input */
5416 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5417 /* unmute amp left and right */
5418 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5419 /* set connection select to line in (default select for this ADC) */
5420 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5421 /* unmute Line-Out mixer amp left and right (volume = 0) */
5422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5423 /* mute pin widget amp left and right (no gain on this amp) */
5424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5425 /* unmute HP mixer amp left and right (volume = 0) */
5426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5427 /* mute pin widget amp left and right (no gain on this amp) */
5428 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005429 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5430 * Line In 2 = 0x03
5431 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005432 /* mute analog inputs */
5433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5437 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005438 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5439 /* Unmute Front out path */
5440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5442 /* Unmute Headphone out path */
5443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5445 /* Unmute Mono out path */
5446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5447 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5448 { }
5449};
5450
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005451/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005452 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5453 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005454 */
5455static struct hda_verb alc260_fujitsu_init_verbs[] = {
5456 /* Disable all GPIOs */
5457 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5458 /* Internal speaker is connected to headphone pin */
5459 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5460 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005462 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5464 /* Ensure all other unused pins are disabled and muted. */
5465 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5466 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005467 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005468 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005469 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005470 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005473
Jonathan Woithef7ace402006-02-28 11:46:14 +01005474 /* Disable digital (SPDIF) pins */
5475 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5476 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005477
Kailang Yangea1fb292008-08-26 12:58:38 +02005478 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005479 * when acting as an output.
5480 */
5481 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5482
5483 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005493
Jonathan Woithef7ace402006-02-28 11:46:14 +01005494 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5495 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5496 /* Unmute Line1 pin widget output buffer since it starts as an output.
5497 * If the pin mode is changed by the user the pin mode control will
5498 * take care of enabling the pin's input/output buffers as needed.
5499 * Therefore there's no need to enable the input buffer at this
5500 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005501 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005503 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005504 * mixer ctrl)
5505 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005506 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005507
Jonathan Woithef7ace402006-02-28 11:46:14 +01005508 /* Mute capture amp left and right */
5509 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005510 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005511 * in (on mic1 pin)
5512 */
5513 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005514
Jonathan Woithef7ace402006-02-28 11:46:14 +01005515 /* Do the same for the second ADC: mute capture input amp and
5516 * set ADC connection to line in (on mic1 pin)
5517 */
5518 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5519 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005520
Jonathan Woithef7ace402006-02-28 11:46:14 +01005521 /* Mute all inputs to mixer widget (even unconnected ones) */
5522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005530
5531 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005532};
5533
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005534/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5535 * similar laptops (adapted from Fujitsu init verbs).
5536 */
5537static struct hda_verb alc260_acer_init_verbs[] = {
5538 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5539 * the headphone jack. Turn this on and rely on the standard mute
5540 * methods whenever the user wants to turn these outputs off.
5541 */
5542 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5543 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5544 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5545 /* Internal speaker/Headphone jack is connected to Line-out pin */
5546 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5547 /* Internal microphone/Mic jack is connected to Mic1 pin */
5548 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5549 /* Line In jack is connected to Line1 pin */
5550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005551 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5552 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005553 /* Ensure all other unused pins are disabled and muted. */
5554 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5555 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005556 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5557 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5560 /* Disable digital (SPDIF) pins */
5561 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5562 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5563
Kailang Yangea1fb292008-08-26 12:58:38 +02005564 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005565 * bus when acting as outputs.
5566 */
5567 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5568 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5569
5570 /* Start with output sum widgets muted and their output gains at min */
5571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5573 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5576 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5578 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5579 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5580
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005581 /* Unmute Line-out pin widget amp left and right
5582 * (no equiv mixer ctrl)
5583 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005584 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005585 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5586 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005587 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5588 * inputs. If the pin mode is changed by the user the pin mode control
5589 * will take care of enabling the pin's input/output buffers as needed.
5590 * Therefore there's no need to enable the input buffer at this
5591 * stage.
5592 */
5593 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5594 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5595
5596 /* Mute capture amp left and right */
5597 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5598 /* Set ADC connection select to match default mixer setting - mic
5599 * (on mic1 pin)
5600 */
5601 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5602
5603 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005604 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005605 */
5606 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005607 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005608
5609 /* Mute all inputs to mixer widget (even unconnected ones) */
5610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5618
5619 { }
5620};
5621
Michael Schwingencc959482009-02-22 18:58:45 +01005622/* Initialisation sequence for Maxdata Favorit 100XS
5623 * (adapted from Acer init verbs).
5624 */
5625static struct hda_verb alc260_favorit100_init_verbs[] = {
5626 /* GPIO 0 enables the output jack.
5627 * Turn this on and rely on the standard mute
5628 * methods whenever the user wants to turn these outputs off.
5629 */
5630 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5631 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5632 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5633 /* Line/Mic input jack is connected to Mic1 pin */
5634 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5635 /* Ensure all other unused pins are disabled and muted. */
5636 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5637 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5638 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5639 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5640 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5641 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5646 /* Disable digital (SPDIF) pins */
5647 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5648 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5649
5650 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5651 * bus when acting as outputs.
5652 */
5653 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5654 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5655
5656 /* Start with output sum widgets muted and their output gains at min */
5657 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5659 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5660 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5663 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5664 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5665 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5666
5667 /* Unmute Line-out pin widget amp left and right
5668 * (no equiv mixer ctrl)
5669 */
5670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5671 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5672 * inputs. If the pin mode is changed by the user the pin mode control
5673 * will take care of enabling the pin's input/output buffers as needed.
5674 * Therefore there's no need to enable the input buffer at this
5675 * stage.
5676 */
5677 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5678
5679 /* Mute capture amp left and right */
5680 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5681 /* Set ADC connection select to match default mixer setting - mic
5682 * (on mic1 pin)
5683 */
5684 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5685
5686 /* Do similar with the second ADC: mute capture input amp and
5687 * set ADC connection to mic to match ALSA's default state.
5688 */
5689 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5690 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5691
5692 /* Mute all inputs to mixer widget (even unconnected ones) */
5693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5701
5702 { }
5703};
5704
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005705static struct hda_verb alc260_will_verbs[] = {
5706 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5707 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5708 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5709 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5710 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5711 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5712 {}
5713};
5714
5715static struct hda_verb alc260_replacer_672v_verbs[] = {
5716 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5717 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5718 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5719
5720 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5721 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5722 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5723
5724 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5725 {}
5726};
5727
5728/* toggle speaker-output according to the hp-jack state */
5729static void alc260_replacer_672v_automute(struct hda_codec *codec)
5730{
5731 unsigned int present;
5732
5733 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5734 present = snd_hda_codec_read(codec, 0x0f, 0,
5735 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5736 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005737 snd_hda_codec_write_cache(codec, 0x01, 0,
5738 AC_VERB_SET_GPIO_DATA, 1);
5739 snd_hda_codec_write_cache(codec, 0x0f, 0,
5740 AC_VERB_SET_PIN_WIDGET_CONTROL,
5741 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005742 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005743 snd_hda_codec_write_cache(codec, 0x01, 0,
5744 AC_VERB_SET_GPIO_DATA, 0);
5745 snd_hda_codec_write_cache(codec, 0x0f, 0,
5746 AC_VERB_SET_PIN_WIDGET_CONTROL,
5747 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005748 }
5749}
5750
5751static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5752 unsigned int res)
5753{
5754 if ((res >> 26) == ALC880_HP_EVENT)
5755 alc260_replacer_672v_automute(codec);
5756}
5757
Kailang Yang3f878302008-08-26 13:02:23 +02005758static struct hda_verb alc260_hp_dc7600_verbs[] = {
5759 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5760 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5761 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5762 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5763 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5765 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5766 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5767 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5768 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5769 {}
5770};
5771
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005772/* Test configuration for debugging, modelled after the ALC880 test
5773 * configuration.
5774 */
5775#ifdef CONFIG_SND_DEBUG
5776static hda_nid_t alc260_test_dac_nids[1] = {
5777 0x02,
5778};
5779static hda_nid_t alc260_test_adc_nids[2] = {
5780 0x04, 0x05,
5781};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005782/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005783 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005784 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005785 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005786static struct hda_input_mux alc260_test_capture_sources[2] = {
5787 {
5788 .num_items = 7,
5789 .items = {
5790 { "MIC1 pin", 0x0 },
5791 { "MIC2 pin", 0x1 },
5792 { "LINE1 pin", 0x2 },
5793 { "LINE2 pin", 0x3 },
5794 { "CD pin", 0x4 },
5795 { "LINE-OUT pin", 0x5 },
5796 { "HP-OUT pin", 0x6 },
5797 },
5798 },
5799 {
5800 .num_items = 8,
5801 .items = {
5802 { "MIC1 pin", 0x0 },
5803 { "MIC2 pin", 0x1 },
5804 { "LINE1 pin", 0x2 },
5805 { "LINE2 pin", 0x3 },
5806 { "CD pin", 0x4 },
5807 { "Mixer", 0x5 },
5808 { "LINE-OUT pin", 0x6 },
5809 { "HP-OUT pin", 0x7 },
5810 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005811 },
5812};
5813static struct snd_kcontrol_new alc260_test_mixer[] = {
5814 /* Output driver widgets */
5815 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5816 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5817 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5818 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5819 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5820 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5821
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005822 /* Modes for retasking pin widgets
5823 * Note: the ALC260 doesn't seem to act on requests to enable mic
5824 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5825 * mention this restriction. At this stage it's not clear whether
5826 * this behaviour is intentional or is a hardware bug in chip
5827 * revisions available at least up until early 2006. Therefore for
5828 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5829 * choices, but if it turns out that the lack of mic bias for these
5830 * NIDs is intentional we could change their modes from
5831 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5832 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005833 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5834 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5835 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5836 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5837 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5838 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5839
5840 /* Loopback mixer controls */
5841 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5842 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5843 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5844 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5845 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5846 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5847 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5848 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5849 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5850 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005851 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5852 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5853 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5854 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005855
5856 /* Controls for GPIO pins, assuming they are configured as outputs */
5857 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5858 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5859 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5860 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5861
Jonathan Woithe92621f12006-02-28 11:47:47 +01005862 /* Switches to allow the digital IO pins to be enabled. The datasheet
5863 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005864 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005865 */
5866 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5867 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5868
Jonathan Woithef8225f62008-01-08 12:16:54 +01005869 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5870 * this output to turn on an external amplifier.
5871 */
5872 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5873 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5874
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005875 { } /* end */
5876};
5877static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005878 /* Enable all GPIOs as outputs with an initial value of 0 */
5879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5880 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5881 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5882
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005883 /* Enable retasking pins as output, initially without power amp */
5884 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5885 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5886 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5888 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5889 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5890
Jonathan Woithe92621f12006-02-28 11:47:47 +01005891 /* Disable digital (SPDIF) pins initially, but users can enable
5892 * them via a mixer switch. In the case of SPDIF-out, this initverb
5893 * payload also sets the generation to 0, output to be in "consumer"
5894 * PCM format, copyright asserted, no pre-emphasis and no validity
5895 * control.
5896 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005897 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5898 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5899
Kailang Yangea1fb292008-08-26 12:58:38 +02005900 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005901 * OUT1 sum bus when acting as an output.
5902 */
5903 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5904 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5905 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5906 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5907
5908 /* Start with output sum widgets muted and their output gains at min */
5909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5910 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5911 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5914 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5915 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5916 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5917 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5918
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005919 /* Unmute retasking pin widget output buffers since the default
5920 * state appears to be output. As the pin mode is changed by the
5921 * user the pin mode control will take care of enabling the pin's
5922 * input/output buffers as needed.
5923 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005924 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5928 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5929 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5930 /* Also unmute the mono-out pin widget */
5931 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5932
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005933 /* Mute capture amp left and right */
5934 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005935 /* Set ADC connection select to match default mixer setting (mic1
5936 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005937 */
5938 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5939
5940 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005941 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005942 */
5943 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5944 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5945
5946 /* Mute all inputs to mixer widget (even unconnected ones) */
5947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5949 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5950 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5951 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5955
5956 { }
5957};
5958#endif
5959
Takashi Iwai63300792008-01-24 15:31:36 +01005960#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5961#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005962
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005963#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5964#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5965
Kailang Yangdf694da2005-12-05 19:42:22 +01005966/*
5967 * for BIOS auto-configuration
5968 */
5969
5970static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005971 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005972{
5973 hda_nid_t nid_vol;
5974 unsigned long vol_val, sw_val;
5975 char name[32];
5976 int err;
5977
5978 if (nid >= 0x0f && nid < 0x11) {
5979 nid_vol = nid - 0x7;
5980 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5981 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5982 } else if (nid == 0x11) {
5983 nid_vol = nid - 0x7;
5984 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5985 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5986 } else if (nid >= 0x12 && nid <= 0x15) {
5987 nid_vol = 0x08;
5988 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5989 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5990 } else
5991 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005992
Takashi Iwai863b4512008-10-21 17:01:47 +02005993 if (!(*vol_bits & (1 << nid_vol))) {
5994 /* first control for the volume widget */
5995 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5996 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5997 if (err < 0)
5998 return err;
5999 *vol_bits |= (1 << nid_vol);
6000 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006001 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006002 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
6003 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006004 return err;
6005 return 1;
6006}
6007
6008/* add playback controls from the parsed DAC table */
6009static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6010 const struct auto_pin_cfg *cfg)
6011{
6012 hda_nid_t nid;
6013 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006014 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006015
6016 spec->multiout.num_dacs = 1;
6017 spec->multiout.dac_nids = spec->private_dac_nids;
6018 spec->multiout.dac_nids[0] = 0x02;
6019
6020 nid = cfg->line_out_pins[0];
6021 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006022 const char *pfx;
6023 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6024 pfx = "Master";
6025 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6026 pfx = "Speaker";
6027 else
6028 pfx = "Front";
6029 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006030 if (err < 0)
6031 return err;
6032 }
6033
Takashi Iwai82bc9552006-03-21 11:24:42 +01006034 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006035 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006036 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006037 if (err < 0)
6038 return err;
6039 }
6040
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006041 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006042 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006043 err = alc260_add_playback_controls(spec, nid, "Headphone",
6044 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006045 if (err < 0)
6046 return err;
6047 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006048 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006049}
6050
6051/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006052static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006053 const struct auto_pin_cfg *cfg)
6054{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006055 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006056}
6057
6058static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6059 hda_nid_t nid, int pin_type,
6060 int sel_idx)
6061{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006062 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 /* need the manual connection? */
6064 if (nid >= 0x12) {
6065 int idx = nid - 0x12;
6066 snd_hda_codec_write(codec, idx + 0x0b, 0,
6067 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006068 }
6069}
6070
6071static void alc260_auto_init_multi_out(struct hda_codec *codec)
6072{
6073 struct alc_spec *spec = codec->spec;
6074 hda_nid_t nid;
6075
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006076 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006077 if (nid) {
6078 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6079 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6080 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006081
Takashi Iwai82bc9552006-03-21 11:24:42 +01006082 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006083 if (nid)
6084 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6085
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006086 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006087 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006088 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006089}
Kailang Yangdf694da2005-12-05 19:42:22 +01006090
6091#define ALC260_PIN_CD_NID 0x16
6092static void alc260_auto_init_analog_input(struct hda_codec *codec)
6093{
6094 struct alc_spec *spec = codec->spec;
6095 int i;
6096
6097 for (i = 0; i < AUTO_PIN_LAST; i++) {
6098 hda_nid_t nid = spec->autocfg.input_pins[i];
6099 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006100 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006101 if (nid != ALC260_PIN_CD_NID &&
6102 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006103 snd_hda_codec_write(codec, nid, 0,
6104 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006105 AMP_OUT_MUTE);
6106 }
6107 }
6108}
6109
6110/*
6111 * generic initialization of ADC, input mixers and output mixers
6112 */
6113static struct hda_verb alc260_volume_init_verbs[] = {
6114 /*
6115 * Unmute ADC0-1 and set the default input to mic-in
6116 */
6117 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6118 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6119 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6120 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006121
Kailang Yangdf694da2005-12-05 19:42:22 +01006122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6123 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006124 * Note: PASD motherboards uses the Line In 2 as the input for
6125 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006126 */
6127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006128 /* mute analog inputs */
6129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006134
6135 /*
6136 * Set up output mixers (0x08 - 0x0a)
6137 */
6138 /* set vol=0 to output mixers */
6139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6140 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6141 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6142 /* set up input amps for analog loopback */
6143 /* Amp Indices: DAC = 0, mixer = 1 */
6144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6146 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6149 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006150
Kailang Yangdf694da2005-12-05 19:42:22 +01006151 { }
6152};
6153
6154static int alc260_parse_auto_config(struct hda_codec *codec)
6155{
6156 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006157 int err;
6158 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6159
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006160 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6161 alc260_ignore);
6162 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006163 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006164 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6165 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006166 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006167 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006168 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006169 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006170 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006171 return err;
6172
6173 spec->multiout.max_channels = 2;
6174
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006175 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006176 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006177 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006178 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006179
Takashi Iwaid88897e2008-10-31 15:01:37 +01006180 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006181
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006182 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006183 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006184
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006185 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6186
Kailang Yangdf694da2005-12-05 19:42:22 +01006187 return 1;
6188}
6189
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006190/* additional initialization for auto-configuration model */
6191static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006192{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006193 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006194 alc260_auto_init_multi_out(codec);
6195 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006196 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006197 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006198}
6199
Takashi Iwaicb53c622007-08-10 17:21:45 +02006200#ifdef CONFIG_SND_HDA_POWER_SAVE
6201static struct hda_amp_list alc260_loopbacks[] = {
6202 { 0x07, HDA_INPUT, 0 },
6203 { 0x07, HDA_INPUT, 1 },
6204 { 0x07, HDA_INPUT, 2 },
6205 { 0x07, HDA_INPUT, 3 },
6206 { 0x07, HDA_INPUT, 4 },
6207 { } /* end */
6208};
6209#endif
6210
Kailang Yangdf694da2005-12-05 19:42:22 +01006211/*
6212 * ALC260 configurations
6213 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006214static const char *alc260_models[ALC260_MODEL_LAST] = {
6215 [ALC260_BASIC] = "basic",
6216 [ALC260_HP] = "hp",
6217 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006218 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006219 [ALC260_FUJITSU_S702X] = "fujitsu",
6220 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006221 [ALC260_WILL] = "will",
6222 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006223 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006224#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006225 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006226#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006227 [ALC260_AUTO] = "auto",
6228};
6229
6230static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006231 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006232 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006233 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006234 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006235 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006236 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006237 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006238 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006239 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6240 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6241 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6242 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6243 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6244 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6245 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6246 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6247 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006248 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006249 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006250 {}
6251};
6252
Kailang Yangdf694da2005-12-05 19:42:22 +01006253static struct alc_config_preset alc260_presets[] = {
6254 [ALC260_BASIC] = {
6255 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006256 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006257 .init_verbs = { alc260_init_verbs },
6258 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6259 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006260 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006261 .adc_nids = alc260_adc_nids,
6262 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6263 .channel_mode = alc260_modes,
6264 .input_mux = &alc260_capture_source,
6265 },
6266 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006267 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006268 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006269 .init_verbs = { alc260_init_verbs,
6270 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006271 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6272 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006273 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6274 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006275 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6276 .channel_mode = alc260_modes,
6277 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006278 .unsol_event = alc260_hp_unsol_event,
6279 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006280 },
Kailang Yang3f878302008-08-26 13:02:23 +02006281 [ALC260_HP_DC7600] = {
6282 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006283 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006284 .init_verbs = { alc260_init_verbs,
6285 alc260_hp_dc7600_verbs },
6286 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6287 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006288 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6289 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006290 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6291 .channel_mode = alc260_modes,
6292 .input_mux = &alc260_capture_source,
6293 .unsol_event = alc260_hp_3012_unsol_event,
6294 .init_hook = alc260_hp_3012_automute,
6295 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006296 [ALC260_HP_3013] = {
6297 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006298 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006299 .init_verbs = { alc260_hp_3013_init_verbs,
6300 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006301 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6302 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006303 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6304 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006305 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6306 .channel_mode = alc260_modes,
6307 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006308 .unsol_event = alc260_hp_3013_unsol_event,
6309 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006310 },
6311 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006312 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 .init_verbs = { alc260_fujitsu_init_verbs },
6314 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6315 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006316 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6317 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6319 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006320 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6321 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006322 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006323 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006324 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006325 .init_verbs = { alc260_acer_init_verbs },
6326 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6327 .dac_nids = alc260_dac_nids,
6328 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6329 .adc_nids = alc260_dual_adc_nids,
6330 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6331 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006332 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6333 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006334 },
Michael Schwingencc959482009-02-22 18:58:45 +01006335 [ALC260_FAVORIT100] = {
6336 .mixers = { alc260_favorit100_mixer },
6337 .init_verbs = { alc260_favorit100_init_verbs },
6338 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6339 .dac_nids = alc260_dac_nids,
6340 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6341 .adc_nids = alc260_dual_adc_nids,
6342 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6343 .channel_mode = alc260_modes,
6344 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6345 .input_mux = alc260_favorit100_capture_sources,
6346 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006347 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006348 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006349 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6350 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6351 .dac_nids = alc260_dac_nids,
6352 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6353 .adc_nids = alc260_adc_nids,
6354 .dig_out_nid = ALC260_DIGOUT_NID,
6355 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6356 .channel_mode = alc260_modes,
6357 .input_mux = &alc260_capture_source,
6358 },
6359 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006360 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006361 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6362 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6363 .dac_nids = alc260_dac_nids,
6364 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6365 .adc_nids = alc260_adc_nids,
6366 .dig_out_nid = ALC260_DIGOUT_NID,
6367 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6368 .channel_mode = alc260_modes,
6369 .input_mux = &alc260_capture_source,
6370 .unsol_event = alc260_replacer_672v_unsol_event,
6371 .init_hook = alc260_replacer_672v_automute,
6372 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006373#ifdef CONFIG_SND_DEBUG
6374 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006375 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006376 .init_verbs = { alc260_test_init_verbs },
6377 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6378 .dac_nids = alc260_test_dac_nids,
6379 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6380 .adc_nids = alc260_test_adc_nids,
6381 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6382 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006383 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6384 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006385 },
6386#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006387};
6388
Linus Torvalds1da177e2005-04-16 15:20:36 -07006389static int patch_alc260(struct hda_codec *codec)
6390{
6391 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006392 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006393
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006394 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006395 if (spec == NULL)
6396 return -ENOMEM;
6397
6398 codec->spec = spec;
6399
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006400 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6401 alc260_models,
6402 alc260_cfg_tbl);
6403 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006404 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006405 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006406 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006407 }
6408
Kailang Yangdf694da2005-12-05 19:42:22 +01006409 if (board_config == ALC260_AUTO) {
6410 /* automatic parse from the BIOS config */
6411 err = alc260_parse_auto_config(codec);
6412 if (err < 0) {
6413 alc_free(codec);
6414 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006415 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006416 printk(KERN_INFO
6417 "hda_codec: Cannot set up configuration "
6418 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006419 board_config = ALC260_BASIC;
6420 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006421 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006422
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006423 err = snd_hda_attach_beep_device(codec, 0x1);
6424 if (err < 0) {
6425 alc_free(codec);
6426 return err;
6427 }
6428
Kailang Yangdf694da2005-12-05 19:42:22 +01006429 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006430 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006431
Linus Torvalds1da177e2005-04-16 15:20:36 -07006432 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6433 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6434
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006435 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6436 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6437
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006438 if (!spec->adc_nids && spec->input_mux) {
6439 /* check whether NID 0x04 is valid */
6440 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006441 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006442 /* get type */
6443 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6444 spec->adc_nids = alc260_adc_nids_alt;
6445 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6446 } else {
6447 spec->adc_nids = alc260_adc_nids;
6448 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6449 }
6450 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006451 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006452 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006453
Takashi Iwai2134ea42008-01-10 16:53:55 +01006454 spec->vmaster_nid = 0x08;
6455
Linus Torvalds1da177e2005-04-16 15:20:36 -07006456 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006457 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006458 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006459#ifdef CONFIG_SND_HDA_POWER_SAVE
6460 if (!spec->loopback.amplist)
6461 spec->loopback.amplist = alc260_loopbacks;
6462#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006463 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006464
6465 return 0;
6466}
6467
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006468
Linus Torvalds1da177e2005-04-16 15:20:36 -07006469/*
Takashi Iwai49535502009-06-30 15:28:30 +02006470 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006471 *
6472 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6473 * configuration. Each pin widget can choose any input DACs and a mixer.
6474 * Each ADC is connected from a mixer of all inputs. This makes possible
6475 * 6-channel independent captures.
6476 *
6477 * In addition, an independent DAC for the multi-playback (not used in this
6478 * driver yet).
6479 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006480#define ALC882_DIGOUT_NID 0x06
6481#define ALC882_DIGIN_NID 0x0a
Takashi Iwai49535502009-06-30 15:28:30 +02006482#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6483#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6484#define ALC1200_DIGOUT_NID 0x10
6485
Linus Torvalds1da177e2005-04-16 15:20:36 -07006486
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006487static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006488 { 8, NULL }
6489};
6490
Takashi Iwai49535502009-06-30 15:28:30 +02006491/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006492static hda_nid_t alc882_dac_nids[4] = {
6493 /* front, rear, clfe, rear_surr */
6494 0x02, 0x03, 0x04, 0x05
6495};
Takashi Iwai49535502009-06-30 15:28:30 +02006496#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006497
Takashi Iwai49535502009-06-30 15:28:30 +02006498/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006499#define alc882_adc_nids alc880_adc_nids
6500#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai49535502009-06-30 15:28:30 +02006501#define alc883_adc_nids alc882_adc_nids_alt
6502static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6503static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6504#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006505
Takashi Iwaie1406342008-02-11 18:32:32 +01006506static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6507static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai49535502009-06-30 15:28:30 +02006508#define alc883_capsrc_nids alc882_capsrc_nids_alt
6509static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6510#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006511
Linus Torvalds1da177e2005-04-16 15:20:36 -07006512/* input MUX */
6513/* FIXME: should be a matrix-type input source selection */
6514
6515static struct hda_input_mux alc882_capture_source = {
6516 .num_items = 4,
6517 .items = {
6518 { "Mic", 0x0 },
6519 { "Front Mic", 0x1 },
6520 { "Line", 0x2 },
6521 { "CD", 0x4 },
6522 },
6523};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006524
Takashi Iwai49535502009-06-30 15:28:30 +02006525#define alc883_capture_source alc882_capture_source
6526
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006527static struct hda_input_mux alc889_capture_source = {
6528 .num_items = 3,
6529 .items = {
6530 { "Front Mic", 0x0 },
6531 { "Mic", 0x3 },
6532 { "Line", 0x2 },
6533 },
6534};
6535
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006536static struct hda_input_mux mb5_capture_source = {
6537 .num_items = 3,
6538 .items = {
6539 { "Mic", 0x1 },
6540 { "Line", 0x2 },
6541 { "CD", 0x4 },
6542 },
6543};
6544
Takashi Iwai49535502009-06-30 15:28:30 +02006545static struct hda_input_mux alc883_3stack_6ch_intel = {
6546 .num_items = 4,
6547 .items = {
6548 { "Mic", 0x1 },
6549 { "Front Mic", 0x0 },
6550 { "Line", 0x2 },
6551 { "CD", 0x4 },
6552 },
6553};
6554
6555static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6556 .num_items = 2,
6557 .items = {
6558 { "Mic", 0x1 },
6559 { "Line", 0x2 },
6560 },
6561};
6562
6563static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6564 .num_items = 4,
6565 .items = {
6566 { "Mic", 0x0 },
6567 { "iMic", 0x1 },
6568 { "Line", 0x2 },
6569 { "CD", 0x4 },
6570 },
6571};
6572
6573static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6574 .num_items = 2,
6575 .items = {
6576 { "Mic", 0x0 },
6577 { "Int Mic", 0x1 },
6578 },
6579};
6580
6581static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6582 .num_items = 3,
6583 .items = {
6584 { "Mic", 0x0 },
6585 { "Front Mic", 0x1 },
6586 { "Line", 0x4 },
6587 },
6588};
6589
6590static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6591 .num_items = 2,
6592 .items = {
6593 { "Mic", 0x0 },
6594 { "Line", 0x2 },
6595 },
6596};
6597
6598static struct hda_input_mux alc889A_mb31_capture_source = {
6599 .num_items = 2,
6600 .items = {
6601 { "Mic", 0x0 },
6602 /* Front Mic (0x01) unused */
6603 { "Line", 0x2 },
6604 /* Line 2 (0x03) unused */
6605 /* CD (0x04) unsused? */
6606 },
6607};
6608
6609/*
6610 * 2ch mode
6611 */
6612static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6613 { 2, NULL }
6614};
6615
Kailang Yangdf694da2005-12-05 19:42:22 +01006616/*
Kailang Yang272a5272007-05-14 11:00:38 +02006617 * 2ch mode
6618 */
6619static struct hda_verb alc882_3ST_ch2_init[] = {
6620 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6621 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6622 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6623 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6624 { } /* end */
6625};
6626
6627/*
Takashi Iwai49535502009-06-30 15:28:30 +02006628 * 4ch mode
6629 */
6630static struct hda_verb alc882_3ST_ch4_init[] = {
6631 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6632 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6635 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6636 { } /* end */
6637};
6638
6639/*
Kailang Yang272a5272007-05-14 11:00:38 +02006640 * 6ch mode
6641 */
6642static struct hda_verb alc882_3ST_ch6_init[] = {
6643 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6644 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6645 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6648 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6649 { } /* end */
6650};
6651
Takashi Iwai49535502009-06-30 15:28:30 +02006652static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006653 { 2, alc882_3ST_ch2_init },
Takashi Iwai49535502009-06-30 15:28:30 +02006654 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006655 { 6, alc882_3ST_ch6_init },
6656};
6657
Takashi Iwai49535502009-06-30 15:28:30 +02006658#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6659
Kailang Yang272a5272007-05-14 11:00:38 +02006660/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306661 * 2ch mode
6662 */
6663static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6664 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6665 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6666 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6667 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6668 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6669 { } /* end */
6670};
6671
6672/*
6673 * 4ch mode
6674 */
6675static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6676 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6677 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6678 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6679 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6680 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6681 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6682 { } /* end */
6683};
6684
6685/*
6686 * 6ch mode
6687 */
6688static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6689 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6690 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6691 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6692 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6693 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6694 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6695 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6696 { } /* end */
6697};
6698
6699static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6700 { 2, alc883_3ST_ch2_clevo_init },
6701 { 4, alc883_3ST_ch4_clevo_init },
6702 { 6, alc883_3ST_ch6_clevo_init },
6703};
6704
6705
6706/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006707 * 6ch mode
6708 */
6709static struct hda_verb alc882_sixstack_ch6_init[] = {
6710 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6711 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6712 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6713 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6714 { } /* end */
6715};
6716
6717/*
6718 * 8ch mode
6719 */
6720static struct hda_verb alc882_sixstack_ch8_init[] = {
6721 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6722 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6723 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6724 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6725 { } /* end */
6726};
6727
6728static struct hda_channel_mode alc882_sixstack_modes[2] = {
6729 { 6, alc882_sixstack_ch6_init },
6730 { 8, alc882_sixstack_ch8_init },
6731};
6732
Takashi Iwai87350ad2007-08-16 18:19:38 +02006733/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006734 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006735 */
6736
6737/*
6738 * 2ch mode
6739 */
6740static struct hda_verb alc885_mbp_ch2_init[] = {
6741 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6742 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6743 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6744 { } /* end */
6745};
6746
6747/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006748 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006749 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006750static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6753 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6754 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6755 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6756 { } /* end */
6757};
6758
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006759static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006760 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006761 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006762};
6763
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006764/*
6765 * 2ch
6766 * Speakers/Woofer/HP = Front
6767 * LineIn = Input
6768 */
6769static struct hda_verb alc885_mb5_ch2_init[] = {
6770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6772 { } /* end */
6773};
6774
6775/*
6776 * 6ch mode
6777 * Speakers/HP = Front
6778 * Woofer = LFE
6779 * LineIn = Surround
6780 */
6781static struct hda_verb alc885_mb5_ch6_init[] = {
6782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6785 { } /* end */
6786};
6787
6788static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6789 { 2, alc885_mb5_ch2_init },
6790 { 6, alc885_mb5_ch6_init },
6791};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006792
Takashi Iwai49535502009-06-30 15:28:30 +02006793
6794/*
6795 * 2ch mode
6796 */
6797static struct hda_verb alc883_4ST_ch2_init[] = {
6798 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6799 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6800 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6801 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6804 { } /* end */
6805};
6806
6807/*
6808 * 4ch mode
6809 */
6810static struct hda_verb alc883_4ST_ch4_init[] = {
6811 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6812 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6815 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6818 { } /* end */
6819};
6820
6821/*
6822 * 6ch mode
6823 */
6824static struct hda_verb alc883_4ST_ch6_init[] = {
6825 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6826 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6827 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6828 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6829 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6830 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6831 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6832 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6833 { } /* end */
6834};
6835
6836/*
6837 * 8ch mode
6838 */
6839static struct hda_verb alc883_4ST_ch8_init[] = {
6840 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6841 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6842 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6843 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6844 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6845 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6846 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6847 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6848 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6849 { } /* end */
6850};
6851
6852static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6853 { 2, alc883_4ST_ch2_init },
6854 { 4, alc883_4ST_ch4_init },
6855 { 6, alc883_4ST_ch6_init },
6856 { 8, alc883_4ST_ch8_init },
6857};
6858
6859
6860/*
6861 * 2ch mode
6862 */
6863static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6864 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6865 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6868 { } /* end */
6869};
6870
6871/*
6872 * 4ch mode
6873 */
6874static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6875 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6876 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6877 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6878 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6879 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6880 { } /* end */
6881};
6882
6883/*
6884 * 6ch mode
6885 */
6886static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6887 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6888 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6889 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6890 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6891 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6892 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6893 { } /* end */
6894};
6895
6896static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6897 { 2, alc883_3ST_ch2_intel_init },
6898 { 4, alc883_3ST_ch4_intel_init },
6899 { 6, alc883_3ST_ch6_intel_init },
6900};
6901
6902/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006903 * 2ch mode
6904 */
6905static struct hda_verb alc889_ch2_intel_init[] = {
6906 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6907 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6908 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6909 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6910 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6911 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6912 { } /* end */
6913};
6914
6915/*
Takashi Iwai49535502009-06-30 15:28:30 +02006916 * 6ch mode
6917 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006918static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006919 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6920 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6921 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6922 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6925 { } /* end */
6926};
6927
6928/*
6929 * 8ch mode
6930 */
6931static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006932 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6933 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6934 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6935 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6936 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006937 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6938 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006939 { } /* end */
6940};
6941
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006942static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6943 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006944 { 6, alc889_ch6_intel_init },
6945 { 8, alc889_ch8_intel_init },
6946};
6947
6948/*
6949 * 6ch mode
6950 */
Takashi Iwai49535502009-06-30 15:28:30 +02006951static struct hda_verb alc883_sixstack_ch6_init[] = {
6952 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6953 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6954 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6955 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6956 { } /* end */
6957};
6958
6959/*
6960 * 8ch mode
6961 */
6962static struct hda_verb alc883_sixstack_ch8_init[] = {
6963 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6964 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6965 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6966 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6967 { } /* end */
6968};
6969
6970static struct hda_channel_mode alc883_sixstack_modes[2] = {
6971 { 6, alc883_sixstack_ch6_init },
6972 { 8, alc883_sixstack_ch8_init },
6973};
6974
6975
Linus Torvalds1da177e2005-04-16 15:20:36 -07006976/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6977 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6978 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01006979static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006980 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006981 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006982 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006983 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006984 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6985 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006986 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6987 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006988 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006989 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6994 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006996 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6998 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006999 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007001 { } /* end */
7002};
7003
Takashi Iwai87350ad2007-08-16 18:19:38 +02007004static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007005 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7006 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7007 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7008 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7009 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7013 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007014 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7016 { } /* end */
7017};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007018
7019static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007020 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7021 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7023 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7025 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7027 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007028 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7029 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7031 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7033 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7034 { } /* end */
7035};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007036
Kailang Yangbdd148a2007-05-08 15:19:08 +02007037static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7040 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7041 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007047 { } /* end */
7048};
7049
Kailang Yang272a5272007-05-14 11:00:38 +02007050static struct snd_kcontrol_new alc882_targa_mixer[] = {
7051 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7052 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007060 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007063 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007064 { } /* end */
7065};
7066
7067/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7068 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7069 */
7070static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7071 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7072 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7073 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7074 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7075 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7076 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7078 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7079 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7080 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007083 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007084 { } /* end */
7085};
7086
Takashi Iwai914759b2007-09-06 14:52:04 +02007087static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7089 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7092 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7094 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007098 { } /* end */
7099};
7100
Kailang Yangdf694da2005-12-05 19:42:22 +01007101static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7102 {
7103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7104 .name = "Channel Mode",
7105 .info = alc_ch_mode_info,
7106 .get = alc_ch_mode_get,
7107 .put = alc_ch_mode_put,
7108 },
7109 { } /* end */
7110};
7111
Takashi Iwai49535502009-06-30 15:28:30 +02007112static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007113 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007117 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7120 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007121 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007122 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7123 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7124 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007125 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007126 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7127 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7128 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007129
Takashi Iwaicb638122009-07-03 10:56:10 +02007130 /* mute analog input loopbacks */
7131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7136
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007137 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007139 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007140 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007141 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007144 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007145 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007146 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007147 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007148 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007149 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007150 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007151 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007152 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007153 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007154 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007155 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7156 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007157 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007158 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7159 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007160 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007161 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7162 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7163 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7164 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7165 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007166 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007167 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007168
7169 /* FIXME: use matrix-type input source selection */
7170 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007171 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007176 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007181 /* ADC2: mute amp left and right */
7182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007183 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007184 /* ADC3: mute amp left and right */
7185 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007186 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007187
7188 { }
7189};
7190
Takashi Iwai49535502009-06-30 15:28:30 +02007191static struct hda_verb alc882_adc1_init_verbs[] = {
7192 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7197 /* ADC1: mute amp left and right */
7198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7199 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7200 { }
7201};
7202
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007203static struct hda_verb alc882_eapd_verbs[] = {
7204 /* change to EAPD mode */
7205 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007206 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007207 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007208};
7209
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007210static struct hda_verb alc889_eapd_verbs[] = {
7211 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7212 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7213 { }
7214};
7215
Wu Fengguang6732bd02009-07-30 09:19:14 +02007216static struct hda_verb alc_hp15_unsol_verbs[] = {
7217 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7219 {}
7220};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007221
7222static struct hda_verb alc885_init_verbs[] = {
7223 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7227 /* Rear mixer */
7228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7231 /* CLFE mixer */
7232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7235 /* Side mixer */
7236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7239
7240 /* mute analog input loopbacks */
7241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7244
7245 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7249 /* Front Pin: output 0 (0x0c) */
7250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7251 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7252 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7253 /* Rear Pin: output 1 (0x0d) */
7254 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7256 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7257 /* CLFE Pin: output 2 (0x0e) */
7258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7260 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7261 /* Side Pin: output 3 (0x0f) */
7262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7264 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7265 /* Mic (rear) pin: input vref at 80% */
7266 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7268 /* Front Mic pin: input vref at 80% */
7269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7271 /* Line In pin: input */
7272 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7274
7275 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7276 /* Input mixer1 */
7277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7280 /* Input mixer2 */
7281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7284 /* Input mixer3 */
7285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7288 /* ADC2: mute amp left and right */
7289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7290 /* ADC3: mute amp left and right */
7291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7292
7293 { }
7294};
7295
7296static struct hda_verb alc885_init_input_verbs[] = {
7297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7300 { }
7301};
7302
7303
7304/* Unmute Selector 24h and set the default input to front mic */
7305static struct hda_verb alc889_init_input_verbs[] = {
7306 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7308 { }
7309};
7310
7311
Takashi Iwai49535502009-06-30 15:28:30 +02007312#define alc883_init_verbs alc882_base_init_verbs
7313
Tobin Davis9102cd12006-12-15 10:02:12 +01007314/* Mac Pro test */
7315static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7317 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7318 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007321 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007322 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7323 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007324 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007325 { } /* end */
7326};
7327
7328static struct hda_verb alc882_macpro_init_verbs[] = {
7329 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7333 /* Front Pin: output 0 (0x0c) */
7334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7337 /* Front Mic pin: input vref at 80% */
7338 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7340 /* Speaker: output */
7341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7343 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7344 /* Headphone output (output 0 - 0x0c) */
7345 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7346 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7347 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7348
7349 /* FIXME: use matrix-type input source selection */
7350 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7351 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7356 /* Input mixer2 */
7357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7359 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7361 /* Input mixer3 */
7362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7366 /* ADC1: mute amp left and right */
7367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7368 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7369 /* ADC2: mute amp left and right */
7370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7371 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7372 /* ADC3: mute amp left and right */
7373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7374 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7375
7376 { }
7377};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007378
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007379/* Macbook 5,1 */
7380static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007381 /* DACs */
7382 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7383 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7384 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7385 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007386 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7388 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7389 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007390 /* Surround mixer */
7391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7392 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7394 /* LFE mixer */
7395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7398 /* HP mixer */
7399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7400 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7401 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7402 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007403 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7404 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007405 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7406 /* LFE Pin (0x0e) */
7407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7409 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7410 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007413 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007414 /* Front Mic pin: input vref at 80% */
7415 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7417 /* Line In pin */
7418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7420
7421 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7423 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7425 { }
7426};
7427
Takashi Iwai87350ad2007-08-16 18:19:38 +02007428/* Macbook Pro rev3 */
7429static struct hda_verb alc885_mbp3_init_verbs[] = {
7430 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7433 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7434 /* Rear mixer */
7435 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007438 /* HP mixer */
7439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7441 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007442 /* Front Pin: output 0 (0x0c) */
7443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007446 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007450 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7451 /* Mic (rear) pin: input vref at 80% */
7452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7454 /* Front Mic pin: input vref at 80% */
7455 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7456 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7457 /* Line In pin: use output 1 when in LineOut mode */
7458 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7459 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7460 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7461
7462 /* FIXME: use matrix-type input source selection */
7463 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7464 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7465 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7466 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7467 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7468 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7469 /* Input mixer2 */
7470 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7471 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7472 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7473 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7474 /* Input mixer3 */
7475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7477 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7479 /* ADC1: mute amp left and right */
7480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7481 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7482 /* ADC2: mute amp left and right */
7483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7484 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7485 /* ADC3: mute amp left and right */
7486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7487 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7488
7489 { }
7490};
7491
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007492/* iMac 24 mixer. */
7493static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7494 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7495 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7496 { } /* end */
7497};
7498
7499/* iMac 24 init verbs. */
7500static struct hda_verb alc885_imac24_init_verbs[] = {
7501 /* Internal speakers: output 0 (0x0c) */
7502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7503 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7504 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7505 /* Internal speakers: output 0 (0x0c) */
7506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7508 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7509 /* Headphone: output 0 (0x0c) */
7510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7512 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7513 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7514 /* Front Mic: input vref at 80% */
7515 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7516 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7517 { }
7518};
7519
7520/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007521static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007522{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007523 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007524
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007525 spec->autocfg.hp_pins[0] = 0x14;
7526 spec->autocfg.speaker_pins[0] = 0x18;
7527 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007528}
7529
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007530static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007531{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007532 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007533
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007534 spec->autocfg.hp_pins[0] = 0x15;
7535 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007536}
7537
7538
Kailang Yang272a5272007-05-14 11:00:38 +02007539static struct hda_verb alc882_targa_verbs[] = {
7540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7542
7543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7544 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007545
Kailang Yang272a5272007-05-14 11:00:38 +02007546 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7547 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7548 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7549
7550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007551 { } /* end */
7552};
7553
7554/* toggle speaker-output according to the hp-jack state */
7555static void alc882_targa_automute(struct hda_codec *codec)
7556{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007557 struct alc_spec *spec = codec->spec;
7558 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007559 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007560 spec->jack_present ? 1 : 3);
7561}
7562
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007563static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007564{
7565 struct alc_spec *spec = codec->spec;
7566
7567 spec->autocfg.hp_pins[0] = 0x14;
7568 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007569}
7570
7571static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7572{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007573 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007574 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007575}
7576
7577static struct hda_verb alc882_asus_a7j_verbs[] = {
7578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7580
7581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7583 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007584
Kailang Yang272a5272007-05-14 11:00:38 +02007585 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7586 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7587 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7588
7589 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7590 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7591 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7592 { } /* end */
7593};
7594
Takashi Iwai914759b2007-09-06 14:52:04 +02007595static struct hda_verb alc882_asus_a7m_verbs[] = {
7596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7598
7599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7601 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007602
Takashi Iwai914759b2007-09-06 14:52:04 +02007603 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7604 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7605 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7606
7607 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7608 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7609 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7610 { } /* end */
7611};
7612
Tobin Davis9102cd12006-12-15 10:02:12 +01007613static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7614{
7615 unsigned int gpiostate, gpiomask, gpiodir;
7616
7617 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7618 AC_VERB_GET_GPIO_DATA, 0);
7619
7620 if (!muted)
7621 gpiostate |= (1 << pin);
7622 else
7623 gpiostate &= ~(1 << pin);
7624
7625 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7626 AC_VERB_GET_GPIO_MASK, 0);
7627 gpiomask |= (1 << pin);
7628
7629 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7630 AC_VERB_GET_GPIO_DIRECTION, 0);
7631 gpiodir |= (1 << pin);
7632
7633
7634 snd_hda_codec_write(codec, codec->afg, 0,
7635 AC_VERB_SET_GPIO_MASK, gpiomask);
7636 snd_hda_codec_write(codec, codec->afg, 0,
7637 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7638
7639 msleep(1);
7640
7641 snd_hda_codec_write(codec, codec->afg, 0,
7642 AC_VERB_SET_GPIO_DATA, gpiostate);
7643}
7644
Takashi Iwai7debbe52007-08-16 15:01:03 +02007645/* set up GPIO at initialization */
7646static void alc885_macpro_init_hook(struct hda_codec *codec)
7647{
7648 alc882_gpio_mute(codec, 0, 0);
7649 alc882_gpio_mute(codec, 1, 0);
7650}
7651
7652/* set up GPIO and update auto-muting at initialization */
7653static void alc885_imac24_init_hook(struct hda_codec *codec)
7654{
7655 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007656 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007657}
7658
Kailang Yangdf694da2005-12-05 19:42:22 +01007659/*
7660 * generic initialization of ADC, input mixers and output mixers
7661 */
Takashi Iwai49535502009-06-30 15:28:30 +02007662static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007663 /*
7664 * Unmute ADC0-2 and set the default input to mic-in
7665 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007666 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7668 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7670
Takashi Iwaicb53c622007-08-10 17:21:45 +02007671 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007672 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007673 * Note: PASD motherboards uses the Line In 2 as the input for
7674 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007675 */
7676 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007682
7683 /*
7684 * Set up output mixers (0x0c - 0x0f)
7685 */
7686 /* set vol=0 to output mixers */
7687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7691 /* set up input amps for analog loopback */
7692 /* Amp Indices: DAC = 0, mixer = 1 */
7693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7695 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7696 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7697 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7698 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7699 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7700 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7701 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7702 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7703
7704 /* FIXME: use matrix-type input source selection */
7705 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007706 /* Input mixer2 */
7707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7709 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7711 /* Input mixer3 */
7712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7716
7717 { }
7718};
7719
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007720/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7721static struct hda_verb alc889A_mb31_ch2_init[] = {
7722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7723 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7726 { } /* end */
7727};
7728
7729/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7730static struct hda_verb alc889A_mb31_ch4_init[] = {
7731 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7735 { } /* end */
7736};
7737
7738/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7739static struct hda_verb alc889A_mb31_ch5_init[] = {
7740 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7744 { } /* end */
7745};
7746
7747/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7748static struct hda_verb alc889A_mb31_ch6_init[] = {
7749 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7753 { } /* end */
7754};
7755
7756static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7757 { 2, alc889A_mb31_ch2_init },
7758 { 4, alc889A_mb31_ch4_init },
7759 { 5, alc889A_mb31_ch5_init },
7760 { 6, alc889A_mb31_ch6_init },
7761};
7762
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007763static struct hda_verb alc883_medion_eapd_verbs[] = {
7764 /* eanable EAPD on medion laptop */
7765 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7766 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7767 { }
7768};
7769
Takashi Iwai49535502009-06-30 15:28:30 +02007770#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007771
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007772static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7773 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7774 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7776 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7777 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7778 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7781 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7783 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7784 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007786 { } /* end */
7787};
7788
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007789static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007790 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7791 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7792 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7793 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7797 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7799 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007800 { } /* end */
7801};
7802
Jiang zhefb97dc62008-03-06 11:07:11 +01007803static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7804 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7805 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7807 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7813 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007814 { } /* end */
7815};
7816
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007817static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7818 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7819 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7820 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7821 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7822 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7824 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007826 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007829 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007830 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007831 { } /* end */
7832};
7833
7834static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7836 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7837 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7838 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7839 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7840 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7841 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7842 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7843 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7846 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7847 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007849 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007852 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007853 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007854 { } /* end */
7855};
7856
Jiang zhe17bba1b2008-06-04 12:11:07 +02007857static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7859 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7860 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7861 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7862 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7863 HDA_OUTPUT),
7864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7865 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7866 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7873 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7876 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007878 { } /* end */
7879};
7880
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007881static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7885 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7887 HDA_OUTPUT),
7888 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7889 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7890 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7892 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7897 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7902 { } /* end */
7903};
7904
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007905static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007908 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007909 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007910 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7911 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007912 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7913 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007923 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007924 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007925 { } /* end */
7926};
7927
Sasha Alexandrc2592492009-06-16 14:52:54 -04007928static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7931 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7932 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7933 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7934 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7935 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7936 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7937 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7938 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7939 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7941 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007944 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007945 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007946};
Kailang Yangccc656c2006-10-17 12:32:26 +02007947
Sasha Alexandrc2592492009-06-16 14:52:54 -04007948static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007949 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7950 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007957 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7959 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007960 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007961};
Kailang Yangccc656c2006-10-17 12:32:26 +02007962
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007963static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7965 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007966 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7967 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007972 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007973};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007974
Kailang Yang272a5272007-05-14 11:00:38 +02007975static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7976 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7977 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7983 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7984 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007985 { } /* end */
7986};
7987
7988static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7989 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7991 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7995 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7997 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007998 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007999};
Kailang Yang272a5272007-05-14 11:00:38 +02008000
Tobin Davis2880a862007-08-07 11:50:26 +02008001static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008002 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8003 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008010 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008011};
Tobin Davis2880a862007-08-07 11:50:26 +02008012
Tony Vroond2fd4b02009-06-21 00:40:10 +01008013static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8015 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8016 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8017 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008018 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8019 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8025 { } /* end */
8026};
8027
Kailang Yange2757d52008-08-26 13:17:46 +02008028static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8030 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8032 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8033 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8034 0x0d, 1, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8036 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8037 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8039 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008040 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8041 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8047 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8048 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008050 { } /* end */
8051};
8052
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008053static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8054 /* Output mixers */
8055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8056 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8057 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8058 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8059 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8060 HDA_OUTPUT),
8061 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8063 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8064 /* Output switches */
8065 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8066 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8067 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8068 /* Boost mixers */
8069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8071 /* Input mixers */
8072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8075 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8076 { } /* end */
8077};
8078
Guido Günther3e1647c2009-06-05 00:47:26 +02008079static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8080 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8081 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8082 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8086 { } /* end */
8087};
8088
Kailang Yange2757d52008-08-26 13:17:46 +02008089static struct hda_bind_ctls alc883_bind_cap_vol = {
8090 .ops = &snd_hda_bind_vol,
8091 .values = {
8092 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8093 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8094 0
8095 },
8096};
8097
8098static struct hda_bind_ctls alc883_bind_cap_switch = {
8099 .ops = &snd_hda_bind_sw,
8100 .values = {
8101 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8102 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8103 0
8104 },
8105};
8106
8107static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8109 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8110 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008116 { } /* end */
8117};
8118
8119static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008120 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8121 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8122 {
8123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8124 /* .name = "Capture Source", */
8125 .name = "Input Source",
8126 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008127 .info = alc_mux_enum_info,
8128 .get = alc_mux_enum_get,
8129 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008130 },
8131 { } /* end */
8132};
8133
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008134static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8135 {
8136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8137 .name = "Channel Mode",
8138 .info = alc_ch_mode_info,
8139 .get = alc_ch_mode_get,
8140 .put = alc_ch_mode_put,
8141 },
8142 { } /* end */
8143};
8144
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008145/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008146static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008147{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008148 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008149
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008150 spec->autocfg.hp_pins[0] = 0x15;
8151 spec->autocfg.speaker_pins[0] = 0x14;
8152 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008153}
8154
8155/* auto-toggle front mic */
8156/*
8157static void alc883_mitac_mic_automute(struct hda_codec *codec)
8158{
8159 unsigned int present;
8160 unsigned char bits;
8161
8162 present = snd_hda_codec_read(codec, 0x18, 0,
8163 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8164 bits = present ? HDA_AMP_MUTE : 0;
8165 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8166}
8167*/
8168
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008169static struct hda_verb alc883_mitac_verbs[] = {
8170 /* HP */
8171 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8173 /* Subwoofer */
8174 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8175 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8176
8177 /* enable unsolicited event */
8178 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8179 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8180
8181 { } /* end */
8182};
8183
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308184static struct hda_verb alc883_clevo_m540r_verbs[] = {
8185 /* HP */
8186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8188 /* Int speaker */
8189 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8190
8191 /* enable unsolicited event */
8192 /*
8193 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8194 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8195 */
8196
8197 { } /* end */
8198};
8199
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008200static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008201 /* HP */
8202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8204 /* Int speaker */
8205 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8207
8208 /* enable unsolicited event */
8209 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008210 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008211
8212 { } /* end */
8213};
8214
Jiang zhefb97dc62008-03-06 11:07:11 +01008215static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8216 /* HP */
8217 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8219 /* Subwoofer */
8220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8222
8223 /* enable unsolicited event */
8224 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8225
8226 { } /* end */
8227};
8228
Sasha Alexandrc2592492009-06-16 14:52:54 -04008229static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8232
8233 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008235
David Heidelberger64a8be72009-06-08 16:15:18 +02008236/* Connect Line-Out side jack (SPDIF) to Side */
8237 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8238 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8239 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8240/* Connect Mic jack to CLFE */
8241 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8242 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8243 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8244/* Connect Line-in jack to Surround */
8245 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8246 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8247 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8248/* Connect HP out jack to Front */
8249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8251 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008252
8253 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008254
8255 { } /* end */
8256};
8257
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008258static struct hda_verb alc883_lenovo_101e_verbs[] = {
8259 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8260 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8261 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8262 { } /* end */
8263};
8264
Kailang Yang272a5272007-05-14 11:00:38 +02008265static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8266 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8268 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8270 { } /* end */
8271};
8272
8273static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8276 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8277 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8278 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8279 { } /* end */
8280};
8281
Kailang Yang189609a2007-08-20 11:31:23 +02008282static struct hda_verb alc883_haier_w66_verbs[] = {
8283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8285
8286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8287
8288 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8289 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8290 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8291 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8292 { } /* end */
8293};
8294
Kailang Yange2757d52008-08-26 13:17:46 +02008295static struct hda_verb alc888_lenovo_sky_verbs[] = {
8296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8300 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8302 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8303 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8304 { } /* end */
8305};
8306
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008307static struct hda_verb alc888_6st_dell_verbs[] = {
8308 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8309 { }
8310};
8311
Guido Günther3e1647c2009-06-05 00:47:26 +02008312static struct hda_verb alc883_vaiott_verbs[] = {
8313 /* HP */
8314 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8316
8317 /* enable unsolicited event */
8318 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8319
8320 { } /* end */
8321};
8322
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008323static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008324{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008325 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008326
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008327 spec->autocfg.hp_pins[0] = 0x1b;
8328 spec->autocfg.speaker_pins[0] = 0x14;
8329 spec->autocfg.speaker_pins[1] = 0x16;
8330 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008331}
8332
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008333static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008334 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008335 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8336 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008337 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008338 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008339};
8340
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008341/*
8342 * 2ch mode
8343 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008344static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008345 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8346 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8347 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8348 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008349 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008350};
8351
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008352/*
8353 * 4ch mode
8354 */
8355static struct hda_verb alc888_3st_hp_4ch_init[] = {
8356 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8357 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8358 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8359 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8360 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8361 { } /* end */
8362};
8363
8364/*
8365 * 6ch mode
8366 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008367static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008368 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8369 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008370 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008371 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8372 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008373 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8374 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008375};
8376
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008377static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008378 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008379 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008380 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008381};
8382
Kailang Yang272a5272007-05-14 11:00:38 +02008383/* toggle front-jack and RCA according to the hp-jack state */
8384static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8385{
8386 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008387
Kailang Yang272a5272007-05-14 11:00:38 +02008388 present = snd_hda_codec_read(codec, 0x1b, 0,
8389 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008390 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8391 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8392 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8393 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008394}
8395
8396/* toggle RCA according to the front-jack state */
8397static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8398{
8399 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008400
Kailang Yang272a5272007-05-14 11:00:38 +02008401 present = snd_hda_codec_read(codec, 0x14, 0,
8402 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008403 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8404 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008405}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008406
Kailang Yang272a5272007-05-14 11:00:38 +02008407static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8408 unsigned int res)
8409{
8410 if ((res >> 26) == ALC880_HP_EVENT)
8411 alc888_lenovo_ms7195_front_automute(codec);
8412 if ((res >> 26) == ALC880_FRONT_EVENT)
8413 alc888_lenovo_ms7195_rca_automute(codec);
8414}
8415
8416static struct hda_verb alc883_medion_md2_verbs[] = {
8417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8419
8420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8421
8422 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8423 { } /* end */
8424};
8425
8426/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008427static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008428{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008429 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008430
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008431 spec->autocfg.hp_pins[0] = 0x14;
8432 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008433}
8434
Kailang Yangccc656c2006-10-17 12:32:26 +02008435/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008436#define alc883_targa_init_hook alc882_targa_init_hook
8437#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008438
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008439static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8440{
8441 unsigned int present;
8442
8443 present = snd_hda_codec_read(codec, 0x18, 0,
8444 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8445 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8446 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8447}
8448
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008449static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008450{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008451 struct alc_spec *spec = codec->spec;
8452
8453 spec->autocfg.hp_pins[0] = 0x15;
8454 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008455}
8456
8457static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8458{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008459 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008460 alc883_clevo_m720_mic_automute(codec);
8461}
8462
8463static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008464 unsigned int res)
8465{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008466 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008467 case ALC880_MIC_EVENT:
8468 alc883_clevo_m720_mic_automute(codec);
8469 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008470 default:
8471 alc_automute_amp_unsol_event(codec, res);
8472 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008473 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008474}
8475
Jiang zhefb97dc62008-03-06 11:07:11 +01008476/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008477static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008478{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008479 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008480
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008481 spec->autocfg.hp_pins[0] = 0x14;
8482 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008483}
8484
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008485static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008486{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008487 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008488
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008489 spec->autocfg.hp_pins[0] = 0x1b;
8490 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008491}
8492
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008493static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8494{
8495 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008496 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008497
David Heidelberger64a8be72009-06-08 16:15:18 +02008498 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8499 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008500 bits = present ? HDA_AMP_MUTE : 0;
8501 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8502 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008503}
8504
8505static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8506{
8507 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008508 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008509
8510 present = snd_hda_codec_read(codec, 0x1b, 0,
8511 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008512 bits = present ? HDA_AMP_MUTE : 0;
8513 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8514 HDA_AMP_MUTE, bits);
8515 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8516 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008517}
8518
8519static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8520 unsigned int res)
8521{
8522 if ((res >> 26) == ALC880_HP_EVENT)
8523 alc883_lenovo_101e_all_automute(codec);
8524 if ((res >> 26) == ALC880_FRONT_EVENT)
8525 alc883_lenovo_101e_ispeaker_automute(codec);
8526}
8527
Takashi Iwai676a9b52007-08-16 15:23:35 +02008528/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008529static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008530{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008531 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008532
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008533 spec->autocfg.hp_pins[0] = 0x14;
8534 spec->autocfg.speaker_pins[0] = 0x15;
8535 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008536}
8537
Kailang Yangd1a991a2007-08-15 16:21:59 +02008538static struct hda_verb alc883_acer_eapd_verbs[] = {
8539 /* HP Pin: output 0 (0x0c) */
8540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8541 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8542 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8543 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8545 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008546 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008547 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8548 /* eanable EAPD on medion laptop */
8549 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8550 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008551 /* enable unsolicited event */
8552 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008553 { }
8554};
8555
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008556static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8558 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8560 { } /* end */
8561};
8562
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008563static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008564{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008565 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008566
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008567 spec->autocfg.hp_pins[0] = 0x1b;
8568 spec->autocfg.speaker_pins[0] = 0x14;
8569 spec->autocfg.speaker_pins[1] = 0x15;
8570 spec->autocfg.speaker_pins[2] = 0x16;
8571 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008572}
8573
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008574static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008575{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008576 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008577
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008578 spec->autocfg.hp_pins[0] = 0x1b;
8579 spec->autocfg.speaker_pins[0] = 0x14;
8580 spec->autocfg.speaker_pins[1] = 0x15;
8581 spec->autocfg.speaker_pins[2] = 0x16;
8582 spec->autocfg.speaker_pins[3] = 0x17;
8583 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008584}
8585
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008586static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008587{
8588 struct alc_spec *spec = codec->spec;
8589
8590 spec->autocfg.hp_pins[0] = 0x15;
8591 spec->autocfg.speaker_pins[0] = 0x14;
8592 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008593}
8594
Kailang Yange2757d52008-08-26 13:17:46 +02008595static struct hda_verb alc888_asus_m90v_verbs[] = {
8596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8599 /* enable unsolicited event */
8600 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8601 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8602 { } /* end */
8603};
8604
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008605static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008606{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008607 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008608
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008609 spec->autocfg.hp_pins[0] = 0x1b;
8610 spec->autocfg.speaker_pins[0] = 0x14;
8611 spec->autocfg.speaker_pins[1] = 0x15;
8612 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008613 spec->ext_mic.pin = 0x18;
8614 spec->int_mic.pin = 0x19;
8615 spec->ext_mic.mux_idx = 0;
8616 spec->int_mic.mux_idx = 1;
8617 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008618}
8619
8620static struct hda_verb alc888_asus_eee1601_verbs[] = {
8621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8624 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8626 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8627 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8628 /* enable unsolicited event */
8629 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8630 { } /* end */
8631};
8632
Kailang Yange2757d52008-08-26 13:17:46 +02008633static void alc883_eee1601_inithook(struct hda_codec *codec)
8634{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008635 struct alc_spec *spec = codec->spec;
8636
8637 spec->autocfg.hp_pins[0] = 0x14;
8638 spec->autocfg.speaker_pins[0] = 0x1b;
8639 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008640}
8641
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008642static struct hda_verb alc889A_mb31_verbs[] = {
8643 /* Init rear pin (used as headphone output) */
8644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8645 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8646 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8647 /* Init line pin (used as output in 4ch and 6ch mode) */
8648 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8649 /* Init line 2 pin (used as headphone out by default) */
8650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8652 { } /* end */
8653};
8654
8655/* Mute speakers according to the headphone jack state */
8656static void alc889A_mb31_automute(struct hda_codec *codec)
8657{
8658 unsigned int present;
8659
8660 /* Mute only in 2ch or 4ch mode */
8661 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8662 == 0x00) {
8663 present = snd_hda_codec_read(codec, 0x15, 0,
8664 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8665 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8666 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8667 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8668 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8669 }
8670}
8671
8672static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8673{
8674 if ((res >> 26) == ALC880_HP_EVENT)
8675 alc889A_mb31_automute(codec);
8676}
8677
Takashi Iwai49535502009-06-30 15:28:30 +02008678
Takashi Iwaicb53c622007-08-10 17:21:45 +02008679#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai49535502009-06-30 15:28:30 +02008680#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008681#endif
8682
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008683/* pcm configuration: identical with ALC880 */
Takashi Iwai49535502009-06-30 15:28:30 +02008684#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8685#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8686#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8687#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8688
8689static hda_nid_t alc883_slave_dig_outs[] = {
8690 ALC1200_DIGOUT_NID, 0,
8691};
8692
8693static hda_nid_t alc1200_slave_dig_outs[] = {
8694 ALC883_DIGOUT_NID, 0,
8695};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008696
8697/*
8698 * configuration and preset
8699 */
Takashi Iwai49535502009-06-30 15:28:30 +02008700static const char *alc882_models[ALC882_MODEL_LAST] = {
8701 [ALC882_3ST_DIG] = "3stack-dig",
8702 [ALC882_6ST_DIG] = "6stack-dig",
8703 [ALC882_ARIMA] = "arima",
8704 [ALC882_W2JC] = "w2jc",
8705 [ALC882_TARGA] = "targa",
8706 [ALC882_ASUS_A7J] = "asus-a7j",
8707 [ALC882_ASUS_A7M] = "asus-a7m",
8708 [ALC885_MACPRO] = "macpro",
8709 [ALC885_MB5] = "mb5",
8710 [ALC885_MBP3] = "mbp3",
8711 [ALC885_IMAC24] = "imac24",
8712 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008713 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8714 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai49535502009-06-30 15:28:30 +02008715 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008716 [ALC883_TARGA_DIG] = "targa-dig",
8717 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008718 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008719 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008720 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008721 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008722 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008723 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008724 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008725 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008726 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008727 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008728 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008729 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8730 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008731 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008732 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008733 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008734 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008735 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308736 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008737 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008738 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008739 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008740 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008741 [ALC889A_INTEL] = "intel-alc889a",
8742 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008743 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008744 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008745 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai49535502009-06-30 15:28:30 +02008746 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008747};
8748
Takashi Iwai49535502009-06-30 15:28:30 +02008749static struct snd_pci_quirk alc882_cfg_tbl[] = {
8750 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8751
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008752 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008753 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008754 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008755 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8756 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008757 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008758 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8759 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008760 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8761 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008762 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8763 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008764 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8765 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai49535502009-06-30 15:28:30 +02008766 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8767 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008768 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008769 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008770 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008771 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008772 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8773 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008774 /* default Acer -- disabled as it causes more problems.
8775 * model=auto should work fine now
8776 */
8777 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai49535502009-06-30 15:28:30 +02008778
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008779 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai49535502009-06-30 15:28:30 +02008780
Tobin Davisfebe3372007-06-12 11:27:46 +02008781 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008782 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8783 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008784 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008785 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008786 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai49535502009-06-30 15:28:30 +02008787
8788 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8789 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8790 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008791 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai49535502009-06-30 15:28:30 +02008792 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8793 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8794 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008795 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008796 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008797 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008798 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai49535502009-06-30 15:28:30 +02008799
8800 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008801 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02008802 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008803 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008804 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8805 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008806 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008807 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02008808 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8809
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008810 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8811 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8812 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02008813 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008814 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02008815 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008816 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008817 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008818 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8819 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8820 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8821 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8822 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8823 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008824 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008825 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8826 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8827 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008828 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008829 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8830 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008831 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008832 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008833 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008834 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008835 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008836 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008837 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008838 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02008839
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008840 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008841 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8842 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308843 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008844 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008845 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02008846 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008847 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008848 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008849 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008850 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008851 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008852 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008853 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008854 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8855 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008856 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008857 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008858 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008859 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008860 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai49535502009-06-30 15:28:30 +02008861
Jiang zhe17bba1b2008-06-04 12:11:07 +02008862 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8863 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008864 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008865 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8866 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8867 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008868 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02008869
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008870 {}
8871};
8872
Takashi Iwai49535502009-06-30 15:28:30 +02008873/* codec SSID table for Intel Mac */
8874static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8875 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8876 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8877 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8878 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8879 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8880 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8881 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8882 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8883 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8884 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8885 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8886 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8887 * no perfect solution yet
8888 */
8889 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8890 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008891};
8892
Takashi Iwai49535502009-06-30 15:28:30 +02008893static struct alc_config_preset alc882_presets[] = {
8894 [ALC882_3ST_DIG] = {
8895 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008896 .init_verbs = { alc882_base_init_verbs,
8897 alc882_adc1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02008898 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8899 .dac_nids = alc882_dac_nids,
8900 .dig_out_nid = ALC882_DIGOUT_NID,
8901 .dig_in_nid = ALC882_DIGIN_NID,
8902 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8903 .channel_mode = alc882_ch_modes,
8904 .need_dac_fix = 1,
8905 .input_mux = &alc882_capture_source,
8906 },
8907 [ALC882_6ST_DIG] = {
8908 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008909 .init_verbs = { alc882_base_init_verbs,
8910 alc882_adc1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02008911 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8912 .dac_nids = alc882_dac_nids,
8913 .dig_out_nid = ALC882_DIGOUT_NID,
8914 .dig_in_nid = ALC882_DIGIN_NID,
8915 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8916 .channel_mode = alc882_sixstack_modes,
8917 .input_mux = &alc882_capture_source,
8918 },
8919 [ALC882_ARIMA] = {
8920 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008921 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8922 alc882_eapd_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02008923 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8924 .dac_nids = alc882_dac_nids,
8925 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8926 .channel_mode = alc882_sixstack_modes,
8927 .input_mux = &alc882_capture_source,
8928 },
8929 [ALC882_W2JC] = {
8930 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008931 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8932 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02008933 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8934 .dac_nids = alc882_dac_nids,
8935 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8936 .channel_mode = alc880_threestack_modes,
8937 .need_dac_fix = 1,
8938 .input_mux = &alc882_capture_source,
8939 .dig_out_nid = ALC882_DIGOUT_NID,
8940 },
8941 [ALC885_MBP3] = {
8942 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8943 .init_verbs = { alc885_mbp3_init_verbs,
8944 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008945 .num_dacs = 2,
Takashi Iwai49535502009-06-30 15:28:30 +02008946 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008947 .hp_nid = 0x04,
8948 .channel_mode = alc885_mbp_4ch_modes,
8949 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai49535502009-06-30 15:28:30 +02008950 .input_mux = &alc882_capture_source,
8951 .dig_out_nid = ALC882_DIGOUT_NID,
8952 .dig_in_nid = ALC882_DIGIN_NID,
8953 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008954 .setup = alc885_mbp3_setup,
8955 .init_hook = alc_automute_amp,
Takashi Iwai49535502009-06-30 15:28:30 +02008956 },
8957 [ALC885_MB5] = {
8958 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8959 .init_verbs = { alc885_mb5_init_verbs,
8960 alc880_gpio1_init_verbs },
8961 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8962 .dac_nids = alc882_dac_nids,
8963 .channel_mode = alc885_mb5_6ch_modes,
8964 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8965 .input_mux = &mb5_capture_source,
8966 .dig_out_nid = ALC882_DIGOUT_NID,
8967 .dig_in_nid = ALC882_DIGIN_NID,
8968 },
8969 [ALC885_MACPRO] = {
8970 .mixers = { alc882_macpro_mixer },
8971 .init_verbs = { alc882_macpro_init_verbs },
8972 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8973 .dac_nids = alc882_dac_nids,
8974 .dig_out_nid = ALC882_DIGOUT_NID,
8975 .dig_in_nid = ALC882_DIGIN_NID,
8976 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8977 .channel_mode = alc882_ch_modes,
8978 .input_mux = &alc882_capture_source,
8979 .init_hook = alc885_macpro_init_hook,
8980 },
8981 [ALC885_IMAC24] = {
8982 .mixers = { alc885_imac24_mixer },
8983 .init_verbs = { alc885_imac24_init_verbs },
8984 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8985 .dac_nids = alc882_dac_nids,
8986 .dig_out_nid = ALC882_DIGOUT_NID,
8987 .dig_in_nid = ALC882_DIGIN_NID,
8988 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8989 .channel_mode = alc882_ch_modes,
8990 .input_mux = &alc882_capture_source,
8991 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008992 .setup = alc885_imac24_setup,
Takashi Iwai49535502009-06-30 15:28:30 +02008993 .init_hook = alc885_imac24_init_hook,
8994 },
8995 [ALC882_TARGA] = {
8996 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008997 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008998 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai49535502009-06-30 15:28:30 +02008999 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9000 .dac_nids = alc882_dac_nids,
9001 .dig_out_nid = ALC882_DIGOUT_NID,
9002 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9003 .adc_nids = alc882_adc_nids,
9004 .capsrc_nids = alc882_capsrc_nids,
9005 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9006 .channel_mode = alc882_3ST_6ch_modes,
9007 .need_dac_fix = 1,
9008 .input_mux = &alc882_capture_source,
9009 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009010 .setup = alc882_targa_setup,
9011 .init_hook = alc882_targa_automute,
Takashi Iwai49535502009-06-30 15:28:30 +02009012 },
9013 [ALC882_ASUS_A7J] = {
9014 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009015 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9016 alc882_asus_a7j_verbs},
Takashi Iwai49535502009-06-30 15:28:30 +02009017 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9018 .dac_nids = alc882_dac_nids,
9019 .dig_out_nid = ALC882_DIGOUT_NID,
9020 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9021 .adc_nids = alc882_adc_nids,
9022 .capsrc_nids = alc882_capsrc_nids,
9023 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9024 .channel_mode = alc882_3ST_6ch_modes,
9025 .need_dac_fix = 1,
9026 .input_mux = &alc882_capture_source,
9027 },
9028 [ALC882_ASUS_A7M] = {
9029 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009030 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9031 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai49535502009-06-30 15:28:30 +02009032 alc882_asus_a7m_verbs },
9033 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9034 .dac_nids = alc882_dac_nids,
9035 .dig_out_nid = ALC882_DIGOUT_NID,
9036 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9037 .channel_mode = alc880_threestack_modes,
9038 .need_dac_fix = 1,
9039 .input_mux = &alc882_capture_source,
9040 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009041 [ALC883_3ST_2ch_DIG] = {
9042 .mixers = { alc883_3ST_2ch_mixer },
9043 .init_verbs = { alc883_init_verbs },
9044 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9045 .dac_nids = alc883_dac_nids,
9046 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009047 .dig_in_nid = ALC883_DIGIN_NID,
9048 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9049 .channel_mode = alc883_3ST_2ch_modes,
9050 .input_mux = &alc883_capture_source,
9051 },
9052 [ALC883_3ST_6ch_DIG] = {
9053 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9054 .init_verbs = { alc883_init_verbs },
9055 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9056 .dac_nids = alc883_dac_nids,
9057 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009058 .dig_in_nid = ALC883_DIGIN_NID,
9059 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9060 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009061 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009062 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009063 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009064 [ALC883_3ST_6ch] = {
9065 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9066 .init_verbs = { alc883_init_verbs },
9067 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9068 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009069 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9070 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009071 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009072 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009073 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009074 [ALC883_3ST_6ch_INTEL] = {
9075 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9076 .init_verbs = { alc883_init_verbs },
9077 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9078 .dac_nids = alc883_dac_nids,
9079 .dig_out_nid = ALC883_DIGOUT_NID,
9080 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009081 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009082 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9083 .channel_mode = alc883_3ST_6ch_intel_modes,
9084 .need_dac_fix = 1,
9085 .input_mux = &alc883_3stack_6ch_intel,
9086 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009087 [ALC889A_INTEL] = {
9088 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009089 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9090 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009091 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9092 .dac_nids = alc883_dac_nids,
9093 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9094 .adc_nids = alc889_adc_nids,
9095 .dig_out_nid = ALC883_DIGOUT_NID,
9096 .dig_in_nid = ALC883_DIGIN_NID,
9097 .slave_dig_outs = alc883_slave_dig_outs,
9098 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9099 .channel_mode = alc889_8ch_intel_modes,
9100 .capsrc_nids = alc889_capsrc_nids,
9101 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009102 .setup = alc889_automute_setup,
9103 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009104 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009105 .need_dac_fix = 1,
9106 },
9107 [ALC889_INTEL] = {
9108 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9109 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009110 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009111 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9112 .dac_nids = alc883_dac_nids,
9113 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9114 .adc_nids = alc889_adc_nids,
9115 .dig_out_nid = ALC883_DIGOUT_NID,
9116 .dig_in_nid = ALC883_DIGIN_NID,
9117 .slave_dig_outs = alc883_slave_dig_outs,
9118 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9119 .channel_mode = alc889_8ch_intel_modes,
9120 .capsrc_nids = alc889_capsrc_nids,
9121 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009122 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009123 .init_hook = alc889_intel_init_hook,
9124 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009125 .need_dac_fix = 1,
9126 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009127 [ALC883_6ST_DIG] = {
9128 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9129 .init_verbs = { alc883_init_verbs },
9130 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9131 .dac_nids = alc883_dac_nids,
9132 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009133 .dig_in_nid = ALC883_DIGIN_NID,
9134 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9135 .channel_mode = alc883_sixstack_modes,
9136 .input_mux = &alc883_capture_source,
9137 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009138 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009139 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009140 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9141 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009142 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9143 .dac_nids = alc883_dac_nids,
9144 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009145 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9146 .channel_mode = alc883_3ST_6ch_modes,
9147 .need_dac_fix = 1,
9148 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009149 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009150 .setup = alc882_targa_setup,
9151 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009152 },
9153 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009154 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009155 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9156 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009157 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9158 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009159 .adc_nids = alc883_adc_nids_alt,
9160 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009161 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009162 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9163 .channel_mode = alc883_3ST_2ch_modes,
9164 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009165 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009166 .setup = alc882_targa_setup,
9167 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009168 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009169 [ALC883_TARGA_8ch_DIG] = {
9170 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9171 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009172 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009173 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9174 .dac_nids = alc883_dac_nids,
9175 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9176 .adc_nids = alc883_adc_nids_rev,
9177 .capsrc_nids = alc883_capsrc_nids_rev,
9178 .dig_out_nid = ALC883_DIGOUT_NID,
9179 .dig_in_nid = ALC883_DIGIN_NID,
9180 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9181 .channel_mode = alc883_4ST_8ch_modes,
9182 .need_dac_fix = 1,
9183 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009184 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009185 .setup = alc882_targa_setup,
9186 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009187 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009188 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009189 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009190 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9191 * and the headphone jack. Turn this on and rely on the
9192 * standard mute methods whenever the user wants to turn
9193 * these outputs off.
9194 */
9195 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9196 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9197 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009198 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9199 .channel_mode = alc883_3ST_2ch_modes,
9200 .input_mux = &alc883_capture_source,
9201 },
Tobin Davis2880a862007-08-07 11:50:26 +02009202 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009203 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009204 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9206 .dac_nids = alc883_dac_nids,
9207 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009208 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9209 .channel_mode = alc883_3ST_2ch_modes,
9210 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009211 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009212 .setup = alc883_acer_aspire_setup,
9213 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009214 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009215 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009216 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009217 alc883_chmode_mixer },
9218 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9219 alc888_acer_aspire_4930g_verbs },
9220 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9221 .dac_nids = alc883_dac_nids,
9222 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9223 .adc_nids = alc883_adc_nids_rev,
9224 .capsrc_nids = alc883_capsrc_nids_rev,
9225 .dig_out_nid = ALC883_DIGOUT_NID,
9226 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9227 .channel_mode = alc883_3ST_6ch_modes,
9228 .need_dac_fix = 1,
9229 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009230 ARRAY_SIZE(alc888_2_capture_sources),
9231 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009232 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009233 .setup = alc888_acer_aspire_4930g_setup,
9234 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009235 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009236 [ALC888_ACER_ASPIRE_6530G] = {
9237 .mixers = { alc888_acer_aspire_6530_mixer },
9238 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9239 alc888_acer_aspire_6530g_verbs },
9240 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9241 .dac_nids = alc883_dac_nids,
9242 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9243 .adc_nids = alc883_adc_nids_rev,
9244 .capsrc_nids = alc883_capsrc_nids_rev,
9245 .dig_out_nid = ALC883_DIGOUT_NID,
9246 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9247 .channel_mode = alc883_3ST_2ch_modes,
9248 .num_mux_defs =
9249 ARRAY_SIZE(alc888_2_capture_sources),
9250 .input_mux = alc888_acer_aspire_6530_sources,
9251 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009252 .setup = alc888_acer_aspire_6530g_setup,
9253 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009254 },
Hector Martin3b315d72009-06-02 10:54:19 +02009255 [ALC888_ACER_ASPIRE_8930G] = {
9256 .mixers = { alc888_base_mixer,
9257 alc883_chmode_mixer },
9258 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009259 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009260 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9261 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009262 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9263 .adc_nids = alc889_adc_nids,
9264 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009265 .dig_out_nid = ALC883_DIGOUT_NID,
9266 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9267 .channel_mode = alc883_3ST_6ch_modes,
9268 .need_dac_fix = 1,
9269 .const_channel_count = 6,
9270 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009271 ARRAY_SIZE(alc889_capture_sources),
9272 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009273 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009274 .setup = alc889_acer_aspire_8930g_setup,
9275 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009276 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009277 [ALC888_ACER_ASPIRE_7730G] = {
9278 .mixers = { alc883_3ST_6ch_mixer,
9279 alc883_chmode_mixer },
9280 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9281 alc888_acer_aspire_7730G_verbs },
9282 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9283 .dac_nids = alc883_dac_nids,
9284 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9285 .adc_nids = alc883_adc_nids_rev,
9286 .capsrc_nids = alc883_capsrc_nids_rev,
9287 .dig_out_nid = ALC883_DIGOUT_NID,
9288 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9289 .channel_mode = alc883_3ST_6ch_modes,
9290 .need_dac_fix = 1,
9291 .const_channel_count = 6,
9292 .input_mux = &alc883_capture_source,
9293 .unsol_event = alc_automute_amp_unsol_event,
9294 .setup = alc888_acer_aspire_6530g_setup,
9295 .init_hook = alc_automute_amp,
9296 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009297 [ALC883_MEDION] = {
9298 .mixers = { alc883_fivestack_mixer,
9299 alc883_chmode_mixer },
9300 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009301 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009302 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9303 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009304 .adc_nids = alc883_adc_nids_alt,
9305 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009306 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9307 .channel_mode = alc883_sixstack_modes,
9308 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009309 },
Kailang Yang272a5272007-05-14 11:00:38 +02009310 [ALC883_MEDION_MD2] = {
9311 .mixers = { alc883_medion_md2_mixer},
9312 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9313 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9314 .dac_nids = alc883_dac_nids,
9315 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009316 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9317 .channel_mode = alc883_3ST_2ch_modes,
9318 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009319 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009320 .setup = alc883_medion_md2_setup,
9321 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009322 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009323 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009324 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009325 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9326 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9327 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009328 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9329 .channel_mode = alc883_3ST_2ch_modes,
9330 .input_mux = &alc883_capture_source,
9331 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309332 [ALC883_CLEVO_M540R] = {
9333 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9334 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9335 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9336 .dac_nids = alc883_dac_nids,
9337 .dig_out_nid = ALC883_DIGOUT_NID,
9338 .dig_in_nid = ALC883_DIGIN_NID,
9339 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9340 .channel_mode = alc883_3ST_6ch_clevo_modes,
9341 .need_dac_fix = 1,
9342 .input_mux = &alc883_capture_source,
9343 /* This machine has the hardware HP auto-muting, thus
9344 * we need no software mute via unsol event
9345 */
9346 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009347 [ALC883_CLEVO_M720] = {
9348 .mixers = { alc883_clevo_m720_mixer },
9349 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009350 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9351 .dac_nids = alc883_dac_nids,
9352 .dig_out_nid = ALC883_DIGOUT_NID,
9353 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9354 .channel_mode = alc883_3ST_2ch_modes,
9355 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009356 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009357 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009358 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009359 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009360 [ALC883_LENOVO_101E_2ch] = {
9361 .mixers = { alc883_lenovo_101e_2ch_mixer},
9362 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9363 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9364 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009365 .adc_nids = alc883_adc_nids_alt,
9366 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009367 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9368 .channel_mode = alc883_3ST_2ch_modes,
9369 .input_mux = &alc883_lenovo_101e_capture_source,
9370 .unsol_event = alc883_lenovo_101e_unsol_event,
9371 .init_hook = alc883_lenovo_101e_all_automute,
9372 },
Kailang Yang272a5272007-05-14 11:00:38 +02009373 [ALC883_LENOVO_NB0763] = {
9374 .mixers = { alc883_lenovo_nb0763_mixer },
9375 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9376 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9377 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009378 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9379 .channel_mode = alc883_3ST_2ch_modes,
9380 .need_dac_fix = 1,
9381 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009382 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009383 .setup = alc883_medion_md2_setup,
9384 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009385 },
9386 [ALC888_LENOVO_MS7195_DIG] = {
9387 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9388 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9389 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9390 .dac_nids = alc883_dac_nids,
9391 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9393 .channel_mode = alc883_3ST_6ch_modes,
9394 .need_dac_fix = 1,
9395 .input_mux = &alc883_capture_source,
9396 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9397 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009398 },
9399 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009400 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009401 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9402 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9403 .dac_nids = alc883_dac_nids,
9404 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009405 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9406 .channel_mode = alc883_3ST_2ch_modes,
9407 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009408 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009409 .setup = alc883_haier_w66_setup,
9410 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009411 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009412 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009413 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009414 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009415 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9416 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009417 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9418 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009419 .need_dac_fix = 1,
9420 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009421 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009422 .setup = alc888_3st_hp_setup,
9423 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009424 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009425 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009426 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009427 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9428 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9429 .dac_nids = alc883_dac_nids,
9430 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009431 .dig_in_nid = ALC883_DIGIN_NID,
9432 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9433 .channel_mode = alc883_sixstack_modes,
9434 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009435 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009436 .setup = alc888_6st_dell_setup,
9437 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009438 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009439 [ALC883_MITAC] = {
9440 .mixers = { alc883_mitac_mixer },
9441 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9443 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009444 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9445 .channel_mode = alc883_3ST_2ch_modes,
9446 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009447 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009448 .setup = alc883_mitac_setup,
9449 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009450 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009451 [ALC883_FUJITSU_PI2515] = {
9452 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9453 .init_verbs = { alc883_init_verbs,
9454 alc883_2ch_fujitsu_pi2515_verbs},
9455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9456 .dac_nids = alc883_dac_nids,
9457 .dig_out_nid = ALC883_DIGOUT_NID,
9458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9459 .channel_mode = alc883_3ST_2ch_modes,
9460 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009461 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009462 .setup = alc883_2ch_fujitsu_pi2515_setup,
9463 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009464 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009465 [ALC888_FUJITSU_XA3530] = {
9466 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9467 .init_verbs = { alc883_init_verbs,
9468 alc888_fujitsu_xa3530_verbs },
9469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9470 .dac_nids = alc883_dac_nids,
9471 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9472 .adc_nids = alc883_adc_nids_rev,
9473 .capsrc_nids = alc883_capsrc_nids_rev,
9474 .dig_out_nid = ALC883_DIGOUT_NID,
9475 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9476 .channel_mode = alc888_4ST_8ch_intel_modes,
9477 .num_mux_defs =
9478 ARRAY_SIZE(alc888_2_capture_sources),
9479 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009480 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009481 .setup = alc888_fujitsu_xa3530_setup,
9482 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009483 },
Kailang Yange2757d52008-08-26 13:17:46 +02009484 [ALC888_LENOVO_SKY] = {
9485 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9486 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9487 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9488 .dac_nids = alc883_dac_nids,
9489 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009490 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9491 .channel_mode = alc883_sixstack_modes,
9492 .need_dac_fix = 1,
9493 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009494 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009495 .setup = alc888_lenovo_sky_setup,
9496 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009497 },
9498 [ALC888_ASUS_M90V] = {
9499 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9500 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9501 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9502 .dac_nids = alc883_dac_nids,
9503 .dig_out_nid = ALC883_DIGOUT_NID,
9504 .dig_in_nid = ALC883_DIGIN_NID,
9505 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9506 .channel_mode = alc883_3ST_6ch_modes,
9507 .need_dac_fix = 1,
9508 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009509 .unsol_event = alc_sku_unsol_event,
9510 .setup = alc883_mode2_setup,
9511 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009512 },
9513 [ALC888_ASUS_EEE1601] = {
9514 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009515 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009516 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9517 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9518 .dac_nids = alc883_dac_nids,
9519 .dig_out_nid = ALC883_DIGOUT_NID,
9520 .dig_in_nid = ALC883_DIGIN_NID,
9521 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9522 .channel_mode = alc883_3ST_2ch_modes,
9523 .need_dac_fix = 1,
9524 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009525 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009526 .init_hook = alc883_eee1601_inithook,
9527 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009528 [ALC1200_ASUS_P5Q] = {
9529 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9530 .init_verbs = { alc883_init_verbs },
9531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9532 .dac_nids = alc883_dac_nids,
9533 .dig_out_nid = ALC1200_DIGOUT_NID,
9534 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009535 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009536 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9537 .channel_mode = alc883_sixstack_modes,
9538 .input_mux = &alc883_capture_source,
9539 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009540 [ALC889A_MB31] = {
9541 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9542 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9543 alc880_gpio1_init_verbs },
9544 .adc_nids = alc883_adc_nids,
9545 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9546 .dac_nids = alc883_dac_nids,
9547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9548 .channel_mode = alc889A_mb31_6ch_modes,
9549 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9550 .input_mux = &alc889A_mb31_capture_source,
9551 .dig_out_nid = ALC883_DIGOUT_NID,
9552 .unsol_event = alc889A_mb31_unsol_event,
9553 .init_hook = alc889A_mb31_automute,
9554 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009555 [ALC883_SONY_VAIO_TT] = {
9556 .mixers = { alc883_vaiott_mixer },
9557 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9559 .dac_nids = alc883_dac_nids,
9560 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9561 .channel_mode = alc883_3ST_2ch_modes,
9562 .input_mux = &alc883_capture_source,
9563 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009564 .setup = alc883_vaiott_setup,
9565 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009566 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009567};
9568
9569
9570/*
Takashi Iwai49535502009-06-30 15:28:30 +02009571 * Pin config fixes
9572 */
9573enum {
9574 PINFIX_ABIT_AW9D_MAX
9575};
9576
9577static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9578 { 0x15, 0x01080104 }, /* side */
9579 { 0x16, 0x01011012 }, /* rear */
9580 { 0x17, 0x01016011 }, /* clfe */
9581 { }
9582};
9583
9584static const struct alc_pincfg *alc882_pin_fixes[] = {
9585 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9586};
9587
9588static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9589 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9590 {}
9591};
9592
9593/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009594 * BIOS auto configuration
9595 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009596static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9597 const struct auto_pin_cfg *cfg)
9598{
9599 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9600}
9601
Takashi Iwai49535502009-06-30 15:28:30 +02009602static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009603 hda_nid_t nid, int pin_type,
9604 int dac_idx)
9605{
9606 /* set as output */
9607 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009608 int idx;
9609
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009610 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009611 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9612 idx = 4;
9613 else
9614 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009615 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9616
9617}
9618
Takashi Iwai49535502009-06-30 15:28:30 +02009619static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009620{
9621 struct alc_spec *spec = codec->spec;
9622 int i;
9623
9624 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009625 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009626 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009627 if (nid)
Takashi Iwai49535502009-06-30 15:28:30 +02009628 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009629 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009630 }
9631}
9632
Takashi Iwai49535502009-06-30 15:28:30 +02009633static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009634{
9635 struct alc_spec *spec = codec->spec;
9636 hda_nid_t pin;
9637
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009638 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009639 if (pin) /* connect to front */
9640 /* use dac 0 */
Takashi Iwai49535502009-06-30 15:28:30 +02009641 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009642 pin = spec->autocfg.speaker_pins[0];
9643 if (pin)
Takashi Iwai49535502009-06-30 15:28:30 +02009644 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009645}
9646
Takashi Iwai49535502009-06-30 15:28:30 +02009647static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009648{
9649 struct alc_spec *spec = codec->spec;
9650 int i;
9651
9652 for (i = 0; i < AUTO_PIN_LAST; i++) {
9653 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai49535502009-06-30 15:28:30 +02009654 if (!nid)
9655 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009656 alc_set_input_pin(codec, nid, i);
Takashi Iwai49535502009-06-30 15:28:30 +02009657 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9658 snd_hda_codec_write(codec, nid, 0,
9659 AC_VERB_SET_AMP_GAIN_MUTE,
9660 AMP_OUT_MUTE);
9661 }
9662}
9663
9664static void alc882_auto_init_input_src(struct hda_codec *codec)
9665{
9666 struct alc_spec *spec = codec->spec;
9667 int c;
9668
9669 for (c = 0; c < spec->num_adc_nids; c++) {
9670 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9671 hda_nid_t nid = spec->capsrc_nids[c];
9672 unsigned int mux_idx;
9673 const struct hda_input_mux *imux;
9674 int conns, mute, idx, item;
9675
9676 conns = snd_hda_get_connections(codec, nid, conn_list,
9677 ARRAY_SIZE(conn_list));
9678 if (conns < 0)
9679 continue;
9680 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9681 imux = &spec->input_mux[mux_idx];
9682 for (idx = 0; idx < conns; idx++) {
9683 /* if the current connection is the selected one,
9684 * unmute it as default - otherwise mute it
9685 */
9686 mute = AMP_IN_MUTE(idx);
9687 for (item = 0; item < imux->num_items; item++) {
9688 if (imux->items[item].index == idx) {
9689 if (spec->cur_mux[c] == item)
9690 mute = AMP_IN_UNMUTE(idx);
9691 break;
9692 }
9693 }
9694 /* check if we have a selector or mixer
9695 * we could check for the widget type instead, but
9696 * just check for Amp-In presence (in case of mixer
9697 * without amp-in there is something wrong, this
9698 * function shouldn't be used or capsrc nid is wrong)
9699 */
9700 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009701 snd_hda_codec_write(codec, nid, 0,
9702 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai49535502009-06-30 15:28:30 +02009703 mute);
9704 else if (mute != AMP_IN_MUTE(idx))
9705 snd_hda_codec_write(codec, nid, 0,
9706 AC_VERB_SET_CONNECT_SEL,
9707 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009708 }
9709 }
9710}
9711
Takashi Iwai49535502009-06-30 15:28:30 +02009712/* add mic boosts if needed */
9713static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009714{
9715 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +02009716 int err;
9717 hda_nid_t nid;
9718
9719 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9720 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9721 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9722 "Mic Boost",
9723 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9724 if (err < 0)
9725 return err;
9726 }
9727 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9728 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9729 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9730 "Front Mic Boost",
9731 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9732 if (err < 0)
9733 return err;
9734 }
9735 return 0;
9736}
9737
9738/* almost identical with ALC880 parser... */
9739static int alc882_parse_auto_config(struct hda_codec *codec)
9740{
9741 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009742 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9743 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009744
Takashi Iwai05f5f472009-08-25 13:10:18 +02009745 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9746 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009747 if (err < 0)
9748 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009749 if (!spec->autocfg.line_outs)
9750 return 0; /* can't find valid BIOS pin config */
9751
9752 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9753 if (err < 0)
9754 return err;
9755 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9756 if (err < 0)
9757 return err;
9758 err = alc880_auto_create_extra_out(spec,
9759 spec->autocfg.speaker_pins[0],
9760 "Speaker");
9761 if (err < 0)
9762 return err;
9763 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9764 "Headphone");
9765 if (err < 0)
9766 return err;
9767 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9768 if (err < 0)
9769 return err;
9770
9771 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9772
9773 /* check multiple SPDIF-out (for recent codecs) */
9774 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9775 hda_nid_t dig_nid;
9776 err = snd_hda_get_connections(codec,
9777 spec->autocfg.dig_out_pins[i],
9778 &dig_nid, 1);
9779 if (err < 0)
9780 continue;
9781 if (!i)
9782 spec->multiout.dig_out_nid = dig_nid;
9783 else {
9784 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9785 spec->slave_dig_outs[i - 1] = dig_nid;
9786 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9787 break;
9788 }
9789 }
9790 if (spec->autocfg.dig_in_pin)
9791 spec->dig_in_nid = ALC880_DIGIN_NID;
9792
9793 if (spec->kctls.list)
9794 add_mixer(spec, spec->kctls.list);
9795
9796 add_verb(spec, alc883_auto_init_verbs);
9797 /* if ADC 0x07 is available, initialize it, too */
9798 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9799 add_verb(spec, alc882_adc1_init_verbs);
9800
9801 spec->num_mux_defs = 1;
9802 spec->input_mux = &spec->private_imux[0];
9803
9804 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009805
9806 err = alc_auto_add_mic_boost(codec);
9807 if (err < 0)
9808 return err;
9809
Takashi Iwai776e1842007-08-29 15:07:11 +02009810 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009811}
9812
9813/* additional initialization for auto-configuration model */
Takashi Iwai49535502009-06-30 15:28:30 +02009814static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009815{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009816 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +02009817 alc882_auto_init_multi_out(codec);
9818 alc882_auto_init_hp_out(codec);
9819 alc882_auto_init_analog_input(codec);
9820 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009821 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009822 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009823}
9824
Takashi Iwai49535502009-06-30 15:28:30 +02009825static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009826{
9827 struct alc_spec *spec;
9828 int err, board_config;
9829
9830 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9831 if (spec == NULL)
9832 return -ENOMEM;
9833
9834 codec->spec = spec;
9835
Takashi Iwai49535502009-06-30 15:28:30 +02009836 switch (codec->vendor_id) {
9837 case 0x10ec0882:
9838 case 0x10ec0885:
9839 break;
9840 default:
9841 /* ALC883 and variants */
9842 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9843 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009844 }
9845
Takashi Iwai49535502009-06-30 15:28:30 +02009846 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9847 alc882_models,
9848 alc882_cfg_tbl);
9849
9850 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9851 board_config = snd_hda_check_board_codec_sid_config(codec,
9852 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9853
9854 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009855 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai49535502009-06-30 15:28:30 +02009856 codec->chip_name);
9857 board_config = ALC882_AUTO;
9858 }
9859
9860 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9861
9862 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009863 /* automatic parse from the BIOS config */
Takashi Iwai49535502009-06-30 15:28:30 +02009864 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009865 if (err < 0) {
9866 alc_free(codec);
9867 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009868 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009869 printk(KERN_INFO
9870 "hda_codec: Cannot set up configuration "
9871 "from BIOS. Using base mode...\n");
Takashi Iwai49535502009-06-30 15:28:30 +02009872 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009873 }
9874 }
9875
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009876 err = snd_hda_attach_beep_device(codec, 0x1);
9877 if (err < 0) {
9878 alc_free(codec);
9879 return err;
9880 }
9881
Takashi Iwai49535502009-06-30 15:28:30 +02009882 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009883 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009884
Takashi Iwai49535502009-06-30 15:28:30 +02009885 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9886 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9887 /* FIXME: setup DAC5 */
9888 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9889 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9890
9891 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9892 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9893
9894 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009895 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai49535502009-06-30 15:28:30 +02009896
9897 if (!spec->adc_nids && spec->input_mux) {
9898 int i;
9899 spec->num_adc_nids = 0;
9900 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9901 hda_nid_t cap;
9902 hda_nid_t nid = alc882_adc_nids[i];
9903 unsigned int wcap = get_wcaps(codec, nid);
9904 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009905 wcap = get_wcaps_type(wcap);
Takashi Iwai49535502009-06-30 15:28:30 +02009906 if (wcap != AC_WID_AUD_IN)
9907 continue;
9908 spec->private_adc_nids[spec->num_adc_nids] = nid;
9909 err = snd_hda_get_connections(codec, nid, &cap, 1);
9910 if (err < 0)
9911 continue;
9912 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9913 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009914 }
Takashi Iwai49535502009-06-30 15:28:30 +02009915 spec->adc_nids = spec->private_adc_nids;
9916 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009917 }
9918
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009919 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009920 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009921
Takashi Iwai2134ea42008-01-10 16:53:55 +01009922 spec->vmaster_nid = 0x0c;
9923
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009924 codec->patch_ops = alc_patch_ops;
Takashi Iwai49535502009-06-30 15:28:30 +02009925 if (board_config == ALC882_AUTO)
9926 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009927#ifdef CONFIG_SND_HDA_POWER_SAVE
9928 if (!spec->loopback.amplist)
Takashi Iwai49535502009-06-30 15:28:30 +02009929 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009930#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009931 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009932
9933 return 0;
9934}
9935
Takashi Iwai49535502009-06-30 15:28:30 +02009936
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009937/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009938 * ALC262 support
9939 */
9940
9941#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9942#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9943
9944#define alc262_dac_nids alc260_dac_nids
9945#define alc262_adc_nids alc882_adc_nids
9946#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009947#define alc262_capsrc_nids alc882_capsrc_nids
9948#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009949
9950#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009951#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009952
Kailang Yang4e555fe2008-08-26 13:05:55 +02009953static hda_nid_t alc262_dmic_adc_nids[1] = {
9954 /* ADC0 */
9955 0x09
9956};
9957
9958static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9959
Kailang Yangdf694da2005-12-05 19:42:22 +01009960static struct snd_kcontrol_new alc262_base_mixer[] = {
9961 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9962 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9963 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9964 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9965 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9966 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9968 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009969 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009970 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9971 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009972 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009973 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9975 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9976 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009977 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009978};
9979
Takashi Iwaice875f02008-01-28 18:17:43 +01009980/* update HP, line and mono-out pins according to the master switch */
9981static void alc262_hp_master_update(struct hda_codec *codec)
9982{
9983 struct alc_spec *spec = codec->spec;
9984 int val = spec->master_sw;
9985
9986 /* HP & line-out */
9987 snd_hda_codec_write_cache(codec, 0x1b, 0,
9988 AC_VERB_SET_PIN_WIDGET_CONTROL,
9989 val ? PIN_HP : 0);
9990 snd_hda_codec_write_cache(codec, 0x15, 0,
9991 AC_VERB_SET_PIN_WIDGET_CONTROL,
9992 val ? PIN_HP : 0);
9993 /* mono (speaker) depending on the HP jack sense */
9994 val = val && !spec->jack_present;
9995 snd_hda_codec_write_cache(codec, 0x16, 0,
9996 AC_VERB_SET_PIN_WIDGET_CONTROL,
9997 val ? PIN_OUT : 0);
9998}
9999
10000static void alc262_hp_bpc_automute(struct hda_codec *codec)
10001{
10002 struct alc_spec *spec = codec->spec;
10003 unsigned int presence;
10004 presence = snd_hda_codec_read(codec, 0x1b, 0,
10005 AC_VERB_GET_PIN_SENSE, 0);
10006 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10007 alc262_hp_master_update(codec);
10008}
10009
10010static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10011{
10012 if ((res >> 26) != ALC880_HP_EVENT)
10013 return;
10014 alc262_hp_bpc_automute(codec);
10015}
10016
10017static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10018{
10019 struct alc_spec *spec = codec->spec;
10020 unsigned int presence;
10021 presence = snd_hda_codec_read(codec, 0x15, 0,
10022 AC_VERB_GET_PIN_SENSE, 0);
10023 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10024 alc262_hp_master_update(codec);
10025}
10026
10027static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10028 unsigned int res)
10029{
10030 if ((res >> 26) != ALC880_HP_EVENT)
10031 return;
10032 alc262_hp_wildwest_automute(codec);
10033}
10034
Takashi Iwaib72519b2009-05-08 14:31:55 +020010035#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010036
10037static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10038 struct snd_ctl_elem_value *ucontrol)
10039{
10040 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10041 struct alc_spec *spec = codec->spec;
10042 int val = !!*ucontrol->value.integer.value;
10043
10044 if (val == spec->master_sw)
10045 return 0;
10046 spec->master_sw = val;
10047 alc262_hp_master_update(codec);
10048 return 1;
10049}
10050
Takashi Iwaib72519b2009-05-08 14:31:55 +020010051#define ALC262_HP_MASTER_SWITCH \
10052 { \
10053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10054 .name = "Master Playback Switch", \
10055 .info = snd_ctl_boolean_mono_info, \
10056 .get = alc262_hp_master_sw_get, \
10057 .put = alc262_hp_master_sw_put, \
10058 }
10059
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010060static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010061 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010062 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10063 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010065 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10066 HDA_OUTPUT),
10067 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10068 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010071 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010072 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10073 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010074 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010075 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10076 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010079 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10080 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10081 { } /* end */
10082};
10083
Kailang Yangcd7509a2007-01-26 18:33:17 +010010084static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010085 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10087 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10088 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010090 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10091 HDA_OUTPUT),
10092 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10093 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010094 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10095 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010096 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10099 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10100 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010101 { } /* end */
10102};
10103
10104static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10105 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10106 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010107 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010108 { } /* end */
10109};
10110
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010111/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010112static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010113{
10114 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010115
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010116 spec->autocfg.hp_pins[0] = 0x15;
10117 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010118}
10119
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010120static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010121 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10122 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010123 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10127 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10128 { } /* end */
10129};
10130
10131static struct hda_verb alc262_hp_t5735_verbs[] = {
10132 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10133 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10134
10135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10136 { }
10137};
10138
Kailang Yang8c427222008-01-10 13:03:59 +010010139static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010140 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010142 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10143 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10146 { } /* end */
10147};
10148
10149static struct hda_verb alc262_hp_rp5700_verbs[] = {
10150 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10151 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10152 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10153 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10154 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10155 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10160 {}
10161};
10162
10163static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10164 .num_items = 1,
10165 .items = {
10166 { "Line", 0x1 },
10167 },
10168};
10169
Takashi Iwai42171c12009-05-08 14:11:43 +020010170/* bind hp and internal speaker mute (with plug check) as master switch */
10171static void alc262_hippo_master_update(struct hda_codec *codec)
10172{
10173 struct alc_spec *spec = codec->spec;
10174 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10175 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10176 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10177 unsigned int mute;
10178
10179 /* HP */
10180 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10181 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10182 HDA_AMP_MUTE, mute);
10183 /* mute internal speaker per jack sense */
10184 if (spec->jack_present)
10185 mute = HDA_AMP_MUTE;
10186 if (line_nid)
10187 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10188 HDA_AMP_MUTE, mute);
10189 if (speaker_nid && speaker_nid != line_nid)
10190 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10191 HDA_AMP_MUTE, mute);
10192}
10193
10194#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10195
10196static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10197 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010198{
10199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010200 struct alc_spec *spec = codec->spec;
10201 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010202
Takashi Iwai42171c12009-05-08 14:11:43 +020010203 if (val == spec->master_sw)
10204 return 0;
10205 spec->master_sw = val;
10206 alc262_hippo_master_update(codec);
10207 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010208}
Takashi Iwai5b319542007-07-26 11:49:22 +020010209
Takashi Iwai42171c12009-05-08 14:11:43 +020010210#define ALC262_HIPPO_MASTER_SWITCH \
10211 { \
10212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10213 .name = "Master Playback Switch", \
10214 .info = snd_ctl_boolean_mono_info, \
10215 .get = alc262_hippo_master_sw_get, \
10216 .put = alc262_hippo_master_sw_put, \
10217 }
10218
10219static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10220 ALC262_HIPPO_MASTER_SWITCH,
10221 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10227 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10228 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10229 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10230 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10231 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10232 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10233 { } /* end */
10234};
10235
10236static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10237 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10238 ALC262_HIPPO_MASTER_SWITCH,
10239 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10240 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10245 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10246 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10248 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10249 { } /* end */
10250};
10251
10252/* mute/unmute internal speaker according to the hp jack and mute state */
10253static void alc262_hippo_automute(struct hda_codec *codec)
10254{
10255 struct alc_spec *spec = codec->spec;
10256 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10257 unsigned int present;
10258
10259 /* need to execute and sync at first */
10260 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10261 present = snd_hda_codec_read(codec, hp_nid, 0,
10262 AC_VERB_GET_PIN_SENSE, 0);
10263 spec->jack_present = (present & 0x80000000) != 0;
10264 alc262_hippo_master_update(codec);
10265}
10266
10267static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10268{
10269 if ((res >> 26) != ALC880_HP_EVENT)
10270 return;
10271 alc262_hippo_automute(codec);
10272}
10273
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010274static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010275{
10276 struct alc_spec *spec = codec->spec;
10277
10278 spec->autocfg.hp_pins[0] = 0x15;
10279 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010280}
10281
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010282static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010283{
10284 struct alc_spec *spec = codec->spec;
10285
10286 spec->autocfg.hp_pins[0] = 0x1b;
10287 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010288}
10289
10290
Kailang Yang272a5272007-05-14 11:00:38 +020010291static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010292 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010293 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10296 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10297 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10298 { } /* end */
10299};
10300
Kailang Yang83c34212007-07-05 11:43:05 +020010301static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010302 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10303 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10307 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10308 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10309 { } /* end */
10310};
Kailang Yang272a5272007-05-14 11:00:38 +020010311
Tony Vroonba340e82009-02-02 19:01:30 +000010312static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10313 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10314 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10315 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10316 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10318 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10321 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10322 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10323 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10324 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10325 { } /* end */
10326};
10327
10328static struct hda_verb alc262_tyan_verbs[] = {
10329 /* Headphone automute */
10330 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10331 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10333
10334 /* P11 AUX_IN, white 4-pin connector */
10335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10336 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10337 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10338 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10339
10340 {}
10341};
10342
10343/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010344static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010345{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010346 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010347
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010348 spec->autocfg.hp_pins[0] = 0x1b;
10349 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010350}
10351
Tony Vroonba340e82009-02-02 19:01:30 +000010352
Kailang Yangdf694da2005-12-05 19:42:22 +010010353#define alc262_capture_mixer alc882_capture_mixer
10354#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10355
10356/*
10357 * generic initialization of ADC, input mixers and output mixers
10358 */
10359static struct hda_verb alc262_init_verbs[] = {
10360 /*
10361 * Unmute ADC0-2 and set the default input to mic-in
10362 */
10363 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10365 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10366 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10367 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10369
Takashi Iwaicb53c622007-08-10 17:21:45 +020010370 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010371 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010372 * Note: PASD motherboards uses the Line In 2 as the input for
10373 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010374 */
10375 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010381
10382 /*
10383 * Set up output mixers (0x0c - 0x0e)
10384 */
10385 /* set vol=0 to output mixers */
10386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10389 /* set up input amps for analog loopback */
10390 /* Amp Indices: DAC = 0, mixer = 1 */
10391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10397
10398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10400 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10402 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10403 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10404
10405 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10406 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10407 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10408 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10409 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010410
Kailang Yangdf694da2005-12-05 19:42:22 +010010411 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10412 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010413
Kailang Yangdf694da2005-12-05 19:42:22 +010010414 /* FIXME: use matrix-type input source selection */
10415 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10416 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10420 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10421 /* Input mixer2 */
10422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10425 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10426 /* Input mixer3 */
10427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010431
10432 { }
10433};
10434
Kailang Yang4e555fe2008-08-26 13:05:55 +020010435static struct hda_verb alc262_eapd_verbs[] = {
10436 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10437 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10438 { }
10439};
10440
Kailang Yangccc656c2006-10-17 12:32:26 +020010441static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10442 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10443 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10445
10446 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10447 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10448 {}
10449};
10450
Kailang Yang272a5272007-05-14 11:00:38 +020010451static struct hda_verb alc262_sony_unsol_verbs[] = {
10452 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10455
10456 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10457 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010458 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010459};
10460
Kailang Yang4e555fe2008-08-26 13:05:55 +020010461static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10462 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10463 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010467 { } /* end */
10468};
10469
10470static struct hda_verb alc262_toshiba_s06_verbs[] = {
10471 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10474 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10475 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10477 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10478 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10479 {}
10480};
10481
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010482static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010483{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010484 struct alc_spec *spec = codec->spec;
10485
10486 spec->autocfg.hp_pins[0] = 0x15;
10487 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010488 spec->ext_mic.pin = 0x18;
10489 spec->ext_mic.mux_idx = 0;
10490 spec->int_mic.pin = 0x12;
10491 spec->int_mic.mux_idx = 9;
10492 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010493}
10494
Takashi Iwai834be882006-03-01 14:16:17 +010010495/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010496 * nec model
10497 * 0x15 = headphone
10498 * 0x16 = internal speaker
10499 * 0x18 = external mic
10500 */
10501
10502static struct snd_kcontrol_new alc262_nec_mixer[] = {
10503 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10504 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10505
10506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10509
10510 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10512 { } /* end */
10513};
10514
10515static struct hda_verb alc262_nec_verbs[] = {
10516 /* Unmute Speaker */
10517 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10518
10519 /* Headphone */
10520 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10522
10523 /* External mic to headphone */
10524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10525 /* External mic to speaker */
10526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10527 {}
10528};
10529
10530/*
Takashi Iwai834be882006-03-01 14:16:17 +010010531 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010532 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10533 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010534 */
10535
10536#define ALC_HP_EVENT 0x37
10537
10538static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10539 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010541 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10542 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010543 {}
10544};
10545
Jiang zhe0e31daf2008-03-20 12:12:39 +010010546static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10547 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10549 {}
10550};
10551
Takashi Iwai834be882006-03-01 14:16:17 +010010552static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010553 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010554 .items = {
10555 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010556 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010557 { "CD", 0x4 },
10558 },
10559};
10560
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010561static struct hda_input_mux alc262_HP_capture_source = {
10562 .num_items = 5,
10563 .items = {
10564 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010565 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010566 { "Line", 0x2 },
10567 { "CD", 0x4 },
10568 { "AUX IN", 0x6 },
10569 },
10570};
10571
zhejiangaccbe492007-08-31 12:36:05 +020010572static struct hda_input_mux alc262_HP_D7000_capture_source = {
10573 .num_items = 4,
10574 .items = {
10575 { "Mic", 0x0 },
10576 { "Front Mic", 0x2 },
10577 { "Line", 0x1 },
10578 { "CD", 0x4 },
10579 },
10580};
10581
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010582/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010583static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10584{
10585 struct alc_spec *spec = codec->spec;
10586 unsigned int mute;
10587
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010588 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010589 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010590 /* need to execute and sync at first */
10591 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010592 /* check laptop HP jack */
10593 present = snd_hda_codec_read(codec, 0x14, 0,
10594 AC_VERB_GET_PIN_SENSE, 0);
10595 /* need to execute and sync at first */
10596 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10597 /* check docking HP jack */
10598 present |= snd_hda_codec_read(codec, 0x1b, 0,
10599 AC_VERB_GET_PIN_SENSE, 0);
10600 if (present & AC_PINSENSE_PRESENCE)
10601 spec->jack_present = 1;
10602 else
10603 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010604 spec->sense_updated = 1;
10605 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010606 /* unmute internal speaker only if both HPs are unplugged and
10607 * master switch is on
10608 */
10609 if (spec->jack_present)
10610 mute = HDA_AMP_MUTE;
10611 else
Takashi Iwai834be882006-03-01 14:16:17 +010010612 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010613 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10614 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010615}
10616
10617/* unsolicited event for HP jack sensing */
10618static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10619 unsigned int res)
10620{
10621 if ((res >> 26) != ALC_HP_EVENT)
10622 return;
10623 alc262_fujitsu_automute(codec, 1);
10624}
10625
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010626static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10627{
10628 alc262_fujitsu_automute(codec, 1);
10629}
10630
Takashi Iwai834be882006-03-01 14:16:17 +010010631/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010632static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10633 .ops = &snd_hda_bind_vol,
10634 .values = {
10635 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10636 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10637 0
10638 },
10639};
Takashi Iwai834be882006-03-01 14:16:17 +010010640
Jiang zhe0e31daf2008-03-20 12:12:39 +010010641/* mute/unmute internal speaker according to the hp jack and mute state */
10642static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10643{
10644 struct alc_spec *spec = codec->spec;
10645 unsigned int mute;
10646
10647 if (force || !spec->sense_updated) {
10648 unsigned int present_int_hp;
10649 /* need to execute and sync at first */
10650 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10651 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10652 AC_VERB_GET_PIN_SENSE, 0);
10653 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10654 spec->sense_updated = 1;
10655 }
10656 if (spec->jack_present) {
10657 /* mute internal speaker */
10658 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10659 HDA_AMP_MUTE, HDA_AMP_MUTE);
10660 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10661 HDA_AMP_MUTE, HDA_AMP_MUTE);
10662 } else {
10663 /* unmute internal speaker if necessary */
10664 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10665 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10666 HDA_AMP_MUTE, mute);
10667 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10668 HDA_AMP_MUTE, mute);
10669 }
10670}
10671
10672/* unsolicited event for HP jack sensing */
10673static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10674 unsigned int res)
10675{
10676 if ((res >> 26) != ALC_HP_EVENT)
10677 return;
10678 alc262_lenovo_3000_automute(codec, 1);
10679}
10680
Takashi Iwai8de56b72009-07-24 16:51:47 +020010681static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10682 int dir, int idx, long *valp)
10683{
10684 int i, change = 0;
10685
10686 for (i = 0; i < 2; i++, valp++)
10687 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10688 HDA_AMP_MUTE,
10689 *valp ? 0 : HDA_AMP_MUTE);
10690 return change;
10691}
10692
Takashi Iwai834be882006-03-01 14:16:17 +010010693/* bind hp and internal speaker mute (with plug check) */
10694static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10695 struct snd_ctl_elem_value *ucontrol)
10696{
10697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10698 long *valp = ucontrol->value.integer.value;
10699 int change;
10700
Takashi Iwai8de56b72009-07-24 16:51:47 +020010701 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10702 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010703 if (change)
10704 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010705 return change;
10706}
10707
10708static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010709 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010710 {
10711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10712 .name = "Master Playback Switch",
10713 .info = snd_hda_mixer_amp_switch_info,
10714 .get = snd_hda_mixer_amp_switch_get,
10715 .put = alc262_fujitsu_master_sw_put,
10716 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10717 },
10718 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10719 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010723 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10724 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10725 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010726 { } /* end */
10727};
10728
Jiang zhe0e31daf2008-03-20 12:12:39 +010010729/* bind hp and internal speaker mute (with plug check) */
10730static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10731 struct snd_ctl_elem_value *ucontrol)
10732{
10733 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10734 long *valp = ucontrol->value.integer.value;
10735 int change;
10736
Takashi Iwai8de56b72009-07-24 16:51:47 +020010737 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010738 if (change)
10739 alc262_lenovo_3000_automute(codec, 0);
10740 return change;
10741}
10742
10743static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10744 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10745 {
10746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10747 .name = "Master Playback Switch",
10748 .info = snd_hda_mixer_amp_switch_info,
10749 .get = snd_hda_mixer_amp_switch_get,
10750 .put = alc262_lenovo_3000_master_sw_put,
10751 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10752 },
10753 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10754 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10758 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10759 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10760 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10761 { } /* end */
10762};
10763
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010764static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10765 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010766 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10769 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10770 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10771 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10772 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10773 { } /* end */
10774};
10775
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010776/* additional init verbs for Benq laptops */
10777static struct hda_verb alc262_EAPD_verbs[] = {
10778 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10779 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10780 {}
10781};
10782
Kailang Yang83c34212007-07-05 11:43:05 +020010783static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10786
10787 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10788 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10789 {}
10790};
10791
Tobin Davisf651b502007-10-26 12:40:47 +020010792/* Samsung Q1 Ultra Vista model setup */
10793static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010794 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10795 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10798 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010799 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010800 { } /* end */
10801};
10802
10803static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010804 /* output mixer */
10805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10808 /* speaker */
10809 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10810 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10812 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10813 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10818 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10819 /* internal mic */
10820 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10821 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10822 /* ADC, choose mic */
10823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10824 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10825 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10826 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10827 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10828 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10829 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10831 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10832 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010833 {}
10834};
10835
Tobin Davisf651b502007-10-26 12:40:47 +020010836/* mute/unmute internal speaker according to the hp jack and mute state */
10837static void alc262_ultra_automute(struct hda_codec *codec)
10838{
10839 struct alc_spec *spec = codec->spec;
10840 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010841
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010842 mute = 0;
10843 /* auto-mute only when HP is used as HP */
10844 if (!spec->cur_mux[0]) {
10845 unsigned int present;
10846 /* need to execute and sync at first */
10847 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10848 present = snd_hda_codec_read(codec, 0x15, 0,
10849 AC_VERB_GET_PIN_SENSE, 0);
10850 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10851 if (spec->jack_present)
10852 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010853 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010854 /* mute/unmute internal speaker */
10855 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10856 HDA_AMP_MUTE, mute);
10857 /* mute/unmute HP */
10858 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10859 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010860}
10861
10862/* unsolicited event for HP jack sensing */
10863static void alc262_ultra_unsol_event(struct hda_codec *codec,
10864 unsigned int res)
10865{
10866 if ((res >> 26) != ALC880_HP_EVENT)
10867 return;
10868 alc262_ultra_automute(codec);
10869}
10870
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010871static struct hda_input_mux alc262_ultra_capture_source = {
10872 .num_items = 2,
10873 .items = {
10874 { "Mic", 0x1 },
10875 { "Headphone", 0x7 },
10876 },
10877};
10878
10879static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10880 struct snd_ctl_elem_value *ucontrol)
10881{
10882 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10883 struct alc_spec *spec = codec->spec;
10884 int ret;
10885
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010886 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010887 if (!ret)
10888 return 0;
10889 /* reprogram the HP pin as mic or HP according to the input source */
10890 snd_hda_codec_write_cache(codec, 0x15, 0,
10891 AC_VERB_SET_PIN_WIDGET_CONTROL,
10892 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10893 alc262_ultra_automute(codec); /* mute/unmute HP */
10894 return ret;
10895}
10896
10897static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10898 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10899 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10900 {
10901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10902 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010903 .info = alc_mux_enum_info,
10904 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010905 .put = alc262_ultra_mux_enum_put,
10906 },
10907 { } /* end */
10908};
10909
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010910/* We use two mixers depending on the output pin; 0x16 is a mono output
10911 * and thus it's bound with a different mixer.
10912 * This function returns which mixer amp should be used.
10913 */
10914static int alc262_check_volbit(hda_nid_t nid)
10915{
10916 if (!nid)
10917 return 0;
10918 else if (nid == 0x16)
10919 return 2;
10920 else
10921 return 1;
10922}
10923
10924static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10925 const char *pfx, int *vbits)
10926{
10927 char name[32];
10928 unsigned long val;
10929 int vbit;
10930
10931 vbit = alc262_check_volbit(nid);
10932 if (!vbit)
10933 return 0;
10934 if (*vbits & vbit) /* a volume control for this mixer already there */
10935 return 0;
10936 *vbits |= vbit;
10937 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10938 if (vbit == 2)
10939 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10940 else
10941 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10942 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10943}
10944
10945static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10946 const char *pfx)
10947{
10948 char name[32];
10949 unsigned long val;
10950
10951 if (!nid)
10952 return 0;
10953 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10954 if (nid == 0x16)
10955 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10956 else
10957 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10958 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10959}
10960
Kailang Yangdf694da2005-12-05 19:42:22 +010010961/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010962static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10963 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010964{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010965 const char *pfx;
10966 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010010967 int err;
10968
10969 spec->multiout.num_dacs = 1; /* only use one dac */
10970 spec->multiout.dac_nids = spec->private_dac_nids;
10971 spec->multiout.dac_nids[0] = 2;
10972
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010973 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
10974 pfx = "Master";
10975 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10976 pfx = "Speaker";
10977 else
10978 pfx = "Front";
10979 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
10980 if (err < 0)
10981 return err;
10982 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
10983 if (err < 0)
10984 return err;
10985 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
10986 if (err < 0)
10987 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010010988
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010989 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
10990 alc262_check_volbit(cfg->speaker_pins[0]) |
10991 alc262_check_volbit(cfg->hp_pins[0]);
10992 if (vbits == 1 || vbits == 2)
10993 pfx = "Master"; /* only one mixer is used */
10994 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10995 pfx = "Speaker";
10996 else
10997 pfx = "Front";
10998 vbits = 0;
10999 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11000 if (err < 0)
11001 return err;
11002 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11003 &vbits);
11004 if (err < 0)
11005 return err;
11006 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11007 &vbits);
11008 if (err < 0)
11009 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011010 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011011}
11012
Takashi Iwai05f5f472009-08-25 13:10:18 +020011013#define alc262_auto_create_input_ctls \
11014 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011015
11016/*
11017 * generic initialization of ADC, input mixers and output mixers
11018 */
11019static struct hda_verb alc262_volume_init_verbs[] = {
11020 /*
11021 * Unmute ADC0-2 and set the default input to mic-in
11022 */
11023 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11025 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11026 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11028 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11029
Takashi Iwaicb53c622007-08-10 17:21:45 +020011030 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011031 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011032 * Note: PASD motherboards uses the Line In 2 as the input for
11033 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011034 */
11035 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011041
11042 /*
11043 * Set up output mixers (0x0c - 0x0f)
11044 */
11045 /* set vol=0 to output mixers */
11046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11048 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011049
Kailang Yangdf694da2005-12-05 19:42:22 +010011050 /* set up input amps for analog loopback */
11051 /* Amp Indices: DAC = 0, mixer = 1 */
11052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11054 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11056 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11058
11059 /* FIXME: use matrix-type input source selection */
11060 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11061 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11066 /* Input mixer2 */
11067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11071 /* Input mixer3 */
11072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11076
11077 { }
11078};
11079
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011080static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11081 /*
11082 * Unmute ADC0-2 and set the default input to mic-in
11083 */
11084 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11086 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11088 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11090
Takashi Iwaicb53c622007-08-10 17:21:45 +020011091 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011092 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011093 * Note: PASD motherboards uses the Line In 2 as the input for
11094 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011095 */
11096 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011104
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011105 /*
11106 * Set up output mixers (0x0c - 0x0e)
11107 */
11108 /* set vol=0 to output mixers */
11109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11112
11113 /* set up input amps for analog loopback */
11114 /* Amp Indices: DAC = 0, mixer = 1 */
11115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11121
Takashi Iwaice875f02008-01-28 18:17:43 +010011122 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011123 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11124 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11125
11126 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11128
11129 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11131
11132 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11133 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11134 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11136 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11137
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011139 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11140 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011142 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11143 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11144
11145
11146 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011147 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11148 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011149 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11151 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11154 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011158 /* Input mixer2 */
11159 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11161 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11162 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11164 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11166 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011168 /* Input mixer3 */
11169 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011170 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011178
Takashi Iwaice875f02008-01-28 18:17:43 +010011179 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11180
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011181 { }
11182};
11183
Kailang Yangcd7509a2007-01-26 18:33:17 +010011184static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11185 /*
11186 * Unmute ADC0-2 and set the default input to mic-in
11187 */
11188 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11190 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11192 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11194
Takashi Iwaicb53c622007-08-10 17:21:45 +020011195 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011196 * mixer widget
11197 * Note: PASD motherboards uses the Line In 2 as the input for front
11198 * panel mic (mic 2)
11199 */
11200 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011209 /*
11210 * Set up output mixers (0x0c - 0x0e)
11211 */
11212 /* set vol=0 to output mixers */
11213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11216
11217 /* set up input amps for analog loopback */
11218 /* Amp Indices: DAC = 0, mixer = 1 */
11219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11225
11226
11227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11228 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11230 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11231 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11233 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11234
11235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11237
11238 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11239 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11240
11241 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11242 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11243 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11245 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11246 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11247
11248 /* FIXME: use matrix-type input source selection */
11249 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11250 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11256 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11258 /* Input mixer2 */
11259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11263 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11264 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11265 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11266 /* Input mixer3 */
11267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11271 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11272 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11274
Takashi Iwaice875f02008-01-28 18:17:43 +010011275 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11276
Kailang Yangcd7509a2007-01-26 18:33:17 +010011277 { }
11278};
11279
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011280static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11281
11282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11283 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11284 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11285
11286 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11287 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11288 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11290
11291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11292 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11294 {}
11295};
11296
11297
Takashi Iwaicb53c622007-08-10 17:21:45 +020011298#ifdef CONFIG_SND_HDA_POWER_SAVE
11299#define alc262_loopbacks alc880_loopbacks
11300#endif
11301
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011302/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011303#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11304#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11305#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11306#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11307
11308/*
11309 * BIOS auto configuration
11310 */
11311static int alc262_parse_auto_config(struct hda_codec *codec)
11312{
11313 struct alc_spec *spec = codec->spec;
11314 int err;
11315 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11316
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011317 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11318 alc262_ignore);
11319 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011320 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011321 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011322 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011323 spec->multiout.max_channels = 2;
11324 spec->no_analog = 1;
11325 goto dig_only;
11326 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011327 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011328 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011329 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11330 if (err < 0)
11331 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011332 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011333 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011334 return err;
11335
11336 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11337
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011338 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011339 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011340 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011341 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011342 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011343 if (spec->autocfg.dig_in_pin)
11344 spec->dig_in_nid = ALC262_DIGIN_NID;
11345
Takashi Iwai603c4012008-07-30 15:01:44 +020011346 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011347 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011348
Takashi Iwaid88897e2008-10-31 15:01:37 +010011349 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011350 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011351 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011352
Takashi Iwai776e1842007-08-29 15:07:11 +020011353 err = alc_auto_add_mic_boost(codec);
11354 if (err < 0)
11355 return err;
11356
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011357 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11358
Kailang Yangdf694da2005-12-05 19:42:22 +010011359 return 1;
11360}
11361
11362#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11363#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11364#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011365#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011366
11367
11368/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011369static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011370{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011371 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011372 alc262_auto_init_multi_out(codec);
11373 alc262_auto_init_hp_out(codec);
11374 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011375 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011376 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011377 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011378}
11379
11380/*
11381 * configuration and preset
11382 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011383static const char *alc262_models[ALC262_MODEL_LAST] = {
11384 [ALC262_BASIC] = "basic",
11385 [ALC262_HIPPO] = "hippo",
11386 [ALC262_HIPPO_1] = "hippo_1",
11387 [ALC262_FUJITSU] = "fujitsu",
11388 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011389 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011390 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011391 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011392 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011393 [ALC262_BENQ_T31] = "benq-t31",
11394 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011395 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011396 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011397 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011398 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011399 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011400 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011401 [ALC262_AUTO] = "auto",
11402};
11403
11404static struct snd_pci_quirk alc262_cfg_tbl[] = {
11405 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011406 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011407 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11408 ALC262_HP_BPC),
11409 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11410 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011411 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11412 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011413 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011414 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011415 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011416 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011417 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011418 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011419 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011420 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011421 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11422 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11423 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011424 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11425 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011426 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011427 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011428 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011429 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011430 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011431 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011432 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11433 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011434 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011435 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011436 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011437 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011438 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011439 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011440 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11441 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011442 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011443 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011444 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011445 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011446 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011447 {}
11448};
11449
11450static struct alc_config_preset alc262_presets[] = {
11451 [ALC262_BASIC] = {
11452 .mixers = { alc262_base_mixer },
11453 .init_verbs = { alc262_init_verbs },
11454 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11455 .dac_nids = alc262_dac_nids,
11456 .hp_nid = 0x03,
11457 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11458 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011459 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011460 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011461 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011462 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011463 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011464 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11465 .dac_nids = alc262_dac_nids,
11466 .hp_nid = 0x03,
11467 .dig_out_nid = ALC262_DIGOUT_NID,
11468 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11469 .channel_mode = alc262_modes,
11470 .input_mux = &alc262_capture_source,
11471 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011472 .setup = alc262_hippo_setup,
11473 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011474 },
11475 [ALC262_HIPPO_1] = {
11476 .mixers = { alc262_hippo1_mixer },
11477 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11478 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11479 .dac_nids = alc262_dac_nids,
11480 .hp_nid = 0x02,
11481 .dig_out_nid = ALC262_DIGOUT_NID,
11482 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11483 .channel_mode = alc262_modes,
11484 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011485 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011486 .setup = alc262_hippo1_setup,
11487 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011488 },
Takashi Iwai834be882006-03-01 14:16:17 +010011489 [ALC262_FUJITSU] = {
11490 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011491 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11492 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011493 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11494 .dac_nids = alc262_dac_nids,
11495 .hp_nid = 0x03,
11496 .dig_out_nid = ALC262_DIGOUT_NID,
11497 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11498 .channel_mode = alc262_modes,
11499 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011500 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011501 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011502 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011503 [ALC262_HP_BPC] = {
11504 .mixers = { alc262_HP_BPC_mixer },
11505 .init_verbs = { alc262_HP_BPC_init_verbs },
11506 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11507 .dac_nids = alc262_dac_nids,
11508 .hp_nid = 0x03,
11509 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11510 .channel_mode = alc262_modes,
11511 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011512 .unsol_event = alc262_hp_bpc_unsol_event,
11513 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011514 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011515 [ALC262_HP_BPC_D7000_WF] = {
11516 .mixers = { alc262_HP_BPC_WildWest_mixer },
11517 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11518 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11519 .dac_nids = alc262_dac_nids,
11520 .hp_nid = 0x03,
11521 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11522 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011523 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011524 .unsol_event = alc262_hp_wildwest_unsol_event,
11525 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011526 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011527 [ALC262_HP_BPC_D7000_WL] = {
11528 .mixers = { alc262_HP_BPC_WildWest_mixer,
11529 alc262_HP_BPC_WildWest_option_mixer },
11530 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11531 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11532 .dac_nids = alc262_dac_nids,
11533 .hp_nid = 0x03,
11534 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11535 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011536 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011537 .unsol_event = alc262_hp_wildwest_unsol_event,
11538 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011539 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011540 [ALC262_HP_TC_T5735] = {
11541 .mixers = { alc262_hp_t5735_mixer },
11542 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11543 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11544 .dac_nids = alc262_dac_nids,
11545 .hp_nid = 0x03,
11546 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11547 .channel_mode = alc262_modes,
11548 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011549 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011550 .setup = alc262_hp_t5735_setup,
11551 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011552 },
11553 [ALC262_HP_RP5700] = {
11554 .mixers = { alc262_hp_rp5700_mixer },
11555 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11556 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11557 .dac_nids = alc262_dac_nids,
11558 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11559 .channel_mode = alc262_modes,
11560 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011561 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011562 [ALC262_BENQ_ED8] = {
11563 .mixers = { alc262_base_mixer },
11564 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11565 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11566 .dac_nids = alc262_dac_nids,
11567 .hp_nid = 0x03,
11568 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11569 .channel_mode = alc262_modes,
11570 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011571 },
Kailang Yang272a5272007-05-14 11:00:38 +020011572 [ALC262_SONY_ASSAMD] = {
11573 .mixers = { alc262_sony_mixer },
11574 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11575 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11576 .dac_nids = alc262_dac_nids,
11577 .hp_nid = 0x02,
11578 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11579 .channel_mode = alc262_modes,
11580 .input_mux = &alc262_capture_source,
11581 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011582 .setup = alc262_hippo_setup,
11583 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011584 },
11585 [ALC262_BENQ_T31] = {
11586 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011587 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11588 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011589 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11590 .dac_nids = alc262_dac_nids,
11591 .hp_nid = 0x03,
11592 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11593 .channel_mode = alc262_modes,
11594 .input_mux = &alc262_capture_source,
11595 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011596 .setup = alc262_hippo_setup,
11597 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011598 },
Tobin Davisf651b502007-10-26 12:40:47 +020011599 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011600 .mixers = { alc262_ultra_mixer },
11601 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011602 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011603 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11604 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011605 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11606 .channel_mode = alc262_modes,
11607 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011608 .adc_nids = alc262_adc_nids, /* ADC0 */
11609 .capsrc_nids = alc262_capsrc_nids,
11610 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011611 .unsol_event = alc262_ultra_unsol_event,
11612 .init_hook = alc262_ultra_automute,
11613 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011614 [ALC262_LENOVO_3000] = {
11615 .mixers = { alc262_lenovo_3000_mixer },
11616 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11617 alc262_lenovo_3000_unsol_verbs },
11618 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11619 .dac_nids = alc262_dac_nids,
11620 .hp_nid = 0x03,
11621 .dig_out_nid = ALC262_DIGOUT_NID,
11622 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11623 .channel_mode = alc262_modes,
11624 .input_mux = &alc262_fujitsu_capture_source,
11625 .unsol_event = alc262_lenovo_3000_unsol_event,
11626 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011627 [ALC262_NEC] = {
11628 .mixers = { alc262_nec_mixer },
11629 .init_verbs = { alc262_nec_verbs },
11630 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11631 .dac_nids = alc262_dac_nids,
11632 .hp_nid = 0x03,
11633 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11634 .channel_mode = alc262_modes,
11635 .input_mux = &alc262_capture_source,
11636 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011637 [ALC262_TOSHIBA_S06] = {
11638 .mixers = { alc262_toshiba_s06_mixer },
11639 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11640 alc262_eapd_verbs },
11641 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11642 .capsrc_nids = alc262_dmic_capsrc_nids,
11643 .dac_nids = alc262_dac_nids,
11644 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011645 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011646 .dig_out_nid = ALC262_DIGOUT_NID,
11647 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11648 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011649 .unsol_event = alc_sku_unsol_event,
11650 .setup = alc262_toshiba_s06_setup,
11651 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011652 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011653 [ALC262_TOSHIBA_RX1] = {
11654 .mixers = { alc262_toshiba_rx1_mixer },
11655 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11656 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11657 .dac_nids = alc262_dac_nids,
11658 .hp_nid = 0x03,
11659 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11660 .channel_mode = alc262_modes,
11661 .input_mux = &alc262_capture_source,
11662 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011663 .setup = alc262_hippo_setup,
11664 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011665 },
Tony Vroonba340e82009-02-02 19:01:30 +000011666 [ALC262_TYAN] = {
11667 .mixers = { alc262_tyan_mixer },
11668 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11669 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11670 .dac_nids = alc262_dac_nids,
11671 .hp_nid = 0x02,
11672 .dig_out_nid = ALC262_DIGOUT_NID,
11673 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11674 .channel_mode = alc262_modes,
11675 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011676 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011677 .setup = alc262_tyan_setup,
11678 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011679 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011680};
11681
11682static int patch_alc262(struct hda_codec *codec)
11683{
11684 struct alc_spec *spec;
11685 int board_config;
11686 int err;
11687
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011688 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011689 if (spec == NULL)
11690 return -ENOMEM;
11691
11692 codec->spec = spec;
11693#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011694 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11695 * under-run
11696 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011697 {
11698 int tmp;
11699 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11700 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11701 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11702 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11703 }
11704#endif
11705
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011706 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11707
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011708 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11709 alc262_models,
11710 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011711
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011712 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011713 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11714 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011715 board_config = ALC262_AUTO;
11716 }
11717
11718 if (board_config == ALC262_AUTO) {
11719 /* automatic parse from the BIOS config */
11720 err = alc262_parse_auto_config(codec);
11721 if (err < 0) {
11722 alc_free(codec);
11723 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011724 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011725 printk(KERN_INFO
11726 "hda_codec: Cannot set up configuration "
11727 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011728 board_config = ALC262_BASIC;
11729 }
11730 }
11731
Takashi Iwai07eba612009-02-19 08:06:35 +010011732 if (!spec->no_analog) {
11733 err = snd_hda_attach_beep_device(codec, 0x1);
11734 if (err < 0) {
11735 alc_free(codec);
11736 return err;
11737 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011738 }
11739
Kailang Yangdf694da2005-12-05 19:42:22 +010011740 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011741 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011742
Kailang Yangdf694da2005-12-05 19:42:22 +010011743 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11744 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011745
Kailang Yangdf694da2005-12-05 19:42:22 +010011746 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11747 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11748
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011749 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011750 int i;
11751 /* check whether the digital-mic has to be supported */
11752 for (i = 0; i < spec->input_mux->num_items; i++) {
11753 if (spec->input_mux->items[i].index >= 9)
11754 break;
11755 }
11756 if (i < spec->input_mux->num_items) {
11757 /* use only ADC0 */
11758 spec->adc_nids = alc262_dmic_adc_nids;
11759 spec->num_adc_nids = 1;
11760 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011761 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011762 /* all analog inputs */
11763 /* check whether NID 0x07 is valid */
11764 unsigned int wcap = get_wcaps(codec, 0x07);
11765
11766 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011767 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011768 if (wcap != AC_WID_AUD_IN) {
11769 spec->adc_nids = alc262_adc_nids_alt;
11770 spec->num_adc_nids =
11771 ARRAY_SIZE(alc262_adc_nids_alt);
11772 spec->capsrc_nids = alc262_capsrc_nids_alt;
11773 } else {
11774 spec->adc_nids = alc262_adc_nids;
11775 spec->num_adc_nids =
11776 ARRAY_SIZE(alc262_adc_nids);
11777 spec->capsrc_nids = alc262_capsrc_nids;
11778 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011779 }
11780 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011781 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011782 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011783 if (!spec->no_analog)
11784 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011785
Takashi Iwai2134ea42008-01-10 16:53:55 +010011786 spec->vmaster_nid = 0x0c;
11787
Kailang Yangdf694da2005-12-05 19:42:22 +010011788 codec->patch_ops = alc_patch_ops;
11789 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011790 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011791#ifdef CONFIG_SND_HDA_POWER_SAVE
11792 if (!spec->loopback.amplist)
11793 spec->loopback.amplist = alc262_loopbacks;
11794#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011795 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011796
Kailang Yangdf694da2005-12-05 19:42:22 +010011797 return 0;
11798}
11799
Kailang Yangdf694da2005-12-05 19:42:22 +010011800/*
Kailang Yanga361d842007-06-05 12:30:55 +020011801 * ALC268 channel source setting (2 channel)
11802 */
11803#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11804#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011805
Kailang Yanga361d842007-06-05 12:30:55 +020011806static hda_nid_t alc268_dac_nids[2] = {
11807 /* front, hp */
11808 0x02, 0x03
11809};
11810
11811static hda_nid_t alc268_adc_nids[2] = {
11812 /* ADC0-1 */
11813 0x08, 0x07
11814};
11815
11816static hda_nid_t alc268_adc_nids_alt[1] = {
11817 /* ADC0 */
11818 0x08
11819};
11820
Takashi Iwaie1406342008-02-11 18:32:32 +010011821static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11822
Kailang Yanga361d842007-06-05 12:30:55 +020011823static struct snd_kcontrol_new alc268_base_mixer[] = {
11824 /* output mixer control */
11825 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11826 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11827 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011829 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11830 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11831 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011832 { }
11833};
11834
Takashi Iwai42171c12009-05-08 14:11:43 +020011835static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11836 /* output mixer control */
11837 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11839 ALC262_HIPPO_MASTER_SWITCH,
11840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11841 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11842 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11843 { }
11844};
11845
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011846/* bind Beep switches of both NID 0x0f and 0x10 */
11847static struct hda_bind_ctls alc268_bind_beep_sw = {
11848 .ops = &snd_hda_bind_sw,
11849 .values = {
11850 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11851 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11852 0
11853 },
11854};
11855
11856static struct snd_kcontrol_new alc268_beep_mixer[] = {
11857 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11858 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11859 { }
11860};
11861
Kailang Yangd1a991a2007-08-15 16:21:59 +020011862static struct hda_verb alc268_eapd_verbs[] = {
11863 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11864 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11865 { }
11866};
11867
Takashi Iwaid2738092007-08-16 14:59:45 +020011868/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011869static struct hda_verb alc268_toshiba_verbs[] = {
11870 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11871 { } /* end */
11872};
11873
11874/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011875/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011876static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11877 .ops = &snd_hda_bind_vol,
11878 .values = {
11879 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11880 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11881 0
11882 },
11883};
11884
Takashi Iwai889c4392007-08-23 18:56:52 +020011885/* mute/unmute internal speaker according to the hp jack and mute state */
11886static void alc268_acer_automute(struct hda_codec *codec, int force)
11887{
11888 struct alc_spec *spec = codec->spec;
11889 unsigned int mute;
11890
11891 if (force || !spec->sense_updated) {
11892 unsigned int present;
11893 present = snd_hda_codec_read(codec, 0x14, 0,
11894 AC_VERB_GET_PIN_SENSE, 0);
11895 spec->jack_present = (present & 0x80000000) != 0;
11896 spec->sense_updated = 1;
11897 }
11898 if (spec->jack_present)
11899 mute = HDA_AMP_MUTE; /* mute internal speaker */
11900 else /* unmute internal speaker if necessary */
11901 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11902 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11903 HDA_AMP_MUTE, mute);
11904}
11905
11906
11907/* bind hp and internal speaker mute (with plug check) */
11908static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11909 struct snd_ctl_elem_value *ucontrol)
11910{
11911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11912 long *valp = ucontrol->value.integer.value;
11913 int change;
11914
Takashi Iwai8de56b72009-07-24 16:51:47 +020011915 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011916 if (change)
11917 alc268_acer_automute(codec, 0);
11918 return change;
11919}
Takashi Iwaid2738092007-08-16 14:59:45 +020011920
Kailang Yang8ef355d2008-08-26 13:10:22 +020011921static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11922 /* output mixer control */
11923 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11924 {
11925 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11926 .name = "Master Playback Switch",
11927 .info = snd_hda_mixer_amp_switch_info,
11928 .get = snd_hda_mixer_amp_switch_get,
11929 .put = alc268_acer_master_sw_put,
11930 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11931 },
11932 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11933 { }
11934};
11935
Takashi Iwaid2738092007-08-16 14:59:45 +020011936static struct snd_kcontrol_new alc268_acer_mixer[] = {
11937 /* output mixer control */
11938 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11939 {
11940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11941 .name = "Master Playback Switch",
11942 .info = snd_hda_mixer_amp_switch_info,
11943 .get = snd_hda_mixer_amp_switch_get,
11944 .put = alc268_acer_master_sw_put,
11945 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11946 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11948 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11949 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011950 { }
11951};
11952
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011953static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11954 /* output mixer control */
11955 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11956 {
11957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11958 .name = "Master Playback Switch",
11959 .info = snd_hda_mixer_amp_switch_info,
11960 .get = snd_hda_mixer_amp_switch_get,
11961 .put = alc268_acer_master_sw_put,
11962 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11963 },
11964 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11965 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11966 { }
11967};
11968
Kailang Yang8ef355d2008-08-26 13:10:22 +020011969static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11970 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11972 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11973 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11974 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11976 { }
11977};
11978
Takashi Iwaid2738092007-08-16 14:59:45 +020011979static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011980 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11981 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011986 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11987 { }
11988};
11989
11990/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011991#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011992#define alc268_toshiba_setup alc262_hippo_setup
11993#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020011994
11995static void alc268_acer_unsol_event(struct hda_codec *codec,
11996 unsigned int res)
11997{
Takashi Iwai889c4392007-08-23 18:56:52 +020011998 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011999 return;
12000 alc268_acer_automute(codec, 1);
12001}
12002
Takashi Iwai889c4392007-08-23 18:56:52 +020012003static void alc268_acer_init_hook(struct hda_codec *codec)
12004{
12005 alc268_acer_automute(codec, 1);
12006}
12007
Kailang Yang8ef355d2008-08-26 13:10:22 +020012008/* toggle speaker-output according to the hp-jack state */
12009static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12010{
12011 unsigned int present;
12012 unsigned char bits;
12013
12014 present = snd_hda_codec_read(codec, 0x15, 0,
12015 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12016 bits = present ? AMP_IN_MUTE(0) : 0;
12017 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12018 AMP_IN_MUTE(0), bits);
12019 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12020 AMP_IN_MUTE(0), bits);
12021}
12022
Kailang Yang8ef355d2008-08-26 13:10:22 +020012023static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12024 unsigned int res)
12025{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012026 switch (res >> 26) {
12027 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012028 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012029 break;
12030 case ALC880_MIC_EVENT:
12031 alc_mic_automute(codec);
12032 break;
12033 }
12034}
12035
12036static void alc268_acer_lc_setup(struct hda_codec *codec)
12037{
12038 struct alc_spec *spec = codec->spec;
12039 spec->ext_mic.pin = 0x18;
12040 spec->ext_mic.mux_idx = 0;
12041 spec->int_mic.pin = 0x12;
12042 spec->int_mic.mux_idx = 6;
12043 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012044}
12045
12046static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12047{
12048 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012049 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012050}
12051
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012052static struct snd_kcontrol_new alc268_dell_mixer[] = {
12053 /* output mixer control */
12054 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12055 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12056 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12058 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12059 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12060 { }
12061};
12062
12063static struct hda_verb alc268_dell_verbs[] = {
12064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12066 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012067 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012068 { }
12069};
12070
12071/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012072static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012073{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012074 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012075
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012076 spec->autocfg.hp_pins[0] = 0x15;
12077 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012078 spec->ext_mic.pin = 0x18;
12079 spec->ext_mic.mux_idx = 0;
12080 spec->int_mic.pin = 0x19;
12081 spec->int_mic.mux_idx = 1;
12082 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012083}
12084
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012085static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12086 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12087 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12088 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12090 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12091 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12092 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12093 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12094 { }
12095};
12096
12097static struct hda_verb alc267_quanta_il1_verbs[] = {
12098 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12099 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12100 { }
12101};
12102
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012103static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012104{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012105 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012106 spec->autocfg.hp_pins[0] = 0x15;
12107 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012108 spec->ext_mic.pin = 0x18;
12109 spec->ext_mic.mux_idx = 0;
12110 spec->int_mic.pin = 0x19;
12111 spec->int_mic.mux_idx = 1;
12112 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012113}
12114
Kailang Yanga361d842007-06-05 12:30:55 +020012115/*
12116 * generic initialization of ADC, input mixers and output mixers
12117 */
12118static struct hda_verb alc268_base_init_verbs[] = {
12119 /* Unmute DAC0-1 and set vol = 0 */
12120 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012121 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012122
12123 /*
12124 * Set up output mixers (0x0c - 0x0e)
12125 */
12126 /* set vol=0 to output mixers */
12127 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012128 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12129
12130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12131 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12132
12133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12135 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12136 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12137 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12138 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12139 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12140 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12141
12142 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012146 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012147
12148 /* set PCBEEP vol = 0, mute connections */
12149 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12151 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012152
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012153 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012154
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012155 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12157 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012159
Kailang Yanga361d842007-06-05 12:30:55 +020012160 { }
12161};
12162
12163/*
12164 * generic initialization of ADC, input mixers and output mixers
12165 */
12166static struct hda_verb alc268_volume_init_verbs[] = {
12167 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012168 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12169 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012170
12171 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12172 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12173 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12174 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12175 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12176
Kailang Yanga361d842007-06-05 12:30:55 +020012177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12179 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12180
12181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012183
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012184 /* set PCBEEP vol = 0, mute connections */
12185 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12187 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012188
12189 { }
12190};
12191
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012192static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12193 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12194 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12195 { } /* end */
12196};
12197
Kailang Yanga361d842007-06-05 12:30:55 +020012198static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12199 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12200 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012201 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012202 { } /* end */
12203};
12204
12205static struct snd_kcontrol_new alc268_capture_mixer[] = {
12206 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12207 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12208 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12209 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012210 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012211 { } /* end */
12212};
12213
12214static struct hda_input_mux alc268_capture_source = {
12215 .num_items = 4,
12216 .items = {
12217 { "Mic", 0x0 },
12218 { "Front Mic", 0x1 },
12219 { "Line", 0x2 },
12220 { "CD", 0x3 },
12221 },
12222};
12223
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012224static struct hda_input_mux alc268_acer_capture_source = {
12225 .num_items = 3,
12226 .items = {
12227 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012228 { "Internal Mic", 0x1 },
12229 { "Line", 0x2 },
12230 },
12231};
12232
12233static struct hda_input_mux alc268_acer_dmic_capture_source = {
12234 .num_items = 3,
12235 .items = {
12236 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012237 { "Internal Mic", 0x6 },
12238 { "Line", 0x2 },
12239 },
12240};
12241
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012242#ifdef CONFIG_SND_DEBUG
12243static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012244 /* Volume widgets */
12245 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12246 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12247 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12248 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12249 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12250 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12251 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12252 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12253 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12254 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12255 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12256 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12257 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012258 /* The below appears problematic on some hardwares */
12259 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012260 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12261 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12262 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12263 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12264
12265 /* Modes for retasking pin widgets */
12266 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12267 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12268 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12269 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12270
12271 /* Controls for GPIO pins, assuming they are configured as outputs */
12272 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12273 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12274 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12275 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12276
12277 /* Switches to allow the digital SPDIF output pin to be enabled.
12278 * The ALC268 does not have an SPDIF input.
12279 */
12280 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12281
12282 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12283 * this output to turn on an external amplifier.
12284 */
12285 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12286 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12287
12288 { } /* end */
12289};
12290#endif
12291
Kailang Yanga361d842007-06-05 12:30:55 +020012292/* create input playback/capture controls for the given pin */
12293static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12294 const char *ctlname, int idx)
12295{
12296 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012297 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012298 int err;
12299
12300 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012301 switch (nid) {
12302 case 0x14:
12303 case 0x16:
12304 dac = 0x02;
12305 break;
12306 case 0x15:
12307 dac = 0x03;
12308 break;
12309 default:
12310 return 0;
12311 }
12312 if (spec->multiout.dac_nids[0] != dac &&
12313 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012314 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012315 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012316 HDA_OUTPUT));
12317 if (err < 0)
12318 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012319 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12320 }
12321
Kailang Yanga361d842007-06-05 12:30:55 +020012322 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012323 if (nid != 0x16)
12324 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012325 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012326 else /* mono */
12327 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12328 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012329 if (err < 0)
12330 return err;
12331 return 0;
12332}
12333
12334/* add playback controls from the parsed DAC table */
12335static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12336 const struct auto_pin_cfg *cfg)
12337{
12338 hda_nid_t nid;
12339 int err;
12340
Kailang Yanga361d842007-06-05 12:30:55 +020012341 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012342
12343 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012344 if (nid) {
12345 const char *name;
12346 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12347 name = "Speaker";
12348 else
12349 name = "Front";
12350 err = alc268_new_analog_output(spec, nid, name, 0);
12351 if (err < 0)
12352 return err;
12353 }
Kailang Yanga361d842007-06-05 12:30:55 +020012354
12355 nid = cfg->speaker_pins[0];
12356 if (nid == 0x1d) {
12357 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12358 "Speaker Playback Volume",
12359 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12360 if (err < 0)
12361 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012362 } else {
12363 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12364 if (err < 0)
12365 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012366 }
12367 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012368 if (nid) {
12369 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12370 if (err < 0)
12371 return err;
12372 }
Kailang Yanga361d842007-06-05 12:30:55 +020012373
12374 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12375 if (nid == 0x16) {
12376 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12377 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012378 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012379 if (err < 0)
12380 return err;
12381 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012382 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012383}
12384
12385/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012386static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012387 const struct auto_pin_cfg *cfg)
12388{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012389 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012390}
12391
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012392static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12393 hda_nid_t nid, int pin_type)
12394{
12395 int idx;
12396
12397 alc_set_pin_output(codec, nid, pin_type);
12398 if (nid == 0x14 || nid == 0x16)
12399 idx = 0;
12400 else
12401 idx = 1;
12402 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12403}
12404
12405static void alc268_auto_init_multi_out(struct hda_codec *codec)
12406{
12407 struct alc_spec *spec = codec->spec;
12408 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12409 if (nid) {
12410 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12411 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12412 }
12413}
12414
12415static void alc268_auto_init_hp_out(struct hda_codec *codec)
12416{
12417 struct alc_spec *spec = codec->spec;
12418 hda_nid_t pin;
12419
12420 pin = spec->autocfg.hp_pins[0];
12421 if (pin)
12422 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12423 pin = spec->autocfg.speaker_pins[0];
12424 if (pin)
12425 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12426}
12427
Kailang Yanga361d842007-06-05 12:30:55 +020012428static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12429{
12430 struct alc_spec *spec = codec->spec;
12431 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12432 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12433 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12434 unsigned int dac_vol1, dac_vol2;
12435
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012436 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012437 snd_hda_codec_write(codec, speaker_nid, 0,
12438 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012439 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012440 snd_hda_codec_write(codec, 0x0f, 0,
12441 AC_VERB_SET_AMP_GAIN_MUTE,
12442 AMP_IN_UNMUTE(1));
12443 snd_hda_codec_write(codec, 0x10, 0,
12444 AC_VERB_SET_AMP_GAIN_MUTE,
12445 AMP_IN_UNMUTE(1));
12446 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012447 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012448 snd_hda_codec_write(codec, 0x0f, 0,
12449 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12450 snd_hda_codec_write(codec, 0x10, 0,
12451 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12452 }
12453
12454 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012455 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012456 dac_vol2 = AMP_OUT_ZERO;
12457 else if (line_nid == 0x15)
12458 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012459 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012460 dac_vol2 = AMP_OUT_ZERO;
12461 else if (hp_nid == 0x15)
12462 dac_vol1 = AMP_OUT_ZERO;
12463 if (line_nid != 0x16 || hp_nid != 0x16 ||
12464 spec->autocfg.line_out_pins[1] != 0x16 ||
12465 spec->autocfg.line_out_pins[2] != 0x16)
12466 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12467
12468 snd_hda_codec_write(codec, 0x02, 0,
12469 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12470 snd_hda_codec_write(codec, 0x03, 0,
12471 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12472}
12473
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012474/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012475#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12476#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012477#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012478#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12479
12480/*
12481 * BIOS auto configuration
12482 */
12483static int alc268_parse_auto_config(struct hda_codec *codec)
12484{
12485 struct alc_spec *spec = codec->spec;
12486 int err;
12487 static hda_nid_t alc268_ignore[] = { 0 };
12488
12489 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12490 alc268_ignore);
12491 if (err < 0)
12492 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012493 if (!spec->autocfg.line_outs) {
12494 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12495 spec->multiout.max_channels = 2;
12496 spec->no_analog = 1;
12497 goto dig_only;
12498 }
Kailang Yanga361d842007-06-05 12:30:55 +020012499 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012500 }
Kailang Yanga361d842007-06-05 12:30:55 +020012501 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12502 if (err < 0)
12503 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012504 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012505 if (err < 0)
12506 return err;
12507
12508 spec->multiout.max_channels = 2;
12509
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012510 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012511 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012512 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012513 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012514 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12515 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012516 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012517 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012518
Takashi Iwai892981f2009-03-02 08:04:35 +010012519 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012520 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012521
Takashi Iwaid88897e2008-10-31 15:01:37 +010012522 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012523 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012524 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012525
Takashi Iwai776e1842007-08-29 15:07:11 +020012526 err = alc_auto_add_mic_boost(codec);
12527 if (err < 0)
12528 return err;
12529
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012530 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12531
Kailang Yanga361d842007-06-05 12:30:55 +020012532 return 1;
12533}
12534
Kailang Yanga361d842007-06-05 12:30:55 +020012535#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12536
12537/* init callback for auto-configuration model -- overriding the default init */
12538static void alc268_auto_init(struct hda_codec *codec)
12539{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012540 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012541 alc268_auto_init_multi_out(codec);
12542 alc268_auto_init_hp_out(codec);
12543 alc268_auto_init_mono_speaker_out(codec);
12544 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012545 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012546 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012547}
12548
12549/*
12550 * configuration and preset
12551 */
12552static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012553 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012554 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012555 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012556 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012557 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012558 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012559 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012560 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012561#ifdef CONFIG_SND_DEBUG
12562 [ALC268_TEST] = "test",
12563#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012564 [ALC268_AUTO] = "auto",
12565};
12566
12567static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012568 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012569 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012570 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012571 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012572 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012573 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12574 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012575 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012576 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012577 /* almost compatible with toshiba but with optional digital outs;
12578 * auto-probing seems working fine
12579 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012580 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012581 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012582 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012583 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012584 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012585 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012586 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012587 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012588 {}
12589};
12590
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012591/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12592static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12593 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12594 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12595 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12596 ALC268_TOSHIBA),
12597 {}
12598};
12599
Kailang Yanga361d842007-06-05 12:30:55 +020012600static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012601 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012602 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12603 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012604 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12605 alc267_quanta_il1_verbs },
12606 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12607 .dac_nids = alc268_dac_nids,
12608 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12609 .adc_nids = alc268_adc_nids_alt,
12610 .hp_nid = 0x03,
12611 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12612 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012613 .unsol_event = alc_sku_unsol_event,
12614 .setup = alc267_quanta_il1_setup,
12615 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012616 },
Kailang Yanga361d842007-06-05 12:30:55 +020012617 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012618 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12619 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012620 .init_verbs = { alc268_base_init_verbs },
12621 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12622 .dac_nids = alc268_dac_nids,
12623 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12624 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012625 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012626 .hp_nid = 0x03,
12627 .dig_out_nid = ALC268_DIGOUT_NID,
12628 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12629 .channel_mode = alc268_modes,
12630 .input_mux = &alc268_capture_source,
12631 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012632 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012633 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012634 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012635 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12636 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012637 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12638 .dac_nids = alc268_dac_nids,
12639 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12640 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012641 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012642 .hp_nid = 0x03,
12643 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12644 .channel_mode = alc268_modes,
12645 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012646 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012647 .setup = alc268_toshiba_setup,
12648 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012649 },
12650 [ALC268_ACER] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012651 .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012652 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012653 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12654 alc268_acer_verbs },
12655 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12656 .dac_nids = alc268_dac_nids,
12657 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12658 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012659 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012660 .hp_nid = 0x02,
12661 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12662 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012663 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012664 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012665 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012666 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012667 [ALC268_ACER_DMIC] = {
12668 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12669 alc268_beep_mixer },
12670 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12671 alc268_acer_verbs },
12672 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12673 .dac_nids = alc268_dac_nids,
12674 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12675 .adc_nids = alc268_adc_nids_alt,
12676 .capsrc_nids = alc268_capsrc_nids,
12677 .hp_nid = 0x02,
12678 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12679 .channel_mode = alc268_modes,
12680 .input_mux = &alc268_acer_dmic_capture_source,
12681 .unsol_event = alc268_acer_unsol_event,
12682 .init_hook = alc268_acer_init_hook,
12683 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012684 [ALC268_ACER_ASPIRE_ONE] = {
12685 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012686 alc268_beep_mixer,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012687 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012688 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12689 alc268_acer_aspire_one_verbs },
12690 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12691 .dac_nids = alc268_dac_nids,
12692 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12693 .adc_nids = alc268_adc_nids_alt,
12694 .capsrc_nids = alc268_capsrc_nids,
12695 .hp_nid = 0x03,
12696 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12697 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012698 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012699 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012700 .init_hook = alc268_acer_lc_init_hook,
12701 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012702 [ALC268_DELL] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012703 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12704 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012705 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12706 alc268_dell_verbs },
12707 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12708 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012709 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12710 .adc_nids = alc268_adc_nids_alt,
12711 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012712 .hp_nid = 0x02,
12713 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12714 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012715 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012716 .setup = alc268_dell_setup,
12717 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012718 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012719 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012720 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12721 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012722 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12723 alc268_toshiba_verbs },
12724 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12725 .dac_nids = alc268_dac_nids,
12726 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12727 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012728 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012729 .hp_nid = 0x03,
12730 .dig_out_nid = ALC268_DIGOUT_NID,
12731 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12732 .channel_mode = alc268_modes,
12733 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012734 .setup = alc268_toshiba_setup,
12735 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012736 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012737#ifdef CONFIG_SND_DEBUG
12738 [ALC268_TEST] = {
12739 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12740 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12741 alc268_volume_init_verbs },
12742 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12743 .dac_nids = alc268_dac_nids,
12744 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12745 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012746 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012747 .hp_nid = 0x03,
12748 .dig_out_nid = ALC268_DIGOUT_NID,
12749 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12750 .channel_mode = alc268_modes,
12751 .input_mux = &alc268_capture_source,
12752 },
12753#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012754};
12755
12756static int patch_alc268(struct hda_codec *codec)
12757{
12758 struct alc_spec *spec;
12759 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012760 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012761
12762 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12763 if (spec == NULL)
12764 return -ENOMEM;
12765
12766 codec->spec = spec;
12767
12768 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12769 alc268_models,
12770 alc268_cfg_tbl);
12771
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012772 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12773 board_config = snd_hda_check_board_codec_sid_config(codec,
12774 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12775
Kailang Yanga361d842007-06-05 12:30:55 +020012776 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012777 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12778 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012779 board_config = ALC268_AUTO;
12780 }
12781
12782 if (board_config == ALC268_AUTO) {
12783 /* automatic parse from the BIOS config */
12784 err = alc268_parse_auto_config(codec);
12785 if (err < 0) {
12786 alc_free(codec);
12787 return err;
12788 } else if (!err) {
12789 printk(KERN_INFO
12790 "hda_codec: Cannot set up configuration "
12791 "from BIOS. Using base mode...\n");
12792 board_config = ALC268_3ST;
12793 }
12794 }
12795
12796 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012797 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012798
Kailang Yanga361d842007-06-05 12:30:55 +020012799 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12800 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012801 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012802
Kailang Yanga361d842007-06-05 12:30:55 +020012803 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12804
Takashi Iwai22971e32009-02-10 11:56:44 +010012805 has_beep = 0;
12806 for (i = 0; i < spec->num_mixers; i++) {
12807 if (spec->mixers[i] == alc268_beep_mixer) {
12808 has_beep = 1;
12809 break;
12810 }
12811 }
12812
12813 if (has_beep) {
12814 err = snd_hda_attach_beep_device(codec, 0x1);
12815 if (err < 0) {
12816 alc_free(codec);
12817 return err;
12818 }
12819 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12820 /* override the amp caps for beep generator */
12821 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012822 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12823 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12824 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12825 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012826 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012827
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012828 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012829 /* check whether NID 0x07 is valid */
12830 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012831 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012832
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012833 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012834 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012835 if (spec->auto_mic ||
12836 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012837 spec->adc_nids = alc268_adc_nids_alt;
12838 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012839 if (spec->auto_mic || spec->input_mux->num_items == 1)
12840 add_mixer(spec, alc268_capture_nosrc_mixer);
12841 else
12842 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012843 } else {
12844 spec->adc_nids = alc268_adc_nids;
12845 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012846 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012847 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012848 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012849 /* set default input source */
12850 for (i = 0; i < spec->num_adc_nids; i++)
12851 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12852 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012853 i < spec->num_mux_defs ?
12854 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012855 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012856 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012857
12858 spec->vmaster_nid = 0x02;
12859
Kailang Yanga361d842007-06-05 12:30:55 +020012860 codec->patch_ops = alc_patch_ops;
12861 if (board_config == ALC268_AUTO)
12862 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012863
Takashi Iwaidaead532008-11-28 12:55:36 +010012864 codec->proc_widget_hook = print_realtek_coef;
12865
Kailang Yanga361d842007-06-05 12:30:55 +020012866 return 0;
12867}
12868
12869/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012870 * ALC269 channel source setting (2 channel)
12871 */
12872#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12873
12874#define alc269_dac_nids alc260_dac_nids
12875
12876static hda_nid_t alc269_adc_nids[1] = {
12877 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012878 0x08,
12879};
12880
Takashi Iwaie01bf502008-08-21 16:25:07 +020012881static hda_nid_t alc269_capsrc_nids[1] = {
12882 0x23,
12883};
12884
12885/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12886 * not a mux!
12887 */
12888
Kailang Yangf6a92242007-12-13 16:52:54 +010012889#define alc269_modes alc260_modes
12890#define alc269_capture_source alc880_lg_lw_capture_source
12891
12892static struct snd_kcontrol_new alc269_base_mixer[] = {
12893 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12894 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12899 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12902 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12904 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12905 { } /* end */
12906};
12907
Kailang Yang60db6b52008-08-26 13:13:00 +020012908static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12909 /* output mixer control */
12910 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12911 {
12912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12913 .name = "Master Playback Switch",
12914 .info = snd_hda_mixer_amp_switch_info,
12915 .get = snd_hda_mixer_amp_switch_get,
12916 .put = alc268_acer_master_sw_put,
12917 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12918 },
12919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12921 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12923 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12924 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012925 { }
12926};
12927
Tony Vroon64154832008-11-06 15:08:49 +000012928static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12929 /* output mixer control */
12930 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12931 {
12932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12933 .name = "Master Playback Switch",
12934 .info = snd_hda_mixer_amp_switch_info,
12935 .get = snd_hda_mixer_amp_switch_get,
12936 .put = alc268_acer_master_sw_put,
12937 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12938 },
12939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12941 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12942 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12943 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12944 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12945 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12946 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12947 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012948 { }
12949};
12950
Kailang Yangf53281e2008-07-18 12:36:43 +020012951static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012952 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012953 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012955 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012956 { } /* end */
12957};
12958
Kailang Yangf6a92242007-12-13 16:52:54 +010012959/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012960static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12961 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12962 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012963 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12964 { } /* end */
12965};
12966
12967/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012968#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012969
Kailang Yang60db6b52008-08-26 13:13:00 +020012970static struct hda_verb alc269_quanta_fl1_verbs[] = {
12971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12972 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12974 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12975 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12976 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12977 { }
12978};
12979
Tony Vroon64154832008-11-06 15:08:49 +000012980static struct hda_verb alc269_lifebook_verbs[] = {
12981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12982 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12983 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12985 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12986 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12987 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12988 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12989 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12990 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12991 { }
12992};
12993
Kailang Yang60db6b52008-08-26 13:13:00 +020012994/* toggle speaker-output according to the hp-jack state */
12995static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12996{
12997 unsigned int present;
12998 unsigned char bits;
12999
13000 present = snd_hda_codec_read(codec, 0x15, 0,
13001 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13002 bits = present ? AMP_IN_MUTE(0) : 0;
13003 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13004 AMP_IN_MUTE(0), bits);
13005 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13006 AMP_IN_MUTE(0), bits);
13007
13008 snd_hda_codec_write(codec, 0x20, 0,
13009 AC_VERB_SET_COEF_INDEX, 0x0c);
13010 snd_hda_codec_write(codec, 0x20, 0,
13011 AC_VERB_SET_PROC_COEF, 0x680);
13012
13013 snd_hda_codec_write(codec, 0x20, 0,
13014 AC_VERB_SET_COEF_INDEX, 0x0c);
13015 snd_hda_codec_write(codec, 0x20, 0,
13016 AC_VERB_SET_PROC_COEF, 0x480);
13017}
13018
Tony Vroon64154832008-11-06 15:08:49 +000013019/* toggle speaker-output according to the hp-jacks state */
13020static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13021{
13022 unsigned int present;
13023 unsigned char bits;
13024
13025 /* Check laptop headphone socket */
13026 present = snd_hda_codec_read(codec, 0x15, 0,
13027 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13028
13029 /* Check port replicator headphone socket */
13030 present |= snd_hda_codec_read(codec, 0x1a, 0,
13031 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13032
13033 bits = present ? AMP_IN_MUTE(0) : 0;
13034 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13035 AMP_IN_MUTE(0), bits);
13036 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13037 AMP_IN_MUTE(0), bits);
13038
13039 snd_hda_codec_write(codec, 0x20, 0,
13040 AC_VERB_SET_COEF_INDEX, 0x0c);
13041 snd_hda_codec_write(codec, 0x20, 0,
13042 AC_VERB_SET_PROC_COEF, 0x680);
13043
13044 snd_hda_codec_write(codec, 0x20, 0,
13045 AC_VERB_SET_COEF_INDEX, 0x0c);
13046 snd_hda_codec_write(codec, 0x20, 0,
13047 AC_VERB_SET_PROC_COEF, 0x480);
13048}
13049
Tony Vroon64154832008-11-06 15:08:49 +000013050static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13051{
13052 unsigned int present_laptop;
13053 unsigned int present_dock;
13054
13055 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13056 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13057
13058 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13059 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13060
13061 /* Laptop mic port overrides dock mic port, design decision */
13062 if (present_dock)
13063 snd_hda_codec_write(codec, 0x23, 0,
13064 AC_VERB_SET_CONNECT_SEL, 0x3);
13065 if (present_laptop)
13066 snd_hda_codec_write(codec, 0x23, 0,
13067 AC_VERB_SET_CONNECT_SEL, 0x0);
13068 if (!present_dock && !present_laptop)
13069 snd_hda_codec_write(codec, 0x23, 0,
13070 AC_VERB_SET_CONNECT_SEL, 0x1);
13071}
13072
Kailang Yang60db6b52008-08-26 13:13:00 +020013073static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13074 unsigned int res)
13075{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013076 switch (res >> 26) {
13077 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013078 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013079 break;
13080 case ALC880_MIC_EVENT:
13081 alc_mic_automute(codec);
13082 break;
13083 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013084}
13085
Tony Vroon64154832008-11-06 15:08:49 +000013086static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13087 unsigned int res)
13088{
13089 if ((res >> 26) == ALC880_HP_EVENT)
13090 alc269_lifebook_speaker_automute(codec);
13091 if ((res >> 26) == ALC880_MIC_EVENT)
13092 alc269_lifebook_mic_autoswitch(codec);
13093}
13094
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013095static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13096{
13097 struct alc_spec *spec = codec->spec;
13098 spec->ext_mic.pin = 0x18;
13099 spec->ext_mic.mux_idx = 0;
13100 spec->int_mic.pin = 0x19;
13101 spec->int_mic.mux_idx = 1;
13102 spec->auto_mic = 1;
13103}
13104
Kailang Yang60db6b52008-08-26 13:13:00 +020013105static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13106{
13107 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013108 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013109}
13110
Tony Vroon64154832008-11-06 15:08:49 +000013111static void alc269_lifebook_init_hook(struct hda_codec *codec)
13112{
13113 alc269_lifebook_speaker_automute(codec);
13114 alc269_lifebook_mic_autoswitch(codec);
13115}
13116
Kailang Yang60db6b52008-08-26 13:13:00 +020013117static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13119 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13120 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13122 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13123 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13124 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13125 {}
13126};
13127
13128static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13129 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13130 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13131 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13133 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13134 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13135 {}
13136};
13137
13138/* toggle speaker-output according to the hp-jack state */
13139static void alc269_speaker_automute(struct hda_codec *codec)
13140{
13141 unsigned int present;
13142 unsigned char bits;
13143
13144 present = snd_hda_codec_read(codec, 0x15, 0,
13145 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13146 bits = present ? AMP_IN_MUTE(0) : 0;
13147 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13148 AMP_IN_MUTE(0), bits);
13149 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13150 AMP_IN_MUTE(0), bits);
13151}
13152
Kailang Yang60db6b52008-08-26 13:13:00 +020013153/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013154static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013155 unsigned int res)
13156{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013157 switch (res >> 26) {
13158 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013159 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013160 break;
13161 case ALC880_MIC_EVENT:
13162 alc_mic_automute(codec);
13163 break;
13164 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013165}
13166
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013167static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13168{
13169 struct alc_spec *spec = codec->spec;
13170 spec->ext_mic.pin = 0x18;
13171 spec->ext_mic.mux_idx = 0;
13172 spec->int_mic.pin = 0x12;
13173 spec->int_mic.mux_idx = 5;
13174 spec->auto_mic = 1;
13175}
13176
13177static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13178{
13179 struct alc_spec *spec = codec->spec;
13180 spec->ext_mic.pin = 0x18;
13181 spec->ext_mic.mux_idx = 0;
13182 spec->int_mic.pin = 0x19;
13183 spec->int_mic.mux_idx = 1;
13184 spec->auto_mic = 1;
13185}
13186
13187static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013188{
13189 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013190 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013191}
13192
Kailang Yangf6a92242007-12-13 16:52:54 +010013193/*
13194 * generic initialization of ADC, input mixers and output mixers
13195 */
13196static struct hda_verb alc269_init_verbs[] = {
13197 /*
13198 * Unmute ADC0 and set the default input to mic-in
13199 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013201
13202 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13203 * analog-loopback mixer widget
13204 * Note: PASD motherboards uses the Line In 2 as the input for
13205 * front panel mic (mic 2)
13206 */
13207 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13213
13214 /*
13215 * Set up output mixers (0x0c - 0x0e)
13216 */
13217 /* set vol=0 to output mixers */
13218 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13219 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13220
13221 /* set up input amps for analog loopback */
13222 /* Amp Indices: DAC = 0, mixer = 1 */
13223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13229
13230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13233 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13234 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13235 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13237
13238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13241 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13242 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13243 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13244 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13245
13246 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13248
13249 /* FIXME: use matrix-type input source selection */
13250 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13251 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13256
13257 /* set EAPD */
13258 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13259 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13260 { }
13261};
13262
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013263#define alc269_auto_create_multi_out_ctls \
13264 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013265#define alc269_auto_create_input_ctls \
13266 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013267
13268#ifdef CONFIG_SND_HDA_POWER_SAVE
13269#define alc269_loopbacks alc880_loopbacks
13270#endif
13271
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013272/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013273#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13274#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13275#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13276#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13277
Takashi Iwaif03d3112009-03-05 14:18:16 +010013278static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13279 .substreams = 1,
13280 .channels_min = 2,
13281 .channels_max = 8,
13282 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13283 /* NID is set in alc_build_pcms */
13284 .ops = {
13285 .open = alc880_playback_pcm_open,
13286 .prepare = alc880_playback_pcm_prepare,
13287 .cleanup = alc880_playback_pcm_cleanup
13288 },
13289};
13290
13291static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13292 .substreams = 1,
13293 .channels_min = 2,
13294 .channels_max = 2,
13295 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13296 /* NID is set in alc_build_pcms */
13297};
13298
Kailang Yangf6a92242007-12-13 16:52:54 +010013299/*
13300 * BIOS auto configuration
13301 */
13302static int alc269_parse_auto_config(struct hda_codec *codec)
13303{
13304 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013305 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013306 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13307
13308 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13309 alc269_ignore);
13310 if (err < 0)
13311 return err;
13312
13313 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13314 if (err < 0)
13315 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013316 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013317 if (err < 0)
13318 return err;
13319
13320 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13321
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013322 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013323 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13324
Takashi Iwai603c4012008-07-30 15:01:44 +020013325 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013326 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013327
Takashi Iwaid88897e2008-10-31 15:01:37 +010013328 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013329 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013330 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013331 /* set default input source */
13332 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13333 0, AC_VERB_SET_CONNECT_SEL,
13334 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013335
13336 err = alc_auto_add_mic_boost(codec);
13337 if (err < 0)
13338 return err;
13339
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013340 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013341 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013342
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013343 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13344
Kailang Yangf6a92242007-12-13 16:52:54 +010013345 return 1;
13346}
13347
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013348#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13349#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013350#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13351
13352
13353/* init callback for auto-configuration model -- overriding the default init */
13354static void alc269_auto_init(struct hda_codec *codec)
13355{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013356 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013357 alc269_auto_init_multi_out(codec);
13358 alc269_auto_init_hp_out(codec);
13359 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013360 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013361 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013362}
13363
13364/*
13365 * configuration and preset
13366 */
13367static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013368 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013369 [ALC269_QUANTA_FL1] = "quanta",
13370 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013371 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013372 [ALC269_FUJITSU] = "fujitsu",
13373 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013374};
13375
13376static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013377 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013378 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13379 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013380 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13381 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13382 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13383 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13384 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13385 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013386 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13387 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013388 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13389 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013390 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013391 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013392 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013393 {}
13394};
13395
13396static struct alc_config_preset alc269_presets[] = {
13397 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013398 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013399 .init_verbs = { alc269_init_verbs },
13400 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13401 .dac_nids = alc269_dac_nids,
13402 .hp_nid = 0x03,
13403 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13404 .channel_mode = alc269_modes,
13405 .input_mux = &alc269_capture_source,
13406 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013407 [ALC269_QUANTA_FL1] = {
13408 .mixers = { alc269_quanta_fl1_mixer },
13409 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13410 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13411 .dac_nids = alc269_dac_nids,
13412 .hp_nid = 0x03,
13413 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13414 .channel_mode = alc269_modes,
13415 .input_mux = &alc269_capture_source,
13416 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013417 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013418 .init_hook = alc269_quanta_fl1_init_hook,
13419 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013420 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013421 .mixers = { alc269_eeepc_mixer },
13422 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013423 .init_verbs = { alc269_init_verbs,
13424 alc269_eeepc_amic_init_verbs },
13425 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13426 .dac_nids = alc269_dac_nids,
13427 .hp_nid = 0x03,
13428 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13429 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013430 .unsol_event = alc269_eeepc_unsol_event,
13431 .setup = alc269_eeepc_amic_setup,
13432 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013433 },
13434 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013435 .mixers = { alc269_eeepc_mixer },
13436 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013437 .init_verbs = { alc269_init_verbs,
13438 alc269_eeepc_dmic_init_verbs },
13439 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13440 .dac_nids = alc269_dac_nids,
13441 .hp_nid = 0x03,
13442 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13443 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013444 .unsol_event = alc269_eeepc_unsol_event,
13445 .setup = alc269_eeepc_dmic_setup,
13446 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013447 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013448 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013449 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013450 .cap_mixer = alc269_epc_capture_mixer,
13451 .init_verbs = { alc269_init_verbs,
13452 alc269_eeepc_dmic_init_verbs },
13453 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13454 .dac_nids = alc269_dac_nids,
13455 .hp_nid = 0x03,
13456 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13457 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013458 .unsol_event = alc269_eeepc_unsol_event,
13459 .setup = alc269_eeepc_dmic_setup,
13460 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013461 },
Tony Vroon64154832008-11-06 15:08:49 +000013462 [ALC269_LIFEBOOK] = {
13463 .mixers = { alc269_lifebook_mixer },
13464 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13465 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13466 .dac_nids = alc269_dac_nids,
13467 .hp_nid = 0x03,
13468 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13469 .channel_mode = alc269_modes,
13470 .input_mux = &alc269_capture_source,
13471 .unsol_event = alc269_lifebook_unsol_event,
13472 .init_hook = alc269_lifebook_init_hook,
13473 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013474};
13475
13476static int patch_alc269(struct hda_codec *codec)
13477{
13478 struct alc_spec *spec;
13479 int board_config;
13480 int err;
13481
13482 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13483 if (spec == NULL)
13484 return -ENOMEM;
13485
13486 codec->spec = spec;
13487
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013488 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13489
Kailang Yangf6a92242007-12-13 16:52:54 +010013490 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13491 alc269_models,
13492 alc269_cfg_tbl);
13493
13494 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013495 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13496 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013497 board_config = ALC269_AUTO;
13498 }
13499
13500 if (board_config == ALC269_AUTO) {
13501 /* automatic parse from the BIOS config */
13502 err = alc269_parse_auto_config(codec);
13503 if (err < 0) {
13504 alc_free(codec);
13505 return err;
13506 } else if (!err) {
13507 printk(KERN_INFO
13508 "hda_codec: Cannot set up configuration "
13509 "from BIOS. Using base mode...\n");
13510 board_config = ALC269_BASIC;
13511 }
13512 }
13513
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013514 err = snd_hda_attach_beep_device(codec, 0x1);
13515 if (err < 0) {
13516 alc_free(codec);
13517 return err;
13518 }
13519
Kailang Yangf6a92242007-12-13 16:52:54 +010013520 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013521 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013522
Takashi Iwaif03d3112009-03-05 14:18:16 +010013523 if (codec->subsystem_id == 0x17aa3bf8) {
13524 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13525 * fix the sample rate of analog I/O to 44.1kHz
13526 */
13527 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13528 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13529 } else {
13530 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13531 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13532 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013533 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13534 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13535
13536 spec->adc_nids = alc269_adc_nids;
13537 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013538 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013539 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013540 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013541 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013542
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013543 spec->vmaster_nid = 0x02;
13544
Kailang Yangf6a92242007-12-13 16:52:54 +010013545 codec->patch_ops = alc_patch_ops;
13546 if (board_config == ALC269_AUTO)
13547 spec->init_hook = alc269_auto_init;
13548#ifdef CONFIG_SND_HDA_POWER_SAVE
13549 if (!spec->loopback.amplist)
13550 spec->loopback.amplist = alc269_loopbacks;
13551#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013552 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013553
13554 return 0;
13555}
13556
13557/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013558 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13559 */
13560
13561/*
13562 * set the path ways for 2 channel output
13563 * need to set the codec line out and mic 1 pin widgets to inputs
13564 */
13565static struct hda_verb alc861_threestack_ch2_init[] = {
13566 /* set pin widget 1Ah (line in) for input */
13567 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013568 /* set pin widget 18h (mic1/2) for input, for mic also enable
13569 * the vref
13570 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013571 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13572
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013573 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13574#if 0
13575 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13576 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13577#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013578 { } /* end */
13579};
13580/*
13581 * 6ch mode
13582 * need to set the codec line out and mic 1 pin widgets to outputs
13583 */
13584static struct hda_verb alc861_threestack_ch6_init[] = {
13585 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13586 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13587 /* set pin widget 18h (mic1) for output (CLFE)*/
13588 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13589
13590 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013591 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013592
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013593 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13594#if 0
13595 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13596 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13597#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013598 { } /* end */
13599};
13600
13601static struct hda_channel_mode alc861_threestack_modes[2] = {
13602 { 2, alc861_threestack_ch2_init },
13603 { 6, alc861_threestack_ch6_init },
13604};
Takashi Iwai22309c32006-08-09 16:57:28 +020013605/* Set mic1 as input and unmute the mixer */
13606static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13607 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13608 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13609 { } /* end */
13610};
13611/* Set mic1 as output and mute mixer */
13612static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13613 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13614 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13615 { } /* end */
13616};
13617
13618static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13619 { 2, alc861_uniwill_m31_ch2_init },
13620 { 4, alc861_uniwill_m31_ch4_init },
13621};
Kailang Yangdf694da2005-12-05 19:42:22 +010013622
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013623/* Set mic1 and line-in as input and unmute the mixer */
13624static struct hda_verb alc861_asus_ch2_init[] = {
13625 /* set pin widget 1Ah (line in) for input */
13626 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013627 /* set pin widget 18h (mic1/2) for input, for mic also enable
13628 * the vref
13629 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013630 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13631
13632 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13633#if 0
13634 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13635 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13636#endif
13637 { } /* end */
13638};
13639/* Set mic1 nad line-in as output and mute mixer */
13640static struct hda_verb alc861_asus_ch6_init[] = {
13641 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13642 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13643 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13644 /* set pin widget 18h (mic1) for output (CLFE)*/
13645 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13646 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13647 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13648 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13649
13650 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13651#if 0
13652 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13653 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13654#endif
13655 { } /* end */
13656};
13657
13658static struct hda_channel_mode alc861_asus_modes[2] = {
13659 { 2, alc861_asus_ch2_init },
13660 { 6, alc861_asus_ch6_init },
13661};
13662
Kailang Yangdf694da2005-12-05 19:42:22 +010013663/* patch-ALC861 */
13664
13665static struct snd_kcontrol_new alc861_base_mixer[] = {
13666 /* output mixer control */
13667 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13668 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13669 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13670 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13671 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13672
13673 /*Input mixer control */
13674 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13675 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13676 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13677 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13678 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13679 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13681 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13682 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013684
Kailang Yangdf694da2005-12-05 19:42:22 +010013685 { } /* end */
13686};
13687
13688static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13689 /* output mixer control */
13690 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13691 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13692 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13693 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13694 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13695
13696 /* Input mixer control */
13697 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13698 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13699 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13700 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13701 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13702 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13704 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013707
Kailang Yangdf694da2005-12-05 19:42:22 +010013708 {
13709 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13710 .name = "Channel Mode",
13711 .info = alc_ch_mode_info,
13712 .get = alc_ch_mode_get,
13713 .put = alc_ch_mode_put,
13714 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13715 },
13716 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013717};
13718
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013719static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013720 /* output mixer control */
13721 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13723 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013724
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013725 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013726};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013727
Takashi Iwai22309c32006-08-09 16:57:28 +020013728static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13729 /* output mixer control */
13730 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13731 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13732 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13733 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13734 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13735
13736 /* Input mixer control */
13737 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13738 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13739 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13740 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13741 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13742 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13744 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13745 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13746 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013747
Takashi Iwai22309c32006-08-09 16:57:28 +020013748 {
13749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13750 .name = "Channel Mode",
13751 .info = alc_ch_mode_info,
13752 .get = alc_ch_mode_get,
13753 .put = alc_ch_mode_put,
13754 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13755 },
13756 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013757};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013758
13759static struct snd_kcontrol_new alc861_asus_mixer[] = {
13760 /* output mixer control */
13761 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13762 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13763 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13764 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13765 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13766
13767 /* Input mixer control */
13768 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13769 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13770 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13771 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13772 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13773 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13775 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13778
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013779 {
13780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13781 .name = "Channel Mode",
13782 .info = alc_ch_mode_info,
13783 .get = alc_ch_mode_get,
13784 .put = alc_ch_mode_put,
13785 .private_value = ARRAY_SIZE(alc861_asus_modes),
13786 },
13787 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013788};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013789
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013790/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013791static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013792 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13793 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013794 { }
13795};
13796
Kailang Yangdf694da2005-12-05 19:42:22 +010013797/*
13798 * generic initialization of ADC, input mixers and output mixers
13799 */
13800static struct hda_verb alc861_base_init_verbs[] = {
13801 /*
13802 * Unmute ADC0 and set the default input to mic-in
13803 */
13804 /* port-A for surround (rear panel) */
13805 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13806 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13807 /* port-B for mic-in (rear panel) with vref */
13808 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13809 /* port-C for line-in (rear panel) */
13810 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13811 /* port-D for Front */
13812 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13813 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13814 /* port-E for HP out (front panel) */
13815 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13816 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013817 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013818 /* port-F for mic-in (front panel) with vref */
13819 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13820 /* port-G for CLFE (rear panel) */
13821 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13822 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13823 /* port-H for side (rear panel) */
13824 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13825 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13826 /* CD-in */
13827 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13828 /* route front mic to ADC1*/
13829 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13830 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013831
Kailang Yangdf694da2005-12-05 19:42:22 +010013832 /* Unmute DAC0~3 & spdif out*/
13833 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13834 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13836 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013838
Kailang Yangdf694da2005-12-05 19:42:22 +010013839 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13840 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13841 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13842 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13843 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013844
Kailang Yangdf694da2005-12-05 19:42:22 +010013845 /* Unmute Stereo Mixer 15 */
13846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013850
13851 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13854 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13857 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013859 /* hp used DAC 3 (Front) */
13860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013861 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13862
13863 { }
13864};
13865
13866static struct hda_verb alc861_threestack_init_verbs[] = {
13867 /*
13868 * Unmute ADC0 and set the default input to mic-in
13869 */
13870 /* port-A for surround (rear panel) */
13871 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13872 /* port-B for mic-in (rear panel) with vref */
13873 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13874 /* port-C for line-in (rear panel) */
13875 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13876 /* port-D for Front */
13877 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13878 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13879 /* port-E for HP out (front panel) */
13880 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13881 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013882 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013883 /* port-F for mic-in (front panel) with vref */
13884 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13885 /* port-G for CLFE (rear panel) */
13886 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13887 /* port-H for side (rear panel) */
13888 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13889 /* CD-in */
13890 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13891 /* route front mic to ADC1*/
13892 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13893 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13894 /* Unmute DAC0~3 & spdif out*/
13895 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13896 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13897 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13898 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013900
Kailang Yangdf694da2005-12-05 19:42:22 +010013901 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13902 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13903 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13904 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13905 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013906
Kailang Yangdf694da2005-12-05 19:42:22 +010013907 /* Unmute Stereo Mixer 15 */
13908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13909 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013912
13913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13919 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013921 /* hp used DAC 3 (Front) */
13922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13924 { }
13925};
Takashi Iwai22309c32006-08-09 16:57:28 +020013926
13927static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13928 /*
13929 * Unmute ADC0 and set the default input to mic-in
13930 */
13931 /* port-A for surround (rear panel) */
13932 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13933 /* port-B for mic-in (rear panel) with vref */
13934 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13935 /* port-C for line-in (rear panel) */
13936 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13937 /* port-D for Front */
13938 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13939 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13940 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013941 /* this has to be set to VREF80 */
13942 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013943 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013944 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013945 /* port-F for mic-in (front panel) with vref */
13946 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13947 /* port-G for CLFE (rear panel) */
13948 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13949 /* port-H for side (rear panel) */
13950 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13951 /* CD-in */
13952 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13953 /* route front mic to ADC1*/
13954 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13956 /* Unmute DAC0~3 & spdif out*/
13957 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13958 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13959 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13960 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013962
Takashi Iwai22309c32006-08-09 16:57:28 +020013963 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13964 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13965 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13966 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13967 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013968
Takashi Iwai22309c32006-08-09 16:57:28 +020013969 /* Unmute Stereo Mixer 15 */
13970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013974
13975 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13976 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13977 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13978 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13979 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13980 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13981 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13982 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013983 /* hp used DAC 3 (Front) */
13984 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013985 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13986 { }
13987};
13988
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013989static struct hda_verb alc861_asus_init_verbs[] = {
13990 /*
13991 * Unmute ADC0 and set the default input to mic-in
13992 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013993 /* port-A for surround (rear panel)
13994 * according to codec#0 this is the HP jack
13995 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013996 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13997 /* route front PCM to HP */
13998 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13999 /* port-B for mic-in (rear panel) with vref */
14000 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14001 /* port-C for line-in (rear panel) */
14002 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14003 /* port-D for Front */
14004 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14005 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14006 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014007 /* this has to be set to VREF80 */
14008 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014009 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014010 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014011 /* port-F for mic-in (front panel) with vref */
14012 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14013 /* port-G for CLFE (rear panel) */
14014 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14015 /* port-H for side (rear panel) */
14016 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14017 /* CD-in */
14018 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14019 /* route front mic to ADC1*/
14020 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14021 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14022 /* Unmute DAC0~3 & spdif out*/
14023 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14024 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14025 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14026 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14028 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14029 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14030 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14031 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14032 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014033
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014034 /* Unmute Stereo Mixer 15 */
14035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14037 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014038 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014039
14040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14041 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14042 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14043 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14045 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14046 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014048 /* hp used DAC 3 (Front) */
14049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14051 { }
14052};
14053
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014054/* additional init verbs for ASUS laptops */
14055static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14056 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14057 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14058 { }
14059};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014060
Kailang Yangdf694da2005-12-05 19:42:22 +010014061/*
14062 * generic initialization of ADC, input mixers and output mixers
14063 */
14064static struct hda_verb alc861_auto_init_verbs[] = {
14065 /*
14066 * Unmute ADC0 and set the default input to mic-in
14067 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014068 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014070
Kailang Yangdf694da2005-12-05 19:42:22 +010014071 /* Unmute DAC0~3 & spdif out*/
14072 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14073 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14074 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14075 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014077
Kailang Yangdf694da2005-12-05 19:42:22 +010014078 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14079 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14080 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14081 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14082 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014083
Kailang Yangdf694da2005-12-05 19:42:22 +010014084 /* Unmute Stereo Mixer 15 */
14085 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14086 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14089
Takashi Iwai1c209302009-07-22 15:17:45 +020014090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14094 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14095 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14096 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14097 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014098
14099 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14102 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14104 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14106 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014107
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014109
14110 { }
14111};
14112
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014113static struct hda_verb alc861_toshiba_init_verbs[] = {
14114 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014115
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014116 { }
14117};
14118
14119/* toggle speaker-output according to the hp-jack state */
14120static void alc861_toshiba_automute(struct hda_codec *codec)
14121{
14122 unsigned int present;
14123
14124 present = snd_hda_codec_read(codec, 0x0f, 0,
14125 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014126 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14128 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14129 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014130}
14131
14132static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14133 unsigned int res)
14134{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014135 if ((res >> 26) == ALC880_HP_EVENT)
14136 alc861_toshiba_automute(codec);
14137}
14138
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014139/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014140#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14141#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14142#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14143#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14144
14145
14146#define ALC861_DIGOUT_NID 0x07
14147
14148static struct hda_channel_mode alc861_8ch_modes[1] = {
14149 { 8, NULL }
14150};
14151
14152static hda_nid_t alc861_dac_nids[4] = {
14153 /* front, surround, clfe, side */
14154 0x03, 0x06, 0x05, 0x04
14155};
14156
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014157static hda_nid_t alc660_dac_nids[3] = {
14158 /* front, clfe, surround */
14159 0x03, 0x05, 0x06
14160};
14161
Kailang Yangdf694da2005-12-05 19:42:22 +010014162static hda_nid_t alc861_adc_nids[1] = {
14163 /* ADC0-2 */
14164 0x08,
14165};
14166
14167static struct hda_input_mux alc861_capture_source = {
14168 .num_items = 5,
14169 .items = {
14170 { "Mic", 0x0 },
14171 { "Front Mic", 0x3 },
14172 { "Line", 0x1 },
14173 { "CD", 0x4 },
14174 { "Mixer", 0x5 },
14175 },
14176};
14177
Takashi Iwai1c209302009-07-22 15:17:45 +020014178static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14179{
14180 struct alc_spec *spec = codec->spec;
14181 hda_nid_t mix, srcs[5];
14182 int i, j, num;
14183
14184 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14185 return 0;
14186 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14187 if (num < 0)
14188 return 0;
14189 for (i = 0; i < num; i++) {
14190 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014191 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014192 if (type != AC_WID_AUD_OUT)
14193 continue;
14194 for (j = 0; j < spec->multiout.num_dacs; j++)
14195 if (spec->multiout.dac_nids[j] == srcs[i])
14196 break;
14197 if (j >= spec->multiout.num_dacs)
14198 return srcs[i];
14199 }
14200 return 0;
14201}
14202
Kailang Yangdf694da2005-12-05 19:42:22 +010014203/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014204static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014205 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014206{
Takashi Iwai1c209302009-07-22 15:17:45 +020014207 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014208 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014209 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014210
14211 spec->multiout.dac_nids = spec->private_dac_nids;
14212 for (i = 0; i < cfg->line_outs; i++) {
14213 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014214 dac = alc861_look_for_dac(codec, nid);
14215 if (!dac)
14216 continue;
14217 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014218 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014219 return 0;
14220}
14221
Takashi Iwai1c209302009-07-22 15:17:45 +020014222static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14223 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014224{
14225 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014226 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14227 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14228 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14229}
14230
14231/* add playback controls from the parsed DAC table */
14232static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14233 const struct auto_pin_cfg *cfg)
14234{
14235 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014236 static const char *chname[4] = {
14237 "Front", "Surround", NULL /*CLFE*/, "Side"
14238 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014239 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014240 int i, err;
14241
14242 if (cfg->line_outs == 1) {
14243 const char *pfx = NULL;
14244 if (!cfg->hp_outs)
14245 pfx = "Master";
14246 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14247 pfx = "Speaker";
14248 if (pfx) {
14249 nid = spec->multiout.dac_nids[0];
14250 return alc861_create_out_sw(codec, pfx, nid, 3);
14251 }
14252 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014253
14254 for (i = 0; i < cfg->line_outs; i++) {
14255 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014256 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014257 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014258 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014259 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014260 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014261 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014262 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014263 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014264 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014265 return err;
14266 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014267 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014268 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014269 return err;
14270 }
14271 }
14272 return 0;
14273}
14274
Takashi Iwai1c209302009-07-22 15:17:45 +020014275static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014276{
Takashi Iwai1c209302009-07-22 15:17:45 +020014277 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014278 int err;
14279 hda_nid_t nid;
14280
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014281 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014282 return 0;
14283
14284 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014285 nid = alc861_look_for_dac(codec, pin);
14286 if (nid) {
14287 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14288 if (err < 0)
14289 return err;
14290 spec->multiout.hp_nid = nid;
14291 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014292 }
14293 return 0;
14294}
14295
14296/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014297static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014298 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014299{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014300 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014301}
14302
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014303static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14304 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014305 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014306{
Takashi Iwai1c209302009-07-22 15:17:45 +020014307 hda_nid_t mix, srcs[5];
14308 int i, num;
14309
Jacek Luczak564c5be2008-05-03 18:41:23 +020014310 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14311 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014312 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014313 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014314 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14315 return;
14316 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14317 if (num < 0)
14318 return;
14319 for (i = 0; i < num; i++) {
14320 unsigned int mute;
14321 if (srcs[i] == dac || srcs[i] == 0x15)
14322 mute = AMP_IN_UNMUTE(i);
14323 else
14324 mute = AMP_IN_MUTE(i);
14325 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14326 mute);
14327 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014328}
14329
14330static void alc861_auto_init_multi_out(struct hda_codec *codec)
14331{
14332 struct alc_spec *spec = codec->spec;
14333 int i;
14334
14335 for (i = 0; i < spec->autocfg.line_outs; i++) {
14336 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014337 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014338 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014339 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014340 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014341 }
14342}
14343
14344static void alc861_auto_init_hp_out(struct hda_codec *codec)
14345{
14346 struct alc_spec *spec = codec->spec;
14347 hda_nid_t pin;
14348
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014349 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014350 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014351 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014352 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014353 pin = spec->autocfg.speaker_pins[0];
14354 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014355 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14356 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014357}
14358
14359static void alc861_auto_init_analog_input(struct hda_codec *codec)
14360{
14361 struct alc_spec *spec = codec->spec;
14362 int i;
14363
14364 for (i = 0; i < AUTO_PIN_LAST; i++) {
14365 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014366 if (nid >= 0x0c && nid <= 0x11)
14367 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014368 }
14369}
14370
14371/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014372/* return 1 if successful, 0 if the proper config is not found,
14373 * or a negative error code
14374 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014375static int alc861_parse_auto_config(struct hda_codec *codec)
14376{
14377 struct alc_spec *spec = codec->spec;
14378 int err;
14379 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14380
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014381 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14382 alc861_ignore);
14383 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014384 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014385 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014386 return 0; /* can't find valid BIOS pin config */
14387
Takashi Iwai1c209302009-07-22 15:17:45 +020014388 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014389 if (err < 0)
14390 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014391 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014392 if (err < 0)
14393 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014394 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014395 if (err < 0)
14396 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014397 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014398 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014399 return err;
14400
14401 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14402
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014403 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014404 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14405
Takashi Iwai603c4012008-07-30 15:01:44 +020014406 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014407 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014408
Takashi Iwaid88897e2008-10-31 15:01:37 +010014409 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014410
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014411 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014412 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014413
14414 spec->adc_nids = alc861_adc_nids;
14415 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014416 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014417
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014418 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14419
Kailang Yangdf694da2005-12-05 19:42:22 +010014420 return 1;
14421}
14422
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014423/* additional initialization for auto-configuration model */
14424static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014425{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014426 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014427 alc861_auto_init_multi_out(codec);
14428 alc861_auto_init_hp_out(codec);
14429 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014430 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014431 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014432}
14433
Takashi Iwaicb53c622007-08-10 17:21:45 +020014434#ifdef CONFIG_SND_HDA_POWER_SAVE
14435static struct hda_amp_list alc861_loopbacks[] = {
14436 { 0x15, HDA_INPUT, 0 },
14437 { 0x15, HDA_INPUT, 1 },
14438 { 0x15, HDA_INPUT, 2 },
14439 { 0x15, HDA_INPUT, 3 },
14440 { } /* end */
14441};
14442#endif
14443
Kailang Yangdf694da2005-12-05 19:42:22 +010014444
14445/*
14446 * configuration and preset
14447 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014448static const char *alc861_models[ALC861_MODEL_LAST] = {
14449 [ALC861_3ST] = "3stack",
14450 [ALC660_3ST] = "3stack-660",
14451 [ALC861_3ST_DIG] = "3stack-dig",
14452 [ALC861_6ST_DIG] = "6stack-dig",
14453 [ALC861_UNIWILL_M31] = "uniwill-m31",
14454 [ALC861_TOSHIBA] = "toshiba",
14455 [ALC861_ASUS] = "asus",
14456 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14457 [ALC861_AUTO] = "auto",
14458};
14459
14460static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014461 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014462 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14463 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14464 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014465 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014466 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014467 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014468 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14469 * Any other models that need this preset?
14470 */
14471 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014472 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14473 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014474 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14475 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14476 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14477 /* FIXME: the below seems conflict */
14478 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14479 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14480 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014481 {}
14482};
14483
14484static struct alc_config_preset alc861_presets[] = {
14485 [ALC861_3ST] = {
14486 .mixers = { alc861_3ST_mixer },
14487 .init_verbs = { alc861_threestack_init_verbs },
14488 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14489 .dac_nids = alc861_dac_nids,
14490 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14491 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014492 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014493 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14494 .adc_nids = alc861_adc_nids,
14495 .input_mux = &alc861_capture_source,
14496 },
14497 [ALC861_3ST_DIG] = {
14498 .mixers = { alc861_base_mixer },
14499 .init_verbs = { alc861_threestack_init_verbs },
14500 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14501 .dac_nids = alc861_dac_nids,
14502 .dig_out_nid = ALC861_DIGOUT_NID,
14503 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14504 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014505 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014506 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14507 .adc_nids = alc861_adc_nids,
14508 .input_mux = &alc861_capture_source,
14509 },
14510 [ALC861_6ST_DIG] = {
14511 .mixers = { alc861_base_mixer },
14512 .init_verbs = { alc861_base_init_verbs },
14513 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14514 .dac_nids = alc861_dac_nids,
14515 .dig_out_nid = ALC861_DIGOUT_NID,
14516 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14517 .channel_mode = alc861_8ch_modes,
14518 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14519 .adc_nids = alc861_adc_nids,
14520 .input_mux = &alc861_capture_source,
14521 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014522 [ALC660_3ST] = {
14523 .mixers = { alc861_3ST_mixer },
14524 .init_verbs = { alc861_threestack_init_verbs },
14525 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14526 .dac_nids = alc660_dac_nids,
14527 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14528 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014529 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014530 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14531 .adc_nids = alc861_adc_nids,
14532 .input_mux = &alc861_capture_source,
14533 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014534 [ALC861_UNIWILL_M31] = {
14535 .mixers = { alc861_uniwill_m31_mixer },
14536 .init_verbs = { alc861_uniwill_m31_init_verbs },
14537 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14538 .dac_nids = alc861_dac_nids,
14539 .dig_out_nid = ALC861_DIGOUT_NID,
14540 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14541 .channel_mode = alc861_uniwill_m31_modes,
14542 .need_dac_fix = 1,
14543 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14544 .adc_nids = alc861_adc_nids,
14545 .input_mux = &alc861_capture_source,
14546 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014547 [ALC861_TOSHIBA] = {
14548 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014549 .init_verbs = { alc861_base_init_verbs,
14550 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014551 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14552 .dac_nids = alc861_dac_nids,
14553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14554 .channel_mode = alc883_3ST_2ch_modes,
14555 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14556 .adc_nids = alc861_adc_nids,
14557 .input_mux = &alc861_capture_source,
14558 .unsol_event = alc861_toshiba_unsol_event,
14559 .init_hook = alc861_toshiba_automute,
14560 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014561 [ALC861_ASUS] = {
14562 .mixers = { alc861_asus_mixer },
14563 .init_verbs = { alc861_asus_init_verbs },
14564 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14565 .dac_nids = alc861_dac_nids,
14566 .dig_out_nid = ALC861_DIGOUT_NID,
14567 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14568 .channel_mode = alc861_asus_modes,
14569 .need_dac_fix = 1,
14570 .hp_nid = 0x06,
14571 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14572 .adc_nids = alc861_adc_nids,
14573 .input_mux = &alc861_capture_source,
14574 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014575 [ALC861_ASUS_LAPTOP] = {
14576 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14577 .init_verbs = { alc861_asus_init_verbs,
14578 alc861_asus_laptop_init_verbs },
14579 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14580 .dac_nids = alc861_dac_nids,
14581 .dig_out_nid = ALC861_DIGOUT_NID,
14582 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14583 .channel_mode = alc883_3ST_2ch_modes,
14584 .need_dac_fix = 1,
14585 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14586 .adc_nids = alc861_adc_nids,
14587 .input_mux = &alc861_capture_source,
14588 },
14589};
Kailang Yangdf694da2005-12-05 19:42:22 +010014590
14591
14592static int patch_alc861(struct hda_codec *codec)
14593{
14594 struct alc_spec *spec;
14595 int board_config;
14596 int err;
14597
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014598 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014599 if (spec == NULL)
14600 return -ENOMEM;
14601
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014602 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014603
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014604 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14605 alc861_models,
14606 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014607
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014608 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014609 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14610 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014611 board_config = ALC861_AUTO;
14612 }
14613
14614 if (board_config == ALC861_AUTO) {
14615 /* automatic parse from the BIOS config */
14616 err = alc861_parse_auto_config(codec);
14617 if (err < 0) {
14618 alc_free(codec);
14619 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014620 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014621 printk(KERN_INFO
14622 "hda_codec: Cannot set up configuration "
14623 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014624 board_config = ALC861_3ST_DIG;
14625 }
14626 }
14627
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014628 err = snd_hda_attach_beep_device(codec, 0x23);
14629 if (err < 0) {
14630 alc_free(codec);
14631 return err;
14632 }
14633
Kailang Yangdf694da2005-12-05 19:42:22 +010014634 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014635 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014636
Kailang Yangdf694da2005-12-05 19:42:22 +010014637 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14638 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14639
Kailang Yangdf694da2005-12-05 19:42:22 +010014640 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14641 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14642
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014643 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14644
Takashi Iwai2134ea42008-01-10 16:53:55 +010014645 spec->vmaster_nid = 0x03;
14646
Kailang Yangdf694da2005-12-05 19:42:22 +010014647 codec->patch_ops = alc_patch_ops;
14648 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014649 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014650#ifdef CONFIG_SND_HDA_POWER_SAVE
14651 if (!spec->loopback.amplist)
14652 spec->loopback.amplist = alc861_loopbacks;
14653#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014654 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014655
Kailang Yangdf694da2005-12-05 19:42:22 +010014656 return 0;
14657}
14658
14659/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014660 * ALC861-VD support
14661 *
14662 * Based on ALC882
14663 *
14664 * In addition, an independent DAC
14665 */
14666#define ALC861VD_DIGOUT_NID 0x06
14667
14668static hda_nid_t alc861vd_dac_nids[4] = {
14669 /* front, surr, clfe, side surr */
14670 0x02, 0x03, 0x04, 0x05
14671};
14672
14673/* dac_nids for ALC660vd are in a different order - according to
14674 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014675 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014676 * of ALC660vd codecs, but for now there is only 3stack mixer
14677 * - and it is the same as in 861vd.
14678 * adc_nids in ALC660vd are (is) the same as in 861vd
14679 */
14680static hda_nid_t alc660vd_dac_nids[3] = {
14681 /* front, rear, clfe, rear_surr */
14682 0x02, 0x04, 0x03
14683};
14684
14685static hda_nid_t alc861vd_adc_nids[1] = {
14686 /* ADC0 */
14687 0x09,
14688};
14689
Takashi Iwaie1406342008-02-11 18:32:32 +010014690static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14691
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014692/* input MUX */
14693/* FIXME: should be a matrix-type input source selection */
14694static struct hda_input_mux alc861vd_capture_source = {
14695 .num_items = 4,
14696 .items = {
14697 { "Mic", 0x0 },
14698 { "Front Mic", 0x1 },
14699 { "Line", 0x2 },
14700 { "CD", 0x4 },
14701 },
14702};
14703
Kailang Yang272a5272007-05-14 11:00:38 +020014704static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014705 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014706 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014707 { "Ext Mic", 0x0 },
14708 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014709 },
14710};
14711
Kailang Yangd1a991a2007-08-15 16:21:59 +020014712static struct hda_input_mux alc861vd_hp_capture_source = {
14713 .num_items = 2,
14714 .items = {
14715 { "Front Mic", 0x0 },
14716 { "ATAPI Mic", 0x1 },
14717 },
14718};
14719
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014720/*
14721 * 2ch mode
14722 */
14723static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14724 { 2, NULL }
14725};
14726
14727/*
14728 * 6ch mode
14729 */
14730static struct hda_verb alc861vd_6stack_ch6_init[] = {
14731 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14732 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14733 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14734 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14735 { } /* end */
14736};
14737
14738/*
14739 * 8ch mode
14740 */
14741static struct hda_verb alc861vd_6stack_ch8_init[] = {
14742 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14743 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14744 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14745 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14746 { } /* end */
14747};
14748
14749static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14750 { 6, alc861vd_6stack_ch6_init },
14751 { 8, alc861vd_6stack_ch8_init },
14752};
14753
14754static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14755 {
14756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14757 .name = "Channel Mode",
14758 .info = alc_ch_mode_info,
14759 .get = alc_ch_mode_get,
14760 .put = alc_ch_mode_put,
14761 },
14762 { } /* end */
14763};
14764
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014765/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14766 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14767 */
14768static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14769 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14770 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14771
14772 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14773 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14774
14775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14776 HDA_OUTPUT),
14777 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14778 HDA_OUTPUT),
14779 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14780 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14781
14782 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14783 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14784
14785 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14786
14787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14790
14791 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14792 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14793 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14794
14795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14797
14798 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14799 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14800
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014801 { } /* end */
14802};
14803
14804static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14805 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14807
14808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14809
14810 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14813
14814 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14817
14818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14820
14821 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14822 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14823
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014824 { } /* end */
14825};
14826
Kailang Yangbdd148a2007-05-08 15:19:08 +020014827static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14828 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14829 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14830 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14831
14832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14833
14834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14837
14838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14839 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14840 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14841
14842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14844
14845 { } /* end */
14846};
14847
Tobin Davisb419f342008-03-07 11:57:51 +010014848/* Pin assignment: Speaker=0x14, HP = 0x15,
14849 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014850 */
14851static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014852 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14853 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014856 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14857 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14858 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14859 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14860 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14861 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014862 { } /* end */
14863};
14864
Kailang Yangd1a991a2007-08-15 16:21:59 +020014865/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14866 * Front Mic=0x18, ATAPI Mic = 0x19,
14867 */
14868static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14869 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14870 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14871 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14872 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14874 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14875 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14876 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014877
Kailang Yangd1a991a2007-08-15 16:21:59 +020014878 { } /* end */
14879};
14880
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014881/*
14882 * generic initialization of ADC, input mixers and output mixers
14883 */
14884static struct hda_verb alc861vd_volume_init_verbs[] = {
14885 /*
14886 * Unmute ADC0 and set the default input to mic-in
14887 */
14888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14890
14891 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14892 * the analog-loopback mixer widget
14893 */
14894 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014900
14901 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014906
14907 /*
14908 * Set up output mixers (0x02 - 0x05)
14909 */
14910 /* set vol=0 to output mixers */
14911 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14912 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14913 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14914 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14915
14916 /* set up input amps for analog loopback */
14917 /* Amp Indices: DAC = 0, mixer = 1 */
14918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14926
14927 { }
14928};
14929
14930/*
14931 * 3-stack pin configuration:
14932 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14933 */
14934static struct hda_verb alc861vd_3stack_init_verbs[] = {
14935 /*
14936 * Set pin mode and muting
14937 */
14938 /* set front pin widgets 0x14 for output */
14939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14940 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14941 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14942
14943 /* Mic (rear) pin: input vref at 80% */
14944 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14945 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14946 /* Front Mic pin: input vref at 80% */
14947 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14948 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14949 /* Line In pin: input */
14950 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14951 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14952 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14953 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14954 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14955 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14956 /* CD pin widget for input */
14957 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14958
14959 { }
14960};
14961
14962/*
14963 * 6-stack pin configuration:
14964 */
14965static struct hda_verb alc861vd_6stack_init_verbs[] = {
14966 /*
14967 * Set pin mode and muting
14968 */
14969 /* set front pin widgets 0x14 for output */
14970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14972 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14973
14974 /* Rear Pin: output 1 (0x0d) */
14975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14977 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14978 /* CLFE Pin: output 2 (0x0e) */
14979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14980 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14981 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14982 /* Side Pin: output 3 (0x0f) */
14983 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14985 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14986
14987 /* Mic (rear) pin: input vref at 80% */
14988 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14990 /* Front Mic pin: input vref at 80% */
14991 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14992 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14993 /* Line In pin: input */
14994 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14995 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14996 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14999 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15000 /* CD pin widget for input */
15001 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15002
15003 { }
15004};
15005
Kailang Yangbdd148a2007-05-08 15:19:08 +020015006static struct hda_verb alc861vd_eapd_verbs[] = {
15007 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15008 { }
15009};
15010
Kailang Yangf9423e72008-05-27 12:32:25 +020015011static struct hda_verb alc660vd_eapd_verbs[] = {
15012 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15013 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15014 { }
15015};
15016
Kailang Yangbdd148a2007-05-08 15:19:08 +020015017static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15021 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015022 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015023 {}
15024};
15025
Kailang Yangbdd148a2007-05-08 15:19:08 +020015026static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15027{
15028 unsigned int present;
15029 unsigned char bits;
15030
15031 present = snd_hda_codec_read(codec, 0x18, 0,
15032 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015033 bits = present ? HDA_AMP_MUTE : 0;
15034 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15035 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015036}
15037
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015038static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015039{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015040 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015041 spec->autocfg.hp_pins[0] = 0x1b;
15042 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015043}
15044
15045static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15046{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015047 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015048 alc861vd_lenovo_mic_automute(codec);
15049}
15050
15051static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15052 unsigned int res)
15053{
15054 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015055 case ALC880_MIC_EVENT:
15056 alc861vd_lenovo_mic_automute(codec);
15057 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015058 default:
15059 alc_automute_amp_unsol_event(codec, res);
15060 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015061 }
15062}
15063
Kailang Yang272a5272007-05-14 11:00:38 +020015064static struct hda_verb alc861vd_dallas_verbs[] = {
15065 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15066 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15067 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15068 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15069
15070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015078
Kailang Yang272a5272007-05-14 11:00:38 +020015079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15080 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15085 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15087
15088 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15090 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15091 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15094 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15095 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15096
15097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15101
15102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015104 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15105
15106 { } /* end */
15107};
15108
15109/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015110static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015111{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015112 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015113
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015114 spec->autocfg.hp_pins[0] = 0x15;
15115 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015116}
15117
Takashi Iwaicb53c622007-08-10 17:21:45 +020015118#ifdef CONFIG_SND_HDA_POWER_SAVE
15119#define alc861vd_loopbacks alc880_loopbacks
15120#endif
15121
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015122/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015123#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15124#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15125#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15126#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15127
15128/*
15129 * configuration and preset
15130 */
15131static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15132 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015133 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015134 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015135 [ALC861VD_3ST] = "3stack",
15136 [ALC861VD_3ST_DIG] = "3stack-digout",
15137 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015138 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015139 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015140 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015141 [ALC861VD_AUTO] = "auto",
15142};
15143
15144static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015145 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15146 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015147 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015148 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015149 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015150 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015151 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015152 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015153 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015154 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015155 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015156 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015157 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015158 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015159 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015160 {}
15161};
15162
15163static struct alc_config_preset alc861vd_presets[] = {
15164 [ALC660VD_3ST] = {
15165 .mixers = { alc861vd_3st_mixer },
15166 .init_verbs = { alc861vd_volume_init_verbs,
15167 alc861vd_3stack_init_verbs },
15168 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15169 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015170 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15171 .channel_mode = alc861vd_3stack_2ch_modes,
15172 .input_mux = &alc861vd_capture_source,
15173 },
Mike Crash6963f842007-06-25 12:12:51 +020015174 [ALC660VD_3ST_DIG] = {
15175 .mixers = { alc861vd_3st_mixer },
15176 .init_verbs = { alc861vd_volume_init_verbs,
15177 alc861vd_3stack_init_verbs },
15178 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15179 .dac_nids = alc660vd_dac_nids,
15180 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015181 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15182 .channel_mode = alc861vd_3stack_2ch_modes,
15183 .input_mux = &alc861vd_capture_source,
15184 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015185 [ALC861VD_3ST] = {
15186 .mixers = { alc861vd_3st_mixer },
15187 .init_verbs = { alc861vd_volume_init_verbs,
15188 alc861vd_3stack_init_verbs },
15189 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15190 .dac_nids = alc861vd_dac_nids,
15191 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15192 .channel_mode = alc861vd_3stack_2ch_modes,
15193 .input_mux = &alc861vd_capture_source,
15194 },
15195 [ALC861VD_3ST_DIG] = {
15196 .mixers = { alc861vd_3st_mixer },
15197 .init_verbs = { alc861vd_volume_init_verbs,
15198 alc861vd_3stack_init_verbs },
15199 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15200 .dac_nids = alc861vd_dac_nids,
15201 .dig_out_nid = ALC861VD_DIGOUT_NID,
15202 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15203 .channel_mode = alc861vd_3stack_2ch_modes,
15204 .input_mux = &alc861vd_capture_source,
15205 },
15206 [ALC861VD_6ST_DIG] = {
15207 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15208 .init_verbs = { alc861vd_volume_init_verbs,
15209 alc861vd_6stack_init_verbs },
15210 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15211 .dac_nids = alc861vd_dac_nids,
15212 .dig_out_nid = ALC861VD_DIGOUT_NID,
15213 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15214 .channel_mode = alc861vd_6stack_modes,
15215 .input_mux = &alc861vd_capture_source,
15216 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015217 [ALC861VD_LENOVO] = {
15218 .mixers = { alc861vd_lenovo_mixer },
15219 .init_verbs = { alc861vd_volume_init_verbs,
15220 alc861vd_3stack_init_verbs,
15221 alc861vd_eapd_verbs,
15222 alc861vd_lenovo_unsol_verbs },
15223 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15224 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015225 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15226 .channel_mode = alc861vd_3stack_2ch_modes,
15227 .input_mux = &alc861vd_capture_source,
15228 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015229 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015230 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015231 },
Kailang Yang272a5272007-05-14 11:00:38 +020015232 [ALC861VD_DALLAS] = {
15233 .mixers = { alc861vd_dallas_mixer },
15234 .init_verbs = { alc861vd_dallas_verbs },
15235 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15236 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015237 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15238 .channel_mode = alc861vd_3stack_2ch_modes,
15239 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015240 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015241 .setup = alc861vd_dallas_setup,
15242 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015243 },
15244 [ALC861VD_HP] = {
15245 .mixers = { alc861vd_hp_mixer },
15246 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15247 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15248 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015249 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015250 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15251 .channel_mode = alc861vd_3stack_2ch_modes,
15252 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015253 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015254 .setup = alc861vd_dallas_setup,
15255 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015256 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015257 [ALC660VD_ASUS_V1S] = {
15258 .mixers = { alc861vd_lenovo_mixer },
15259 .init_verbs = { alc861vd_volume_init_verbs,
15260 alc861vd_3stack_init_verbs,
15261 alc861vd_eapd_verbs,
15262 alc861vd_lenovo_unsol_verbs },
15263 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15264 .dac_nids = alc660vd_dac_nids,
15265 .dig_out_nid = ALC861VD_DIGOUT_NID,
15266 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15267 .channel_mode = alc861vd_3stack_2ch_modes,
15268 .input_mux = &alc861vd_capture_source,
15269 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015270 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015271 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015272 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015273};
15274
15275/*
15276 * BIOS auto configuration
15277 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015278static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15279 const struct auto_pin_cfg *cfg)
15280{
15281 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15282}
15283
15284
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015285static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15286 hda_nid_t nid, int pin_type, int dac_idx)
15287{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015288 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015289}
15290
15291static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15292{
15293 struct alc_spec *spec = codec->spec;
15294 int i;
15295
15296 for (i = 0; i <= HDA_SIDE; i++) {
15297 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015298 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015299 if (nid)
15300 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015301 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015302 }
15303}
15304
15305
15306static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15307{
15308 struct alc_spec *spec = codec->spec;
15309 hda_nid_t pin;
15310
15311 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015312 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015313 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015314 pin = spec->autocfg.speaker_pins[0];
15315 if (pin)
15316 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015317}
15318
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015319#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15320
15321static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15322{
15323 struct alc_spec *spec = codec->spec;
15324 int i;
15325
15326 for (i = 0; i < AUTO_PIN_LAST; i++) {
15327 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015328 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015329 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015330 if (nid != ALC861VD_PIN_CD_NID &&
15331 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332 snd_hda_codec_write(codec, nid, 0,
15333 AC_VERB_SET_AMP_GAIN_MUTE,
15334 AMP_OUT_MUTE);
15335 }
15336 }
15337}
15338
Takashi Iwaif511b012008-08-15 16:46:42 +020015339#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15340
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015341#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15342#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15343
15344/* add playback controls from the parsed DAC table */
15345/* Based on ALC880 version. But ALC861VD has separate,
15346 * different NIDs for mute/unmute switch and volume control */
15347static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15348 const struct auto_pin_cfg *cfg)
15349{
15350 char name[32];
15351 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15352 hda_nid_t nid_v, nid_s;
15353 int i, err;
15354
15355 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015356 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015357 continue;
15358 nid_v = alc861vd_idx_to_mixer_vol(
15359 alc880_dac_to_idx(
15360 spec->multiout.dac_nids[i]));
15361 nid_s = alc861vd_idx_to_mixer_switch(
15362 alc880_dac_to_idx(
15363 spec->multiout.dac_nids[i]));
15364
15365 if (i == 2) {
15366 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015367 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15368 "Center Playback Volume",
15369 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15370 HDA_OUTPUT));
15371 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015372 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015373 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15374 "LFE Playback Volume",
15375 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15376 HDA_OUTPUT));
15377 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015378 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015379 err = add_control(spec, ALC_CTL_BIND_MUTE,
15380 "Center Playback Switch",
15381 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15382 HDA_INPUT));
15383 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015384 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015385 err = add_control(spec, ALC_CTL_BIND_MUTE,
15386 "LFE Playback Switch",
15387 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15388 HDA_INPUT));
15389 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015390 return err;
15391 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015392 const char *pfx;
15393 if (cfg->line_outs == 1 &&
15394 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15395 if (!cfg->hp_pins)
15396 pfx = "Speaker";
15397 else
15398 pfx = "PCM";
15399 } else
15400 pfx = chname[i];
15401 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015402 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15403 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15404 HDA_OUTPUT));
15405 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015406 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015407 if (cfg->line_outs == 1 &&
15408 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15409 pfx = "Speaker";
15410 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015411 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015412 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015413 HDA_INPUT));
15414 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015415 return err;
15416 }
15417 }
15418 return 0;
15419}
15420
15421/* add playback controls for speaker and HP outputs */
15422/* Based on ALC880 version. But ALC861VD has separate,
15423 * different NIDs for mute/unmute switch and volume control */
15424static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15425 hda_nid_t pin, const char *pfx)
15426{
15427 hda_nid_t nid_v, nid_s;
15428 int err;
15429 char name[32];
15430
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015431 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015432 return 0;
15433
15434 if (alc880_is_fixed_pin(pin)) {
15435 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15436 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015437 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015438 spec->multiout.hp_nid = nid_v;
15439 else
15440 spec->multiout.extra_out_nid[0] = nid_v;
15441 /* control HP volume/switch on the output mixer amp */
15442 nid_v = alc861vd_idx_to_mixer_vol(
15443 alc880_fixed_pin_idx(pin));
15444 nid_s = alc861vd_idx_to_mixer_switch(
15445 alc880_fixed_pin_idx(pin));
15446
15447 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015448 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15449 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15450 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015451 return err;
15452 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015453 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15454 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15455 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015456 return err;
15457 } else if (alc880_is_multi_pin(pin)) {
15458 /* set manual connection */
15459 /* we have only a switch on HP-out PIN */
15460 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015461 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15462 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15463 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015464 return err;
15465 }
15466 return 0;
15467}
15468
15469/* parse the BIOS configuration and set up the alc_spec
15470 * return 1 if successful, 0 if the proper config is not found,
15471 * or a negative error code
15472 * Based on ALC880 version - had to change it to override
15473 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15474static int alc861vd_parse_auto_config(struct hda_codec *codec)
15475{
15476 struct alc_spec *spec = codec->spec;
15477 int err;
15478 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15479
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015480 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15481 alc861vd_ignore);
15482 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015483 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015484 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015485 return 0; /* can't find valid BIOS pin config */
15486
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015487 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15488 if (err < 0)
15489 return err;
15490 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15491 if (err < 0)
15492 return err;
15493 err = alc861vd_auto_create_extra_out(spec,
15494 spec->autocfg.speaker_pins[0],
15495 "Speaker");
15496 if (err < 0)
15497 return err;
15498 err = alc861vd_auto_create_extra_out(spec,
15499 spec->autocfg.hp_pins[0],
15500 "Headphone");
15501 if (err < 0)
15502 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015503 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015504 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015505 return err;
15506
15507 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15508
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015509 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015510 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15511
Takashi Iwai603c4012008-07-30 15:01:44 +020015512 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015513 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015514
Takashi Iwaid88897e2008-10-31 15:01:37 +010015515 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015516
15517 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015518 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015519
Takashi Iwai776e1842007-08-29 15:07:11 +020015520 err = alc_auto_add_mic_boost(codec);
15521 if (err < 0)
15522 return err;
15523
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015524 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15525
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015526 return 1;
15527}
15528
15529/* additional initialization for auto-configuration model */
15530static void alc861vd_auto_init(struct hda_codec *codec)
15531{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015532 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015533 alc861vd_auto_init_multi_out(codec);
15534 alc861vd_auto_init_hp_out(codec);
15535 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015536 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015537 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015538 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015539}
15540
15541static int patch_alc861vd(struct hda_codec *codec)
15542{
15543 struct alc_spec *spec;
15544 int err, board_config;
15545
15546 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15547 if (spec == NULL)
15548 return -ENOMEM;
15549
15550 codec->spec = spec;
15551
15552 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15553 alc861vd_models,
15554 alc861vd_cfg_tbl);
15555
15556 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015557 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15558 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015559 board_config = ALC861VD_AUTO;
15560 }
15561
15562 if (board_config == ALC861VD_AUTO) {
15563 /* automatic parse from the BIOS config */
15564 err = alc861vd_parse_auto_config(codec);
15565 if (err < 0) {
15566 alc_free(codec);
15567 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015568 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015569 printk(KERN_INFO
15570 "hda_codec: Cannot set up configuration "
15571 "from BIOS. Using base mode...\n");
15572 board_config = ALC861VD_3ST;
15573 }
15574 }
15575
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015576 err = snd_hda_attach_beep_device(codec, 0x23);
15577 if (err < 0) {
15578 alc_free(codec);
15579 return err;
15580 }
15581
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015582 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015583 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015584
Kailang Yang2f893282008-05-27 12:14:47 +020015585 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015586 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015587 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015588 }
15589
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015590 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15591 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15592
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015593 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15594 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15595
Takashi Iwaidd704692009-08-11 08:45:11 +020015596 if (!spec->adc_nids) {
15597 spec->adc_nids = alc861vd_adc_nids;
15598 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15599 }
15600 if (!spec->capsrc_nids)
15601 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015602
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015603 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015604 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015605
Takashi Iwai2134ea42008-01-10 16:53:55 +010015606 spec->vmaster_nid = 0x02;
15607
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015608 codec->patch_ops = alc_patch_ops;
15609
15610 if (board_config == ALC861VD_AUTO)
15611 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015612#ifdef CONFIG_SND_HDA_POWER_SAVE
15613 if (!spec->loopback.amplist)
15614 spec->loopback.amplist = alc861vd_loopbacks;
15615#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015616 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015617
15618 return 0;
15619}
15620
15621/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015622 * ALC662 support
15623 *
15624 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15625 * configuration. Each pin widget can choose any input DACs and a mixer.
15626 * Each ADC is connected from a mixer of all inputs. This makes possible
15627 * 6-channel independent captures.
15628 *
15629 * In addition, an independent DAC for the multi-playback (not used in this
15630 * driver yet).
15631 */
15632#define ALC662_DIGOUT_NID 0x06
15633#define ALC662_DIGIN_NID 0x0a
15634
15635static hda_nid_t alc662_dac_nids[4] = {
15636 /* front, rear, clfe, rear_surr */
15637 0x02, 0x03, 0x04
15638};
15639
Kailang Yang622e84c2009-04-21 07:39:04 +020015640static hda_nid_t alc272_dac_nids[2] = {
15641 0x02, 0x03
15642};
15643
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015644static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015645 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015646 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015647};
Takashi Iwaie1406342008-02-11 18:32:32 +010015648
Kailang Yang622e84c2009-04-21 07:39:04 +020015649static hda_nid_t alc272_adc_nids[1] = {
15650 /* ADC1-2 */
15651 0x08,
15652};
15653
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015654static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015655static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15656
Takashi Iwaie1406342008-02-11 18:32:32 +010015657
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015658/* input MUX */
15659/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015660static struct hda_input_mux alc662_capture_source = {
15661 .num_items = 4,
15662 .items = {
15663 { "Mic", 0x0 },
15664 { "Front Mic", 0x1 },
15665 { "Line", 0x2 },
15666 { "CD", 0x4 },
15667 },
15668};
15669
15670static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15671 .num_items = 2,
15672 .items = {
15673 { "Mic", 0x1 },
15674 { "Line", 0x2 },
15675 },
15676};
Kailang Yang291702f2007-10-16 14:28:03 +020015677
Kailang Yang6dda9f42008-05-27 12:05:31 +020015678static struct hda_input_mux alc663_capture_source = {
15679 .num_items = 3,
15680 .items = {
15681 { "Mic", 0x0 },
15682 { "Front Mic", 0x1 },
15683 { "Line", 0x2 },
15684 },
15685};
15686
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015687#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015688static struct hda_input_mux alc272_nc10_capture_source = {
15689 .num_items = 16,
15690 .items = {
15691 { "Autoselect Mic", 0x0 },
15692 { "Internal Mic", 0x1 },
15693 { "In-0x02", 0x2 },
15694 { "In-0x03", 0x3 },
15695 { "In-0x04", 0x4 },
15696 { "In-0x05", 0x5 },
15697 { "In-0x06", 0x6 },
15698 { "In-0x07", 0x7 },
15699 { "In-0x08", 0x8 },
15700 { "In-0x09", 0x9 },
15701 { "In-0x0a", 0x0a },
15702 { "In-0x0b", 0x0b },
15703 { "In-0x0c", 0x0c },
15704 { "In-0x0d", 0x0d },
15705 { "In-0x0e", 0x0e },
15706 { "In-0x0f", 0x0f },
15707 },
15708};
15709#endif
15710
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015711/*
15712 * 2ch mode
15713 */
15714static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15715 { 2, NULL }
15716};
15717
15718/*
15719 * 2ch mode
15720 */
15721static struct hda_verb alc662_3ST_ch2_init[] = {
15722 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15723 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15724 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15725 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15726 { } /* end */
15727};
15728
15729/*
15730 * 6ch mode
15731 */
15732static struct hda_verb alc662_3ST_ch6_init[] = {
15733 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15734 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15735 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15736 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15737 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15738 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15739 { } /* end */
15740};
15741
15742static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15743 { 2, alc662_3ST_ch2_init },
15744 { 6, alc662_3ST_ch6_init },
15745};
15746
15747/*
15748 * 2ch mode
15749 */
15750static struct hda_verb alc662_sixstack_ch6_init[] = {
15751 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15752 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15753 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15754 { } /* end */
15755};
15756
15757/*
15758 * 6ch mode
15759 */
15760static struct hda_verb alc662_sixstack_ch8_init[] = {
15761 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15762 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15763 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15764 { } /* end */
15765};
15766
15767static struct hda_channel_mode alc662_5stack_modes[2] = {
15768 { 2, alc662_sixstack_ch6_init },
15769 { 6, alc662_sixstack_ch8_init },
15770};
15771
15772/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15773 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15774 */
15775
15776static struct snd_kcontrol_new alc662_base_mixer[] = {
15777 /* output mixer control */
15778 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015779 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015781 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015784 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15785 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15787
15788 /*Input mixer control */
15789 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15790 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15791 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15792 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15793 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15794 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15795 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015797 { } /* end */
15798};
15799
15800static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15801 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015802 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015812 { } /* end */
15813};
15814
15815static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15816 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015817 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015818 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015819 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015820 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15821 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015822 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15823 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015824 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15827 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15828 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15830 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15831 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15832 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015833 { } /* end */
15834};
15835
15836static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15837 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15838 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15840 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15842 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15843 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015846 { } /* end */
15847};
15848
Kailang Yang291702f2007-10-16 14:28:03 +020015849static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015850 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15851 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015852
15853 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15854 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15855 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15856
15857 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15858 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15859 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15860 { } /* end */
15861};
15862
Kailang Yang8c427222008-01-10 13:03:59 +010015863static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015864 ALC262_HIPPO_MASTER_SWITCH,
15865 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015866 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15868 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015869 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15874 { } /* end */
15875};
15876
Kailang Yangf1d4e282008-08-26 14:03:29 +020015877static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15878 .ops = &snd_hda_bind_vol,
15879 .values = {
15880 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15881 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15882 0
15883 },
15884};
15885
15886static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15887 .ops = &snd_hda_bind_sw,
15888 .values = {
15889 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15890 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15891 0
15892 },
15893};
15894
Kailang Yang6dda9f42008-05-27 12:05:31 +020015895static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015896 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15897 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15900 { } /* end */
15901};
15902
15903static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15904 .ops = &snd_hda_bind_sw,
15905 .values = {
15906 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15907 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15908 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15909 0
15910 },
15911};
15912
15913static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15914 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15915 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15917 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15918 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15919 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15920
15921 { } /* end */
15922};
15923
15924static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15925 .ops = &snd_hda_bind_sw,
15926 .values = {
15927 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15928 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15929 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15930 0
15931 },
15932};
15933
15934static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15935 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15936 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15939 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15940 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15941 { } /* end */
15942};
15943
15944static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015945 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15946 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15950 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15951 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15952 { } /* end */
15953};
15954
15955static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15956 .ops = &snd_hda_bind_vol,
15957 .values = {
15958 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15959 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15960 0
15961 },
15962};
15963
15964static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15965 .ops = &snd_hda_bind_sw,
15966 .values = {
15967 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15968 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15969 0
15970 },
15971};
15972
15973static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15974 HDA_BIND_VOL("Master Playback Volume",
15975 &alc663_asus_two_bind_master_vol),
15976 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15977 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015981 { } /* end */
15982};
15983
15984static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15985 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15986 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15987 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015991 { } /* end */
15992};
15993
15994static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15995 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15996 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15997 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15998 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16000
16001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16003 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16004 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16005 { } /* end */
16006};
16007
16008static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16009 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16010 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16012
16013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16015 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16016 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16019 { } /* end */
16020};
16021
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016022static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16023 {
16024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16025 .name = "Channel Mode",
16026 .info = alc_ch_mode_info,
16027 .get = alc_ch_mode_get,
16028 .put = alc_ch_mode_put,
16029 },
16030 { } /* end */
16031};
16032
16033static struct hda_verb alc662_init_verbs[] = {
16034 /* ADC: mute amp left and right */
16035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16036 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16037 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16038
Takashi Iwaicb53c622007-08-10 17:21:45 +020016039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016044
Kailang Yangb60dd392007-09-20 12:50:29 +020016045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16050 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016051
16052 /* Front Pin: output 0 (0x0c) */
16053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16055
16056 /* Rear Pin: output 1 (0x0d) */
16057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16059
16060 /* CLFE Pin: output 2 (0x0e) */
16061 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16062 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16063
16064 /* Mic (rear) pin: input vref at 80% */
16065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16066 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16067 /* Front Mic pin: input vref at 80% */
16068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16070 /* Line In pin: input */
16071 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16072 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16073 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16074 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16075 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16076 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16077 /* CD pin widget for input */
16078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16079
16080 /* FIXME: use matrix-type input source selection */
16081 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16082 /* Input mixer */
16083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016085
16086 /* always trun on EAPD */
16087 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16088 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16089
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016090 { }
16091};
16092
16093static struct hda_verb alc662_sue_init_verbs[] = {
16094 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16095 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016096 {}
16097};
16098
16099static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16100 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16101 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16102 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016103};
16104
Kailang Yang8c427222008-01-10 13:03:59 +010016105/* Set Unsolicited Event*/
16106static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16107 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16108 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16109 {}
16110};
16111
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016112/*
16113 * generic initialization of ADC, input mixers and output mixers
16114 */
16115static struct hda_verb alc662_auto_init_verbs[] = {
16116 /*
16117 * Unmute ADC and set the default input to mic-in
16118 */
16119 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16121
16122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16123 * mixer widget
16124 * Note: PASD motherboards uses the Line In 2 as the input for front
16125 * panel mic (mic 2)
16126 */
16127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016133
16134 /*
16135 * Set up output mixers (0x0c - 0x0f)
16136 */
16137 /* set vol=0 to output mixers */
16138 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16139 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16141
16142 /* set up input amps for analog loopback */
16143 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016150
16151
16152 /* FIXME: use matrix-type input source selection */
16153 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16154 /* Input mixer */
16155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016157 { }
16158};
16159
Takashi Iwai24fb9172008-09-02 14:48:20 +020016160/* additional verbs for ALC663 */
16161static struct hda_verb alc663_auto_init_verbs[] = {
16162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16164 { }
16165};
16166
Kailang Yang6dda9f42008-05-27 12:05:31 +020016167static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016170 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16171 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016172 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016175 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16176 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16177 {}
16178};
16179
Kailang Yangf1d4e282008-08-26 14:03:29 +020016180static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16181 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16182 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16183 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16186 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16187 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16188 {}
16189};
16190
16191static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16198 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16199 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16200 {}
16201};
16202
16203static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16206 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16209 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16211 {}
16212};
16213
16214static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16216 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16217 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16218 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16224 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16225 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16227 {}
16228};
16229
16230static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16233 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16234 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16237 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16240 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16241 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16243 {}
16244};
16245
Kailang Yang6dda9f42008-05-27 12:05:31 +020016246static struct hda_verb alc663_g71v_init_verbs[] = {
16247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16248 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16249 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16250
16251 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16252 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16253 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16254
16255 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16256 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16257 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16258 {}
16259};
16260
16261static struct hda_verb alc663_g50v_init_verbs[] = {
16262 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16263 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16264 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16265
16266 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16267 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16268 {}
16269};
16270
Kailang Yangf1d4e282008-08-26 14:03:29 +020016271static struct hda_verb alc662_ecs_init_verbs[] = {
16272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16274 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16275 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16276 {}
16277};
16278
Kailang Yang622e84c2009-04-21 07:39:04 +020016279static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16280 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16281 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16283 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16284 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16285 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16286 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16289 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16290 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16291 {}
16292};
16293
16294static struct hda_verb alc272_dell_init_verbs[] = {
16295 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16296 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16298 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16299 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16300 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16301 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16302 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16304 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16305 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16306 {}
16307};
16308
Kailang Yangf1d4e282008-08-26 14:03:29 +020016309static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16310 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16311 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16312 { } /* end */
16313};
16314
Kailang Yang622e84c2009-04-21 07:39:04 +020016315static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16316 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16317 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16318 { } /* end */
16319};
16320
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016321static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16322{
16323 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016324 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325
16326 present = snd_hda_codec_read(codec, 0x14, 0,
16327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016328 bits = present ? HDA_AMP_MUTE : 0;
16329 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16330 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016331}
16332
16333static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16334{
16335 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016336 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016337
16338 present = snd_hda_codec_read(codec, 0x1b, 0,
16339 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016340 bits = present ? HDA_AMP_MUTE : 0;
16341 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16342 HDA_AMP_MUTE, bits);
16343 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16344 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016345}
16346
16347static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16348 unsigned int res)
16349{
16350 if ((res >> 26) == ALC880_HP_EVENT)
16351 alc662_lenovo_101e_all_automute(codec);
16352 if ((res >> 26) == ALC880_FRONT_EVENT)
16353 alc662_lenovo_101e_ispeaker_automute(codec);
16354}
16355
Kailang Yang291702f2007-10-16 14:28:03 +020016356/* unsolicited event for HP jack sensing */
16357static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16358 unsigned int res)
16359{
Kailang Yang291702f2007-10-16 14:28:03 +020016360 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016361 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016362 else
16363 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016364}
16365
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016366static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016367{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016368 struct alc_spec *spec = codec->spec;
16369
16370 alc262_hippo1_setup(codec);
16371 spec->ext_mic.pin = 0x18;
16372 spec->ext_mic.mux_idx = 0;
16373 spec->int_mic.pin = 0x19;
16374 spec->int_mic.mux_idx = 1;
16375 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016376}
16377
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016378static void alc662_eeepc_inithook(struct hda_codec *codec)
16379{
16380 alc262_hippo_automute(codec);
16381 alc_mic_automute(codec);
16382}
16383
16384static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016385{
Takashi Iwai42171c12009-05-08 14:11:43 +020016386 struct alc_spec *spec = codec->spec;
16387
16388 spec->autocfg.hp_pins[0] = 0x14;
16389 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016390}
16391
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016392#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16393
Kailang Yang6dda9f42008-05-27 12:05:31 +020016394static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16395{
16396 unsigned int present;
16397 unsigned char bits;
16398
16399 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016400 AC_VERB_GET_PIN_SENSE, 0)
16401 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016402 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016403 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16404 AMP_IN_MUTE(0), bits);
16405 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16406 AMP_IN_MUTE(0), bits);
16407}
16408
16409static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16410{
16411 unsigned int present;
16412 unsigned char bits;
16413
16414 present = snd_hda_codec_read(codec, 0x21, 0,
16415 AC_VERB_GET_PIN_SENSE, 0)
16416 & AC_PINSENSE_PRESENCE;
16417 bits = present ? HDA_AMP_MUTE : 0;
16418 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16419 AMP_IN_MUTE(0), bits);
16420 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16421 AMP_IN_MUTE(0), bits);
16422 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16423 AMP_IN_MUTE(0), bits);
16424 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16425 AMP_IN_MUTE(0), bits);
16426}
16427
16428static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16429{
16430 unsigned int present;
16431 unsigned char bits;
16432
16433 present = snd_hda_codec_read(codec, 0x15, 0,
16434 AC_VERB_GET_PIN_SENSE, 0)
16435 & AC_PINSENSE_PRESENCE;
16436 bits = present ? HDA_AMP_MUTE : 0;
16437 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16438 AMP_IN_MUTE(0), bits);
16439 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16440 AMP_IN_MUTE(0), bits);
16441 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16442 AMP_IN_MUTE(0), bits);
16443 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16444 AMP_IN_MUTE(0), bits);
16445}
16446
16447static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16448{
16449 unsigned int present;
16450 unsigned char bits;
16451
16452 present = snd_hda_codec_read(codec, 0x1b, 0,
16453 AC_VERB_GET_PIN_SENSE, 0)
16454 & AC_PINSENSE_PRESENCE;
16455 bits = present ? 0 : PIN_OUT;
16456 snd_hda_codec_write(codec, 0x14, 0,
16457 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16458}
16459
16460static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16461{
16462 unsigned int present1, present2;
16463
16464 present1 = snd_hda_codec_read(codec, 0x21, 0,
16465 AC_VERB_GET_PIN_SENSE, 0)
16466 & AC_PINSENSE_PRESENCE;
16467 present2 = snd_hda_codec_read(codec, 0x15, 0,
16468 AC_VERB_GET_PIN_SENSE, 0)
16469 & AC_PINSENSE_PRESENCE;
16470
16471 if (present1 || present2) {
16472 snd_hda_codec_write_cache(codec, 0x14, 0,
16473 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16474 } else {
16475 snd_hda_codec_write_cache(codec, 0x14, 0,
16476 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16477 }
16478}
16479
16480static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16481{
16482 unsigned int present1, present2;
16483
16484 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16485 AC_VERB_GET_PIN_SENSE, 0)
16486 & AC_PINSENSE_PRESENCE;
16487 present2 = snd_hda_codec_read(codec, 0x15, 0,
16488 AC_VERB_GET_PIN_SENSE, 0)
16489 & AC_PINSENSE_PRESENCE;
16490
16491 if (present1 || present2) {
16492 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16493 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16494 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16495 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16496 } else {
16497 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16498 AMP_IN_MUTE(0), 0);
16499 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16500 AMP_IN_MUTE(0), 0);
16501 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016502}
16503
Kailang Yang6dda9f42008-05-27 12:05:31 +020016504static void alc663_m51va_unsol_event(struct hda_codec *codec,
16505 unsigned int res)
16506{
16507 switch (res >> 26) {
16508 case ALC880_HP_EVENT:
16509 alc663_m51va_speaker_automute(codec);
16510 break;
16511 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016512 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016513 break;
16514 }
16515}
16516
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016517static void alc663_m51va_setup(struct hda_codec *codec)
16518{
16519 struct alc_spec *spec = codec->spec;
16520 spec->ext_mic.pin = 0x18;
16521 spec->ext_mic.mux_idx = 0;
16522 spec->int_mic.pin = 0x12;
16523 spec->int_mic.mux_idx = 1;
16524 spec->auto_mic = 1;
16525}
16526
Kailang Yang6dda9f42008-05-27 12:05:31 +020016527static void alc663_m51va_inithook(struct hda_codec *codec)
16528{
16529 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016530 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016531}
16532
Kailang Yangf1d4e282008-08-26 14:03:29 +020016533/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016534#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16535#define alc663_mode1_setup alc663_m51va_setup
16536#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016537
Kailang Yangf1d4e282008-08-26 14:03:29 +020016538/* ***************** Mode2 ******************************/
16539static void alc662_mode2_unsol_event(struct hda_codec *codec,
16540 unsigned int res)
16541{
16542 switch (res >> 26) {
16543 case ALC880_HP_EVENT:
16544 alc662_f5z_speaker_automute(codec);
16545 break;
16546 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016547 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016548 break;
16549 }
16550}
16551
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016552#define alc662_mode2_setup alc663_m51va_setup
16553
Kailang Yangf1d4e282008-08-26 14:03:29 +020016554static void alc662_mode2_inithook(struct hda_codec *codec)
16555{
16556 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016557 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016558}
16559/* ***************** Mode3 ******************************/
16560static void alc663_mode3_unsol_event(struct hda_codec *codec,
16561 unsigned int res)
16562{
16563 switch (res >> 26) {
16564 case ALC880_HP_EVENT:
16565 alc663_two_hp_m1_speaker_automute(codec);
16566 break;
16567 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016568 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016569 break;
16570 }
16571}
16572
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016573#define alc663_mode3_setup alc663_m51va_setup
16574
Kailang Yangf1d4e282008-08-26 14:03:29 +020016575static void alc663_mode3_inithook(struct hda_codec *codec)
16576{
16577 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016578 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016579}
16580/* ***************** Mode4 ******************************/
16581static void alc663_mode4_unsol_event(struct hda_codec *codec,
16582 unsigned int res)
16583{
16584 switch (res >> 26) {
16585 case ALC880_HP_EVENT:
16586 alc663_21jd_two_speaker_automute(codec);
16587 break;
16588 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016589 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016590 break;
16591 }
16592}
16593
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016594#define alc663_mode4_setup alc663_m51va_setup
16595
Kailang Yangf1d4e282008-08-26 14:03:29 +020016596static void alc663_mode4_inithook(struct hda_codec *codec)
16597{
16598 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016599 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016600}
16601/* ***************** Mode5 ******************************/
16602static void alc663_mode5_unsol_event(struct hda_codec *codec,
16603 unsigned int res)
16604{
16605 switch (res >> 26) {
16606 case ALC880_HP_EVENT:
16607 alc663_15jd_two_speaker_automute(codec);
16608 break;
16609 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016610 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016611 break;
16612 }
16613}
16614
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016615#define alc663_mode5_setup alc663_m51va_setup
16616
Kailang Yangf1d4e282008-08-26 14:03:29 +020016617static void alc663_mode5_inithook(struct hda_codec *codec)
16618{
16619 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016620 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016621}
16622/* ***************** Mode6 ******************************/
16623static void alc663_mode6_unsol_event(struct hda_codec *codec,
16624 unsigned int res)
16625{
16626 switch (res >> 26) {
16627 case ALC880_HP_EVENT:
16628 alc663_two_hp_m2_speaker_automute(codec);
16629 break;
16630 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016631 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016632 break;
16633 }
16634}
16635
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016636#define alc663_mode6_setup alc663_m51va_setup
16637
Kailang Yangf1d4e282008-08-26 14:03:29 +020016638static void alc663_mode6_inithook(struct hda_codec *codec)
16639{
16640 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016641 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016642}
16643
Kailang Yang6dda9f42008-05-27 12:05:31 +020016644static void alc663_g71v_hp_automute(struct hda_codec *codec)
16645{
16646 unsigned int present;
16647 unsigned char bits;
16648
16649 present = snd_hda_codec_read(codec, 0x21, 0,
16650 AC_VERB_GET_PIN_SENSE, 0)
16651 & AC_PINSENSE_PRESENCE;
16652 bits = present ? HDA_AMP_MUTE : 0;
16653 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16654 HDA_AMP_MUTE, bits);
16655 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16656 HDA_AMP_MUTE, bits);
16657}
16658
16659static void alc663_g71v_front_automute(struct hda_codec *codec)
16660{
16661 unsigned int present;
16662 unsigned char bits;
16663
16664 present = snd_hda_codec_read(codec, 0x15, 0,
16665 AC_VERB_GET_PIN_SENSE, 0)
16666 & AC_PINSENSE_PRESENCE;
16667 bits = present ? HDA_AMP_MUTE : 0;
16668 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16669 HDA_AMP_MUTE, bits);
16670}
16671
16672static void alc663_g71v_unsol_event(struct hda_codec *codec,
16673 unsigned int res)
16674{
16675 switch (res >> 26) {
16676 case ALC880_HP_EVENT:
16677 alc663_g71v_hp_automute(codec);
16678 break;
16679 case ALC880_FRONT_EVENT:
16680 alc663_g71v_front_automute(codec);
16681 break;
16682 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016683 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016684 break;
16685 }
16686}
16687
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016688#define alc663_g71v_setup alc663_m51va_setup
16689
Kailang Yang6dda9f42008-05-27 12:05:31 +020016690static void alc663_g71v_inithook(struct hda_codec *codec)
16691{
16692 alc663_g71v_front_automute(codec);
16693 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016694 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016695}
16696
16697static void alc663_g50v_unsol_event(struct hda_codec *codec,
16698 unsigned int res)
16699{
16700 switch (res >> 26) {
16701 case ALC880_HP_EVENT:
16702 alc663_m51va_speaker_automute(codec);
16703 break;
16704 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016705 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016706 break;
16707 }
16708}
16709
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016710#define alc663_g50v_setup alc663_m51va_setup
16711
Kailang Yang6dda9f42008-05-27 12:05:31 +020016712static void alc663_g50v_inithook(struct hda_codec *codec)
16713{
16714 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016715 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016716}
16717
Kailang Yangf1d4e282008-08-26 14:03:29 +020016718static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16719 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016720 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016721
16722 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16723 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16724 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16725
16726 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16727 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16728 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16729 { } /* end */
16730};
16731
Chris Pockelé9541ba12009-05-12 08:08:53 +020016732static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16733 /* Master Playback automatically created from Speaker and Headphone */
16734 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16735 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16736 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16738
16739 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16740 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16741 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16742
16743 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16744 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16745 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16746 { } /* end */
16747};
16748
Takashi Iwaicb53c622007-08-10 17:21:45 +020016749#ifdef CONFIG_SND_HDA_POWER_SAVE
16750#define alc662_loopbacks alc880_loopbacks
16751#endif
16752
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016753
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016754/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016755#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16756#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16757#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16758#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16759
16760/*
16761 * configuration and preset
16762 */
16763static const char *alc662_models[ALC662_MODEL_LAST] = {
16764 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16765 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16766 [ALC662_3ST_6ch] = "3stack-6ch",
16767 [ALC662_5ST_DIG] = "6stack-dig",
16768 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016769 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016770 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016771 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016772 [ALC663_ASUS_M51VA] = "m51va",
16773 [ALC663_ASUS_G71V] = "g71v",
16774 [ALC663_ASUS_H13] = "h13",
16775 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016776 [ALC663_ASUS_MODE1] = "asus-mode1",
16777 [ALC662_ASUS_MODE2] = "asus-mode2",
16778 [ALC663_ASUS_MODE3] = "asus-mode3",
16779 [ALC663_ASUS_MODE4] = "asus-mode4",
16780 [ALC663_ASUS_MODE5] = "asus-mode5",
16781 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016782 [ALC272_DELL] = "dell",
16783 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016784 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016785 [ALC662_AUTO] = "auto",
16786};
16787
16788static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016789 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016790 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16791 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016792 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16793 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16794 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16795 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16796 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16797 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16798 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16799 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16800 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16801 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16802 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16803 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016804 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16805 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16806 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016807 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16808 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16809 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16810 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016811 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016812 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16813 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016814 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016815 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16816 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16817 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016818 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16819 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16820 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016821 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16822 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16823 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016824 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016825 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16826 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016827 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016828 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016829 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016830 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16831 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16832 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016833 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016834 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16835 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016836 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016837 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016838 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016839 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016840 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16841 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016842 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016843 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16844 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016845 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016846 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016847 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016848 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016849 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016850 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16851 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016852 {}
16853};
16854
16855static struct alc_config_preset alc662_presets[] = {
16856 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016857 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016858 .init_verbs = { alc662_init_verbs },
16859 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16860 .dac_nids = alc662_dac_nids,
16861 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016862 .dig_in_nid = ALC662_DIGIN_NID,
16863 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16864 .channel_mode = alc662_3ST_2ch_modes,
16865 .input_mux = &alc662_capture_source,
16866 },
16867 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016868 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016869 .init_verbs = { alc662_init_verbs },
16870 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16871 .dac_nids = alc662_dac_nids,
16872 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016873 .dig_in_nid = ALC662_DIGIN_NID,
16874 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16875 .channel_mode = alc662_3ST_6ch_modes,
16876 .need_dac_fix = 1,
16877 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016878 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016879 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016880 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016881 .init_verbs = { alc662_init_verbs },
16882 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16883 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016884 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16885 .channel_mode = alc662_3ST_6ch_modes,
16886 .need_dac_fix = 1,
16887 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016888 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016889 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016890 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016891 .init_verbs = { alc662_init_verbs },
16892 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16893 .dac_nids = alc662_dac_nids,
16894 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016895 .dig_in_nid = ALC662_DIGIN_NID,
16896 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16897 .channel_mode = alc662_5stack_modes,
16898 .input_mux = &alc662_capture_source,
16899 },
16900 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016901 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016902 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16903 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16904 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016905 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16906 .channel_mode = alc662_3ST_2ch_modes,
16907 .input_mux = &alc662_lenovo_101e_capture_source,
16908 .unsol_event = alc662_lenovo_101e_unsol_event,
16909 .init_hook = alc662_lenovo_101e_all_automute,
16910 },
Kailang Yang291702f2007-10-16 14:28:03 +020016911 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016912 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016913 .init_verbs = { alc662_init_verbs,
16914 alc662_eeepc_sue_init_verbs },
16915 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16916 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016917 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16918 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016919 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016920 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016921 .init_hook = alc662_eeepc_inithook,
16922 },
Kailang Yang8c427222008-01-10 13:03:59 +010016923 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016924 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016925 alc662_chmode_mixer },
16926 .init_verbs = { alc662_init_verbs,
16927 alc662_eeepc_ep20_sue_init_verbs },
16928 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16929 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016930 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16931 .channel_mode = alc662_3ST_6ch_modes,
16932 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016933 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016934 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016935 .init_hook = alc662_eeepc_ep20_inithook,
16936 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016937 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016938 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016939 .init_verbs = { alc662_init_verbs,
16940 alc662_ecs_init_verbs },
16941 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16942 .dac_nids = alc662_dac_nids,
16943 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16944 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016945 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016946 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016947 .init_hook = alc662_eeepc_inithook,
16948 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016949 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016950 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016951 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16952 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16953 .dac_nids = alc662_dac_nids,
16954 .dig_out_nid = ALC662_DIGOUT_NID,
16955 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16956 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016957 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016958 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016959 .init_hook = alc663_m51va_inithook,
16960 },
16961 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016962 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016963 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16964 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16965 .dac_nids = alc662_dac_nids,
16966 .dig_out_nid = ALC662_DIGOUT_NID,
16967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16968 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016969 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016970 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016971 .init_hook = alc663_g71v_inithook,
16972 },
16973 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016974 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016975 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16976 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16977 .dac_nids = alc662_dac_nids,
16978 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16979 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016980 .unsol_event = alc663_m51va_unsol_event,
16981 .init_hook = alc663_m51va_inithook,
16982 },
16983 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016984 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016985 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16986 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16987 .dac_nids = alc662_dac_nids,
16988 .dig_out_nid = ALC662_DIGOUT_NID,
16989 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16990 .channel_mode = alc662_3ST_6ch_modes,
16991 .input_mux = &alc663_capture_source,
16992 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016993 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016994 .init_hook = alc663_g50v_inithook,
16995 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016996 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016997 .mixers = { alc663_m51va_mixer },
16998 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016999 .init_verbs = { alc662_init_verbs,
17000 alc663_21jd_amic_init_verbs },
17001 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17002 .hp_nid = 0x03,
17003 .dac_nids = alc662_dac_nids,
17004 .dig_out_nid = ALC662_DIGOUT_NID,
17005 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17006 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017007 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017008 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017009 .init_hook = alc663_mode1_inithook,
17010 },
17011 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017012 .mixers = { alc662_1bjd_mixer },
17013 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017014 .init_verbs = { alc662_init_verbs,
17015 alc662_1bjd_amic_init_verbs },
17016 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17017 .dac_nids = alc662_dac_nids,
17018 .dig_out_nid = ALC662_DIGOUT_NID,
17019 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17020 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017021 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017022 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017023 .init_hook = alc662_mode2_inithook,
17024 },
17025 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017026 .mixers = { alc663_two_hp_m1_mixer },
17027 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017028 .init_verbs = { alc662_init_verbs,
17029 alc663_two_hp_amic_m1_init_verbs },
17030 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17031 .hp_nid = 0x03,
17032 .dac_nids = alc662_dac_nids,
17033 .dig_out_nid = ALC662_DIGOUT_NID,
17034 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17035 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017036 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017037 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017038 .init_hook = alc663_mode3_inithook,
17039 },
17040 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017041 .mixers = { alc663_asus_21jd_clfe_mixer },
17042 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017043 .init_verbs = { alc662_init_verbs,
17044 alc663_21jd_amic_init_verbs},
17045 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17046 .hp_nid = 0x03,
17047 .dac_nids = alc662_dac_nids,
17048 .dig_out_nid = ALC662_DIGOUT_NID,
17049 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17050 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017051 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017052 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017053 .init_hook = alc663_mode4_inithook,
17054 },
17055 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017056 .mixers = { alc663_asus_15jd_clfe_mixer },
17057 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017058 .init_verbs = { alc662_init_verbs,
17059 alc663_15jd_amic_init_verbs },
17060 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17061 .hp_nid = 0x03,
17062 .dac_nids = alc662_dac_nids,
17063 .dig_out_nid = ALC662_DIGOUT_NID,
17064 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17065 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017066 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017067 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017068 .init_hook = alc663_mode5_inithook,
17069 },
17070 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017071 .mixers = { alc663_two_hp_m2_mixer },
17072 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017073 .init_verbs = { alc662_init_verbs,
17074 alc663_two_hp_amic_m2_init_verbs },
17075 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17076 .hp_nid = 0x03,
17077 .dac_nids = alc662_dac_nids,
17078 .dig_out_nid = ALC662_DIGOUT_NID,
17079 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17080 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017081 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017082 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017083 .init_hook = alc663_mode6_inithook,
17084 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017085 [ALC272_DELL] = {
17086 .mixers = { alc663_m51va_mixer },
17087 .cap_mixer = alc272_auto_capture_mixer,
17088 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17089 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17090 .dac_nids = alc662_dac_nids,
17091 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17092 .adc_nids = alc272_adc_nids,
17093 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17094 .capsrc_nids = alc272_capsrc_nids,
17095 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017096 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017097 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017098 .init_hook = alc663_m51va_inithook,
17099 },
17100 [ALC272_DELL_ZM1] = {
17101 .mixers = { alc663_m51va_mixer },
17102 .cap_mixer = alc662_auto_capture_mixer,
17103 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17104 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17105 .dac_nids = alc662_dac_nids,
17106 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17107 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017108 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017109 .capsrc_nids = alc662_capsrc_nids,
17110 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017111 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017112 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017113 .init_hook = alc663_m51va_inithook,
17114 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017115 [ALC272_SAMSUNG_NC10] = {
17116 .mixers = { alc272_nc10_mixer },
17117 .init_verbs = { alc662_init_verbs,
17118 alc663_21jd_amic_init_verbs },
17119 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17120 .dac_nids = alc272_dac_nids,
17121 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17122 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017123 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017124 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017125 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017126 .init_hook = alc663_mode4_inithook,
17127 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017128};
17129
17130
17131/*
17132 * BIOS auto configuration
17133 */
17134
17135/* add playback controls from the parsed DAC table */
17136static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17137 const struct auto_pin_cfg *cfg)
17138{
17139 char name[32];
17140 static const char *chname[4] = {
17141 "Front", "Surround", NULL /*CLFE*/, "Side"
17142 };
17143 hda_nid_t nid;
17144 int i, err;
17145
17146 for (i = 0; i < cfg->line_outs; i++) {
17147 if (!spec->multiout.dac_nids[i])
17148 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017149 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017150 if (i == 2) {
17151 /* Center/LFE */
17152 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17153 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017154 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17155 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017156 if (err < 0)
17157 return err;
17158 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17159 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017160 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17161 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017162 if (err < 0)
17163 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017164 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017165 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017166 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017167 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017168 if (err < 0)
17169 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017170 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017171 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017172 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017173 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017174 if (err < 0)
17175 return err;
17176 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017177 const char *pfx;
17178 if (cfg->line_outs == 1 &&
17179 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17180 if (!cfg->hp_pins)
17181 pfx = "Speaker";
17182 else
17183 pfx = "PCM";
17184 } else
17185 pfx = chname[i];
17186 sprintf(name, "%s Playback Volume", pfx);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017187 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017188 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17189 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017190 if (err < 0)
17191 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017192 if (cfg->line_outs == 1 &&
17193 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17194 pfx = "Speaker";
17195 sprintf(name, "%s Playback Switch", pfx);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017196 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17197 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17198 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017199 if (err < 0)
17200 return err;
17201 }
17202 }
17203 return 0;
17204}
17205
17206/* add playback controls for speaker and HP outputs */
17207static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17208 const char *pfx)
17209{
17210 hda_nid_t nid;
17211 int err;
17212 char name[32];
17213
17214 if (!pin)
17215 return 0;
17216
Takashi Iwai24fb9172008-09-02 14:48:20 +020017217 if (pin == 0x17) {
17218 /* ALC663 has a mono output pin on 0x17 */
17219 sprintf(name, "%s Playback Switch", pfx);
17220 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17221 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17222 return err;
17223 }
17224
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017225 if (alc880_is_fixed_pin(pin)) {
17226 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017227 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017228 /* specify the DAC as the extra output */
17229 if (!spec->multiout.hp_nid)
17230 spec->multiout.hp_nid = nid;
17231 else
17232 spec->multiout.extra_out_nid[0] = nid;
17233 /* control HP volume/switch on the output mixer amp */
17234 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17235 sprintf(name, "%s Playback Volume", pfx);
17236 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17237 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17238 if (err < 0)
17239 return err;
17240 sprintf(name, "%s Playback Switch", pfx);
17241 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17242 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17243 if (err < 0)
17244 return err;
17245 } else if (alc880_is_multi_pin(pin)) {
17246 /* set manual connection */
17247 /* we have only a switch on HP-out PIN */
17248 sprintf(name, "%s Playback Switch", pfx);
17249 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17250 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17251 if (err < 0)
17252 return err;
17253 }
17254 return 0;
17255}
17256
17257/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017258#define alc662_auto_create_input_ctls \
17259 alc880_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017260
17261static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17262 hda_nid_t nid, int pin_type,
17263 int dac_idx)
17264{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017265 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017266 /* need the manual connection? */
17267 if (alc880_is_multi_pin(nid)) {
17268 struct alc_spec *spec = codec->spec;
17269 int idx = alc880_multi_pin_idx(nid);
17270 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17271 AC_VERB_SET_CONNECT_SEL,
17272 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17273 }
17274}
17275
17276static void alc662_auto_init_multi_out(struct hda_codec *codec)
17277{
17278 struct alc_spec *spec = codec->spec;
17279 int i;
17280
17281 for (i = 0; i <= HDA_SIDE; i++) {
17282 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017283 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017284 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017285 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017286 i);
17287 }
17288}
17289
17290static void alc662_auto_init_hp_out(struct hda_codec *codec)
17291{
17292 struct alc_spec *spec = codec->spec;
17293 hda_nid_t pin;
17294
17295 pin = spec->autocfg.hp_pins[0];
17296 if (pin) /* connect to front */
17297 /* use dac 0 */
17298 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017299 pin = spec->autocfg.speaker_pins[0];
17300 if (pin)
17301 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017302}
17303
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017304#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17305
17306static void alc662_auto_init_analog_input(struct hda_codec *codec)
17307{
17308 struct alc_spec *spec = codec->spec;
17309 int i;
17310
17311 for (i = 0; i < AUTO_PIN_LAST; i++) {
17312 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017313 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017314 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017315 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017316 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017317 snd_hda_codec_write(codec, nid, 0,
17318 AC_VERB_SET_AMP_GAIN_MUTE,
17319 AMP_OUT_MUTE);
17320 }
17321 }
17322}
17323
Takashi Iwaif511b012008-08-15 16:46:42 +020017324#define alc662_auto_init_input_src alc882_auto_init_input_src
17325
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017326static int alc662_parse_auto_config(struct hda_codec *codec)
17327{
17328 struct alc_spec *spec = codec->spec;
17329 int err;
17330 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17331
17332 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17333 alc662_ignore);
17334 if (err < 0)
17335 return err;
17336 if (!spec->autocfg.line_outs)
17337 return 0; /* can't find valid BIOS pin config */
17338
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017339 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17340 if (err < 0)
17341 return err;
17342 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17343 if (err < 0)
17344 return err;
17345 err = alc662_auto_create_extra_out(spec,
17346 spec->autocfg.speaker_pins[0],
17347 "Speaker");
17348 if (err < 0)
17349 return err;
17350 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17351 "Headphone");
17352 if (err < 0)
17353 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017354 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017355 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017356 return err;
17357
17358 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17359
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017360 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017361 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17362
Takashi Iwai603c4012008-07-30 15:01:44 +020017363 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017364 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017365
17366 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017367 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017368
Takashi Iwaid88897e2008-10-31 15:01:37 +010017369 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017370 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017371 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017372
17373 err = alc_auto_add_mic_boost(codec);
17374 if (err < 0)
17375 return err;
17376
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017377 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17378
Takashi Iwai8c872862007-06-19 12:11:16 +020017379 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017380}
17381
17382/* additional initialization for auto-configuration model */
17383static void alc662_auto_init(struct hda_codec *codec)
17384{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017385 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017386 alc662_auto_init_multi_out(codec);
17387 alc662_auto_init_hp_out(codec);
17388 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017389 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017390 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017391 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017392}
17393
17394static int patch_alc662(struct hda_codec *codec)
17395{
17396 struct alc_spec *spec;
17397 int err, board_config;
17398
17399 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17400 if (!spec)
17401 return -ENOMEM;
17402
17403 codec->spec = spec;
17404
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017405 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17406
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017407 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17408 alc662_models,
17409 alc662_cfg_tbl);
17410 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017411 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17412 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017413 board_config = ALC662_AUTO;
17414 }
17415
17416 if (board_config == ALC662_AUTO) {
17417 /* automatic parse from the BIOS config */
17418 err = alc662_parse_auto_config(codec);
17419 if (err < 0) {
17420 alc_free(codec);
17421 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020017422 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017423 printk(KERN_INFO
17424 "hda_codec: Cannot set up configuration "
17425 "from BIOS. Using base mode...\n");
17426 board_config = ALC662_3ST_2ch_DIG;
17427 }
17428 }
17429
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017430 err = snd_hda_attach_beep_device(codec, 0x1);
17431 if (err < 0) {
17432 alc_free(codec);
17433 return err;
17434 }
17435
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017436 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017437 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017438
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017439 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17440 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17441
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017442 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17443 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17444
Takashi Iwaidd704692009-08-11 08:45:11 +020017445 if (!spec->adc_nids) {
17446 spec->adc_nids = alc662_adc_nids;
17447 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17448 }
17449 if (!spec->capsrc_nids)
17450 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017451
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017452 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017453 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017454 if (codec->vendor_id == 0x10ec0662)
17455 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17456 else
17457 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017458
Takashi Iwai2134ea42008-01-10 16:53:55 +010017459 spec->vmaster_nid = 0x02;
17460
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017461 codec->patch_ops = alc_patch_ops;
17462 if (board_config == ALC662_AUTO)
17463 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017464#ifdef CONFIG_SND_HDA_POWER_SAVE
17465 if (!spec->loopback.amplist)
17466 spec->loopback.amplist = alc662_loopbacks;
17467#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017468 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017469
17470 return 0;
17471}
17472
17473/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017474 * patch entries
17475 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017476static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017477 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017478 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017479 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017480 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017481 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017482 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017483 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017484 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017485 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17486 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17487 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017488 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai49535502009-06-30 15:28:30 +020017489 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017490 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17491 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017492 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017493 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017494 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020017495 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017496 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020017497 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017498 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020017499 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017500 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020017501 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017502 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai49535502009-06-30 15:28:30 +020017503 .patch = patch_alc882 },
17504 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17505 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017506 {} /* terminator */
17507};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017508
17509MODULE_ALIAS("snd-hda-codec-id:10ec*");
17510
17511MODULE_LICENSE("GPL");
17512MODULE_DESCRIPTION("Realtek HD-audio codec");
17513
17514static struct hda_codec_preset_list realtek_list = {
17515 .preset = snd_hda_preset_realtek,
17516 .owner = THIS_MODULE,
17517};
17518
17519static int __init patch_realtek_init(void)
17520{
17521 return snd_hda_add_codec_preset(&realtek_list);
17522}
17523
17524static void __exit patch_realtek_exit(void)
17525{
17526 snd_hda_delete_codec_preset(&realtek_list);
17527}
17528
17529module_init(patch_realtek_init)
17530module_exit(patch_realtek_exit)