blob: 872731eb49e84ec8e6b44eecb043f3c0337b6e8f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
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 Woithe7cf51e482006-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 Avdoninbab282b92006-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 Iwai4953550a2009-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
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200278 const struct hda_verb *init_verbs[10]; /* 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 Iwai4953550a2009-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Kluin4b35d2ca2009-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 Iwaiad87c642009-11-02 14:23:15 +0100968 if (!nid)
969 return;
Takashi Iwai261c2402009-06-25 08:13:40 +0200970 pincap = snd_hda_query_pin_caps(codec, nid);
971 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
972 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200973 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200974 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200975 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
976 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
977 nid = spec->autocfg.speaker_pins[i];
978 if (!nid)
979 break;
980 snd_hda_codec_write(codec, nid, 0,
981 AC_VERB_SET_PIN_WIDGET_CONTROL,
982 spec->jack_present ? 0 : PIN_OUT);
983 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200984}
985
Takashi Iwai6c819492009-08-10 18:47:44 +0200986static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
987 hda_nid_t nid)
988{
989 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
990 int i, nums;
991
992 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
993 for (i = 0; i < nums; i++)
994 if (conn[i] == nid)
995 return i;
996 return -1;
997}
998
Kailang Yang7fb0d782008-10-15 11:12:35 +0200999static void alc_mic_automute(struct hda_codec *codec)
1000{
1001 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001002 struct alc_mic_route *dead, *alive;
1003 unsigned int present, type;
1004 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001005
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001006 if (!spec->auto_mic)
1007 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001008 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1009 return;
1010 if (snd_BUG_ON(!spec->adc_nids))
1011 return;
1012
1013 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1014
1015 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1016 AC_VERB_GET_PIN_SENSE, 0);
1017 present &= AC_PINSENSE_PRESENCE;
1018 if (present) {
1019 alive = &spec->ext_mic;
1020 dead = &spec->int_mic;
1021 } else {
1022 alive = &spec->int_mic;
1023 dead = &spec->ext_mic;
1024 }
1025
Takashi Iwai6c819492009-08-10 18:47:44 +02001026 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1027 if (type == AC_WID_AUD_MIX) {
1028 /* Matrix-mixer style (e.g. ALC882) */
1029 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1030 alive->mux_idx,
1031 HDA_AMP_MUTE, 0);
1032 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1033 dead->mux_idx,
1034 HDA_AMP_MUTE, HDA_AMP_MUTE);
1035 } else {
1036 /* MUX style (e.g. ALC880) */
1037 snd_hda_codec_write_cache(codec, cap_nid, 0,
1038 AC_VERB_SET_CONNECT_SEL,
1039 alive->mux_idx);
1040 }
1041
1042 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001043}
1044
Kailang Yangc9b58002007-10-16 14:30:01 +02001045/* unsolicited event for HP jack sensing */
1046static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1047{
1048 if (codec->vendor_id == 0x10ec0880)
1049 res >>= 28;
1050 else
1051 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001052 switch (res) {
1053 case ALC880_HP_EVENT:
1054 alc_automute_pin(codec);
1055 break;
1056 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001057 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 break;
1059 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001060}
1061
1062static void alc_inithook(struct hda_codec *codec)
1063{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001064 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001065 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001066}
1067
Kailang Yangf9423e72008-05-27 12:32:25 +02001068/* additional initialization for ALC888 variants */
1069static void alc888_coef_init(struct hda_codec *codec)
1070{
1071 unsigned int tmp;
1072
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1074 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1075 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001076 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001077 /* alc888S-VC */
1078 snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_SET_PROC_COEF, 0x830);
1080 else
1081 /* alc888-VB */
1082 snd_hda_codec_read(codec, 0x20, 0,
1083 AC_VERB_SET_PROC_COEF, 0x3030);
1084}
1085
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001086static void alc889_coef_init(struct hda_codec *codec)
1087{
1088 unsigned int tmp;
1089
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1093 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1094}
1095
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001099
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 switch (type) {
1101 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001102 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1103 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001104 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001105 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1106 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001107 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001108 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1109 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001110 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001111 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 case 0x10ec0260:
1113 snd_hda_codec_write(codec, 0x0f, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1115 snd_hda_codec_write(codec, 0x10, 0,
1116 AC_VERB_SET_EAPD_BTLENABLE, 2);
1117 break;
1118 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001119 case 0x10ec0267:
1120 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001122 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001123 case 0x10ec0660:
1124 case 0x10ec0662:
1125 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001127 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001128 snd_hda_codec_write(codec, 0x14, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
1130 snd_hda_codec_write(codec, 0x15, 0,
1131 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001133 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 switch (codec->vendor_id) {
1135 case 0x10ec0260:
1136 snd_hda_codec_write(codec, 0x1a, 0,
1137 AC_VERB_SET_COEF_INDEX, 7);
1138 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1139 AC_VERB_GET_PROC_COEF, 0);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_COEF_INDEX, 7);
1142 snd_hda_codec_write(codec, 0x1a, 0,
1143 AC_VERB_SET_PROC_COEF,
1144 tmp | 0x2010);
1145 break;
1146 case 0x10ec0262:
1147 case 0x10ec0880:
1148 case 0x10ec0882:
1149 case 0x10ec0883:
1150 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001151 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001152 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001153 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001154 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001156 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001157 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001158 case 0x10ec0267:
1159 case 0x10ec0268:
1160 snd_hda_codec_write(codec, 0x20, 0,
1161 AC_VERB_SET_COEF_INDEX, 7);
1162 tmp = snd_hda_codec_read(codec, 0x20, 0,
1163 AC_VERB_GET_PROC_COEF, 0);
1164 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001165 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001166 snd_hda_codec_write(codec, 0x20, 0,
1167 AC_VERB_SET_PROC_COEF,
1168 tmp | 0x3000);
1169 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001170 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001171 break;
1172 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173}
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001175static void alc_init_auto_hp(struct hda_codec *codec)
1176{
1177 struct alc_spec *spec = codec->spec;
1178
1179 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 if (spec->autocfg.line_out_pins[0] &&
1184 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001186 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 else
1188 return;
1189 }
1190
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001191 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1192 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001193 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1194 AC_VERB_SET_UNSOLICITED_ENABLE,
1195 AC_USRSP_EN | ALC880_HP_EVENT);
1196 spec->unsol_event = alc_sku_unsol_event;
1197}
1198
Takashi Iwai6c819492009-08-10 18:47:44 +02001199static void alc_init_auto_mic(struct hda_codec *codec)
1200{
1201 struct alc_spec *spec = codec->spec;
1202 struct auto_pin_cfg *cfg = &spec->autocfg;
1203 hda_nid_t fixed, ext;
1204 int i;
1205
1206 /* there must be only two mic inputs exclusively */
1207 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1208 if (cfg->input_pins[i])
1209 return;
1210
1211 fixed = ext = 0;
1212 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1213 hda_nid_t nid = cfg->input_pins[i];
1214 unsigned int defcfg;
1215 if (!nid)
1216 return;
1217 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1218 switch (get_defcfg_connect(defcfg)) {
1219 case AC_JACK_PORT_FIXED:
1220 if (fixed)
1221 return; /* already occupied */
1222 fixed = nid;
1223 break;
1224 case AC_JACK_PORT_COMPLEX:
1225 if (ext)
1226 return; /* already occupied */
1227 ext = nid;
1228 break;
1229 default:
1230 return; /* invalid entry */
1231 }
1232 }
1233 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1234 return; /* no unsol support */
1235 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1236 ext, fixed);
1237 spec->ext_mic.pin = ext;
1238 spec->int_mic.pin = fixed;
1239 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1240 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1241 spec->auto_mic = 1;
1242 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1243 AC_VERB_SET_UNSOLICITED_ENABLE,
1244 AC_USRSP_EN | ALC880_MIC_EVENT);
1245 spec->unsol_event = alc_sku_unsol_event;
1246}
1247
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001248/* check subsystem ID and set up device-specific initialization;
1249 * return 1 if initialized, 0 if invalid SSID
1250 */
1251/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1252 * 31 ~ 16 : Manufacture ID
1253 * 15 ~ 8 : SKU ID
1254 * 7 ~ 0 : Assembly ID
1255 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1256 */
1257static int alc_subsystem_id(struct hda_codec *codec,
1258 hda_nid_t porta, hda_nid_t porte,
1259 hda_nid_t portd)
1260{
1261 unsigned int ass, tmp, i;
1262 unsigned nid;
1263 struct alc_spec *spec = codec->spec;
1264
1265 ass = codec->subsystem_id & 0xffff;
1266 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1267 goto do_sku;
1268
1269 /* invalid SSID, check the special NID pin defcfg instead */
1270 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001271 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001272 * 29~21 : reserve
1273 * 20 : PCBEEP input
1274 * 19~16 : Check sum (15:1)
1275 * 15~1 : Custom
1276 * 0 : override
1277 */
1278 nid = 0x1d;
1279 if (codec->vendor_id == 0x10ec0260)
1280 nid = 0x17;
1281 ass = snd_hda_codec_get_pincfg(codec, nid);
1282 snd_printd("realtek: No valid SSID, "
1283 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001284 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001285 if (!(ass & 1) && !(ass & 0x100000))
1286 return 0;
1287 if ((ass >> 30) != 1) /* no physical connection */
1288 return 0;
1289
1290 /* check sum */
1291 tmp = 0;
1292 for (i = 1; i < 16; i++) {
1293 if ((ass >> i) & 1)
1294 tmp++;
1295 }
1296 if (((ass >> 16) & 0xf) != tmp)
1297 return 0;
1298do_sku:
1299 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1300 ass & 0xffff, codec->vendor_id);
1301 /*
1302 * 0 : override
1303 * 1 : Swap Jack
1304 * 2 : 0 --> Desktop, 1 --> Laptop
1305 * 3~5 : External Amplifier control
1306 * 7~6 : Reserved
1307 */
1308 tmp = (ass & 0x38) >> 3; /* external Amp control */
1309 switch (tmp) {
1310 case 1:
1311 spec->init_amp = ALC_INIT_GPIO1;
1312 break;
1313 case 3:
1314 spec->init_amp = ALC_INIT_GPIO2;
1315 break;
1316 case 7:
1317 spec->init_amp = ALC_INIT_GPIO3;
1318 break;
1319 case 5:
1320 spec->init_amp = ALC_INIT_DEFAULT;
1321 break;
1322 }
1323
1324 /* is laptop or Desktop and enable the function "Mute internal speaker
1325 * when the external headphone out jack is plugged"
1326 */
1327 if (!(ass & 0x8000))
1328 return 1;
1329 /*
1330 * 10~8 : Jack location
1331 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1332 * 14~13: Resvered
1333 * 15 : 1 --> enable the function "Mute internal speaker
1334 * when the external headphone out jack is plugged"
1335 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001337 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1339 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001340 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001341 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001344 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001346 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001347 for (i = 0; i < spec->autocfg.line_outs; i++)
1348 if (spec->autocfg.line_out_pins[i] == nid)
1349 return 1;
1350 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001351 }
1352
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001353 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001354 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001355 return 1;
1356}
Kailang Yangea1fb292008-08-26 12:58:38 +02001357
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001358static void alc_ssid_check(struct hda_codec *codec,
1359 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1360{
1361 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1362 struct alc_spec *spec = codec->spec;
1363 snd_printd("realtek: "
1364 "Enable default setup for auto mode as fallback\n");
1365 spec->init_amp = ALC_INIT_DEFAULT;
1366 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001367 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001368 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001369}
1370
Takashi Iwai41e41f12005-06-08 14:48:49 +02001371/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001372 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001373 */
1374
1375struct alc_pincfg {
1376 hda_nid_t nid;
1377 u32 val;
1378};
1379
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001380struct alc_fixup {
1381 const struct alc_pincfg *pins;
1382 const struct hda_verb *verbs;
1383};
1384
1385static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001386 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001387 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001388{
1389 const struct alc_pincfg *cfg;
1390
1391 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1392 if (!quirk)
1393 return;
1394
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001395 fix += quirk->value;
1396 cfg = fix->pins;
1397 if (cfg) {
1398 for (; cfg->nid; cfg++)
1399 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1400 }
1401 if (fix->verbs)
1402 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001403}
1404
1405/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001406 * ALC888
1407 */
1408
1409/*
1410 * 2ch mode
1411 */
1412static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1413/* Mic-in jack as mic in */
1414 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1415 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1416/* Line-in jack as Line in */
1417 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1418 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1419/* Line-Out as Front */
1420 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1421 { } /* end */
1422};
1423
1424/*
1425 * 4ch mode
1426 */
1427static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1428/* Mic-in jack as mic in */
1429 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1430 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1431/* Line-in jack as Surround */
1432 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1433 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1434/* Line-Out as Front */
1435 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1436 { } /* end */
1437};
1438
1439/*
1440 * 6ch mode
1441 */
1442static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1443/* Mic-in jack as CLFE */
1444 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1445 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1446/* Line-in jack as Surround */
1447 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1448 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1449/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1450 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1451 { } /* end */
1452};
1453
1454/*
1455 * 8ch mode
1456 */
1457static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1458/* Mic-in jack as CLFE */
1459 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1460 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1461/* Line-in jack as Surround */
1462 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1463 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1464/* Line-Out as Side */
1465 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1466 { } /* end */
1467};
1468
1469static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1470 { 2, alc888_4ST_ch2_intel_init },
1471 { 4, alc888_4ST_ch4_intel_init },
1472 { 6, alc888_4ST_ch6_intel_init },
1473 { 8, alc888_4ST_ch8_intel_init },
1474};
1475
1476/*
1477 * ALC888 Fujitsu Siemens Amillo xa3530
1478 */
1479
1480static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1481/* Front Mic: set to PIN_IN (empty by default) */
1482 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1483/* Connect Internal HP to Front */
1484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1486 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1487/* Connect Bass HP to Front */
1488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1490 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1491/* Connect Line-Out side jack (SPDIF) to Side */
1492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1493 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1495/* Connect Mic jack to CLFE */
1496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1499/* Connect Line-in jack to Surround */
1500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1503/* Connect HP out jack to Front */
1504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1507/* Enable unsolicited event for HP jack and Line-out jack */
1508 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1509 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1510 {}
1511};
1512
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001513static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001514{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001515 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001516 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001517 hda_nid_t nid;
1518 int i;
1519
1520 spec->jack_present = 0;
1521 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1522 nid = spec->autocfg.hp_pins[i];
1523 if (!nid)
1524 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001525 pincap = snd_hda_query_pin_caps(codec, nid);
1526 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1527 snd_hda_codec_read(codec, nid, 0,
1528 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001529 val = snd_hda_codec_read(codec, nid, 0,
1530 AC_VERB_GET_PIN_SENSE, 0);
1531 if (val & AC_PINSENSE_PRESENCE) {
1532 spec->jack_present = 1;
1533 break;
1534 }
1535 }
1536
1537 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001538 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001539 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1540 nid = spec->autocfg.speaker_pins[i];
1541 if (!nid)
1542 break;
1543 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1544 HDA_AMP_MUTE, mute);
1545 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001546}
1547
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001548static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1549 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001550{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001551 if (codec->vendor_id == 0x10ec0880)
1552 res >>= 28;
1553 else
1554 res >>= 26;
1555 if (res == ALC880_HP_EVENT)
1556 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001557}
1558
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001559static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001560{
1561 struct alc_spec *spec = codec->spec;
1562
1563 spec->autocfg.hp_pins[0] = 0x15;
1564 spec->autocfg.speaker_pins[0] = 0x14;
1565 spec->autocfg.speaker_pins[1] = 0x16;
1566 spec->autocfg.speaker_pins[2] = 0x17;
1567 spec->autocfg.speaker_pins[3] = 0x19;
1568 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001569}
1570
1571static void alc889_intel_init_hook(struct hda_codec *codec)
1572{
1573 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001574 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001575}
1576
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001577static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001578{
1579 struct alc_spec *spec = codec->spec;
1580
1581 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1582 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1583 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1584 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001585}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001586
1587/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001588 * ALC888 Acer Aspire 4930G model
1589 */
1590
1591static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1592/* Front Mic: set to PIN_IN (empty by default) */
1593 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1594/* Unselect Front Mic by default in input mixer 3 */
1595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001596/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1598/* Connect Internal HP to front */
1599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1601 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1602/* Connect HP out to front */
1603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1606 { }
1607};
1608
Hector Martin3b315d72009-06-02 10:54:19 +02001609/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001610 * ALC888 Acer Aspire 6530G model
1611 */
1612
1613static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1614/* Bias voltage on for external mic port */
1615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001616/* Front Mic: set to PIN_IN (empty by default) */
1617 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1618/* Unselect Front Mic by default in input mixer 3 */
1619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001620/* Enable unsolicited event for HP jack */
1621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1622/* Enable speaker output */
1623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625/* Enable headphone output */
1626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1629 { }
1630};
1631
1632/*
Hector Martin018df412009-06-04 00:13:40 +02001633 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001634 */
1635
Hector Martin018df412009-06-04 00:13:40 +02001636static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001637/* Front Mic: set to PIN_IN (empty by default) */
1638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1639/* Unselect Front Mic by default in input mixer 3 */
1640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1641/* Enable unsolicited event for HP jack */
1642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1643/* Connect Internal Front to Front */
1644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1647/* Connect Internal Rear to Rear */
1648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1650 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1651/* Connect Internal CLFE to CLFE */
1652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1655/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1658 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1659/* Enable all DACs */
1660/* DAC DISABLE/MUTE 1? */
1661/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1662 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1663 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1664/* DAC DISABLE/MUTE 2? */
1665/* some bit here disables the other DACs. Init=0x4900 */
1666 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1667 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1668/* Enable amplifiers */
1669 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1670 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001671/* DMIC fix
1672 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1673 * which makes the stereo useless. However, either the mic or the ALC889
1674 * makes the signal become a difference/sum signal instead of standard
1675 * stereo, which is annoying. So instead we flip this bit which makes the
1676 * codec replicate the sum signal to both channels, turning it into a
1677 * normal mono mic.
1678 */
1679/* DMIC_CONTROL? Init value = 0x0001 */
1680 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1681 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001682 { }
1683};
1684
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001685static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001686 /* Front mic only available on one ADC */
1687 {
1688 .num_items = 4,
1689 .items = {
1690 { "Mic", 0x0 },
1691 { "Line", 0x2 },
1692 { "CD", 0x4 },
1693 { "Front Mic", 0xb },
1694 },
1695 },
1696 {
1697 .num_items = 3,
1698 .items = {
1699 { "Mic", 0x0 },
1700 { "Line", 0x2 },
1701 { "CD", 0x4 },
1702 },
1703 }
1704};
1705
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1707 /* Interal mic only available on one ADC */
1708 {
Tony Vroon684a8842009-06-26 09:27:50 +01001709 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710 .items = {
1711 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001712 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001714 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001715 { "Int Mic", 0xb },
1716 },
1717 },
1718 {
Tony Vroon684a8842009-06-26 09:27:50 +01001719 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 .items = {
1721 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001722 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001723 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001724 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001725 },
1726 }
1727};
1728
Hector Martin018df412009-06-04 00:13:40 +02001729static struct hda_input_mux alc889_capture_sources[3] = {
1730 /* Digital mic only available on first "ADC" */
1731 {
1732 .num_items = 5,
1733 .items = {
1734 { "Mic", 0x0 },
1735 { "Line", 0x2 },
1736 { "CD", 0x4 },
1737 { "Front Mic", 0xb },
1738 { "Input Mix", 0xa },
1739 },
1740 },
1741 {
1742 .num_items = 4,
1743 .items = {
1744 { "Mic", 0x0 },
1745 { "Line", 0x2 },
1746 { "CD", 0x4 },
1747 { "Input Mix", 0xa },
1748 },
1749 },
1750 {
1751 .num_items = 4,
1752 .items = {
1753 { "Mic", 0x0 },
1754 { "Line", 0x2 },
1755 { "CD", 0x4 },
1756 { "Input Mix", 0xa },
1757 },
1758 }
1759};
1760
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001761static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001762 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1763 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1767 HDA_OUTPUT),
1768 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1770 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1774 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1776 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001780 { } /* end */
1781};
1782
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001783static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001784{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001785 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001786
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001787 spec->autocfg.hp_pins[0] = 0x15;
1788 spec->autocfg.speaker_pins[0] = 0x14;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001789}
1790
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001791static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001792{
1793 struct alc_spec *spec = codec->spec;
1794
1795 spec->autocfg.hp_pins[0] = 0x15;
1796 spec->autocfg.speaker_pins[0] = 0x14;
1797 spec->autocfg.speaker_pins[1] = 0x16;
1798 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001799}
1800
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001801static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001802{
1803 struct alc_spec *spec = codec->spec;
1804
1805 spec->autocfg.hp_pins[0] = 0x15;
1806 spec->autocfg.speaker_pins[0] = 0x14;
1807 spec->autocfg.speaker_pins[1] = 0x16;
1808 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001809}
1810
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001811/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001812 * ALC880 3-stack model
1813 *
1814 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001815 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1816 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001817 */
1818
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001819static hda_nid_t alc880_dac_nids[4] = {
1820 /* front, rear, clfe, rear_surr */
1821 0x02, 0x05, 0x04, 0x03
1822};
1823
1824static hda_nid_t alc880_adc_nids[3] = {
1825 /* ADC0-2 */
1826 0x07, 0x08, 0x09,
1827};
1828
1829/* The datasheet says the node 0x07 is connected from inputs,
1830 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001831 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001832 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833static hda_nid_t alc880_adc_nids_alt[2] = {
1834 /* ADC1-2 */
1835 0x08, 0x09,
1836};
1837
1838#define ALC880_DIGOUT_NID 0x06
1839#define ALC880_DIGIN_NID 0x0a
1840
1841static struct hda_input_mux alc880_capture_source = {
1842 .num_items = 4,
1843 .items = {
1844 { "Mic", 0x0 },
1845 { "Front Mic", 0x3 },
1846 { "Line", 0x2 },
1847 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001848 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001849};
1850
1851/* channel source setting (2/6 channel selection for 3-stack) */
1852/* 2ch mode */
1853static struct hda_verb alc880_threestack_ch2_init[] = {
1854 /* set line-in to input, mute it */
1855 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1856 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1857 /* set mic-in to input vref 80%, mute it */
1858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 { } /* end */
1861};
1862
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001863/* 6ch mode */
1864static struct hda_verb alc880_threestack_ch6_init[] = {
1865 /* set line-in to output, unmute it */
1866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1868 /* set mic-in to output, unmute it */
1869 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1870 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1871 { } /* end */
1872};
1873
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001874static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001875 { 2, alc880_threestack_ch2_init },
1876 { 6, alc880_threestack_ch6_init },
1877};
1878
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001879static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001881 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001883 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001897 {
1898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1899 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001900 .info = alc_ch_mode_info,
1901 .get = alc_ch_mode_get,
1902 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001903 },
1904 { } /* end */
1905};
1906
1907/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001908static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1909 struct snd_ctl_elem_info *uinfo)
1910{
1911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1912 struct alc_spec *spec = codec->spec;
1913 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001914
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001915 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001916 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1917 HDA_INPUT);
1918 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001919 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001920 return err;
1921}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001922
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001923static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1924 unsigned int size, unsigned int __user *tlv)
1925{
1926 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1927 struct alc_spec *spec = codec->spec;
1928 int err;
1929
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001930 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001931 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1932 HDA_INPUT);
1933 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001934 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001935 return err;
1936}
1937
1938typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1939 struct snd_ctl_elem_value *ucontrol);
1940
1941static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1942 struct snd_ctl_elem_value *ucontrol,
1943 getput_call_t func)
1944{
1945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1946 struct alc_spec *spec = codec->spec;
1947 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1948 int err;
1949
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001950 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1952 3, 0, HDA_INPUT);
1953 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001954 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001955 return err;
1956}
1957
1958static int alc_cap_vol_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_volume_get);
1963}
1964
1965static int alc_cap_vol_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_volume_put);
1970}
1971
1972/* capture mixer elements */
1973#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1974
1975static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1976 struct snd_ctl_elem_value *ucontrol)
1977{
1978 return alc_cap_getput_caller(kcontrol, ucontrol,
1979 snd_hda_mixer_amp_switch_get);
1980}
1981
1982static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1983 struct snd_ctl_elem_value *ucontrol)
1984{
1985 return alc_cap_getput_caller(kcontrol, ucontrol,
1986 snd_hda_mixer_amp_switch_put);
1987}
1988
Takashi Iwaia23b6882009-03-23 15:21:36 +01001989#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001990 { \
1991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1992 .name = "Capture Switch", \
1993 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1994 .count = num, \
1995 .info = alc_cap_sw_info, \
1996 .get = alc_cap_sw_get, \
1997 .put = alc_cap_sw_put, \
1998 }, \
1999 { \
2000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2001 .name = "Capture Volume", \
2002 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2003 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2004 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2005 .count = num, \
2006 .info = alc_cap_vol_info, \
2007 .get = alc_cap_vol_get, \
2008 .put = alc_cap_vol_put, \
2009 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002010 }
2011
2012#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002013 { \
2014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2015 /* .name = "Capture Source", */ \
2016 .name = "Input Source", \
2017 .count = num, \
2018 .info = alc_mux_enum_info, \
2019 .get = alc_mux_enum_get, \
2020 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002021 }
2022
2023#define DEFINE_CAPMIX(num) \
2024static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2025 _DEFINE_CAPMIX(num), \
2026 _DEFINE_CAPSRC(num), \
2027 { } /* end */ \
2028}
2029
2030#define DEFINE_CAPMIX_NOSRC(num) \
2031static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2032 _DEFINE_CAPMIX(num), \
2033 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002034}
2035
2036/* up to three ADCs */
2037DEFINE_CAPMIX(1);
2038DEFINE_CAPMIX(2);
2039DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002040DEFINE_CAPMIX_NOSRC(1);
2041DEFINE_CAPMIX_NOSRC(2);
2042DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002043
2044/*
2045 * ALC880 5-stack model
2046 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002047 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2048 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2050 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2051 */
2052
2053/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002054static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002055 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002056 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057 { } /* end */
2058};
2059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060/* channel source setting (6/8 channel selection for 5-stack) */
2061/* 6ch mode */
2062static struct hda_verb alc880_fivestack_ch6_init[] = {
2063 /* set line-in to input, mute it */
2064 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2065 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002066 { } /* end */
2067};
2068
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069/* 8ch mode */
2070static struct hda_verb alc880_fivestack_ch8_init[] = {
2071 /* set line-in to output, unmute it */
2072 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2073 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2074 { } /* end */
2075};
2076
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002077static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002078 { 6, alc880_fivestack_ch6_init },
2079 { 8, alc880_fivestack_ch8_init },
2080};
2081
2082
2083/*
2084 * ALC880 6-stack model
2085 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002086 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2087 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2089 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2090 */
2091
2092static hda_nid_t alc880_6st_dac_nids[4] = {
2093 /* front, rear, clfe, rear_surr */
2094 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002095};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002096
2097static struct hda_input_mux alc880_6stack_capture_source = {
2098 .num_items = 4,
2099 .items = {
2100 { "Mic", 0x0 },
2101 { "Front Mic", 0x1 },
2102 { "Line", 0x2 },
2103 { "CD", 0x4 },
2104 },
2105};
2106
2107/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002108static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002109 { 8, NULL },
2110};
2111
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002112static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002115 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002116 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002117 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2118 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002119 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2120 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002121 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002122 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2129 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2130 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002131 {
2132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2133 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002134 .info = alc_ch_mode_info,
2135 .get = alc_ch_mode_get,
2136 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002137 },
2138 { } /* end */
2139};
2140
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002141
2142/*
2143 * ALC880 W810 model
2144 *
2145 * W810 has rear IO for:
2146 * Front (DAC 02)
2147 * Surround (DAC 03)
2148 * Center/LFE (DAC 04)
2149 * Digital out (06)
2150 *
2151 * The system also has a pair of internal speakers, and a headphone jack.
2152 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002153 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002154 * There is a variable resistor to control the speaker or headphone
2155 * volume. This is a hardware-only device without a software API.
2156 *
2157 * Plugging headphones in will disable the internal speakers. This is
2158 * implemented in hardware, not via the driver using jack sense. In
2159 * a similar fashion, plugging into the rear socket marked "front" will
2160 * disable both the speakers and headphones.
2161 *
2162 * For input, there's a microphone jack, and an "audio in" jack.
2163 * These may not do anything useful with this driver yet, because I
2164 * haven't setup any initialization verbs for these yet...
2165 */
2166
2167static hda_nid_t alc880_w810_dac_nids[3] = {
2168 /* front, rear/surround, clfe */
2169 0x02, 0x03, 0x04
2170};
2171
2172/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002173static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174 { 6, NULL }
2175};
2176
2177/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002178static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002180 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002182 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2184 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2186 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2188 { } /* end */
2189};
2190
2191
2192/*
2193 * Z710V model
2194 *
2195 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002196 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2197 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002198 */
2199
2200static hda_nid_t alc880_z71v_dac_nids[1] = {
2201 0x02
2202};
2203#define ALC880_Z71V_HP_DAC 0x03
2204
2205/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002206static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 { 2, NULL }
2208};
2209
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002210static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002214 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2216 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2219 { } /* end */
2220};
2221
2222
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223/*
2224 * ALC880 F1734 model
2225 *
2226 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2227 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2228 */
2229
2230static hda_nid_t alc880_f1734_dac_nids[1] = {
2231 0x03
2232};
2233#define ALC880_F1734_HP_DAC 0x02
2234
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002235static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002236 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002237 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002238 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2239 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002244 { } /* end */
2245};
2246
Takashi Iwai937b4162008-02-11 14:52:36 +01002247static struct hda_input_mux alc880_f1734_capture_source = {
2248 .num_items = 2,
2249 .items = {
2250 { "Mic", 0x1 },
2251 { "CD", 0x4 },
2252 },
2253};
2254
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002256/*
2257 * ALC880 ASUS model
2258 *
2259 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2260 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2261 * Mic = 0x18, Line = 0x1a
2262 */
2263
2264#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2265#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2266
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002267static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002269 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002271 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2273 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002274 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2275 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002282 {
2283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2284 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002285 .info = alc_ch_mode_info,
2286 .get = alc_ch_mode_get,
2287 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 },
2289 { } /* end */
2290};
2291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002292/*
2293 * ALC880 ASUS W1V model
2294 *
2295 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2296 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2297 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2298 */
2299
2300/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002301static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2303 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 { } /* end */
2305};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002306
Kailang Yangdf694da2005-12-05 19:42:22 +01002307/* TCL S700 */
2308static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002318 { } /* end */
2319};
2320
Kailang Yangccc656c2006-10-17 12:32:26 +02002321/* Uniwill */
2322static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2324 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2325 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2326 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002327 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2328 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2329 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2330 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002339 {
2340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2341 .name = "Channel Mode",
2342 .info = alc_ch_mode_info,
2343 .get = alc_ch_mode_get,
2344 .put = alc_ch_mode_put,
2345 },
2346 { } /* end */
2347};
2348
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002349static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2351 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2353 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2357 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2358 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2359 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2360 { } /* end */
2361};
2362
Kailang Yangccc656c2006-10-17 12:32:26 +02002363static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002364 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2365 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2367 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2370 { } /* end */
2371};
2372
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002374 * virtual master controls
2375 */
2376
2377/*
2378 * slave controls for virtual master
2379 */
2380static const char *alc_slave_vols[] = {
2381 "Front Playback Volume",
2382 "Surround Playback Volume",
2383 "Center Playback Volume",
2384 "LFE Playback Volume",
2385 "Side Playback Volume",
2386 "Headphone Playback Volume",
2387 "Speaker Playback Volume",
2388 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002389 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002390 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002391 NULL,
2392};
2393
2394static const char *alc_slave_sws[] = {
2395 "Front Playback Switch",
2396 "Surround Playback Switch",
2397 "Center Playback Switch",
2398 "LFE Playback Switch",
2399 "Side Playback Switch",
2400 "Headphone Playback Switch",
2401 "Speaker Playback Switch",
2402 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002403 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002404 NULL,
2405};
2406
2407/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002408 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002410
2411static void alc_free_kctls(struct hda_codec *codec);
2412
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002413/* additional beep mixers; the actual parameters are overwritten at build */
2414static struct snd_kcontrol_new alc_beep_mixer[] = {
2415 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2416 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2417 { } /* end */
2418};
2419
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420static int alc_build_controls(struct hda_codec *codec)
2421{
2422 struct alc_spec *spec = codec->spec;
2423 int err;
2424 int i;
2425
2426 for (i = 0; i < spec->num_mixers; i++) {
2427 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2428 if (err < 0)
2429 return err;
2430 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002431 if (spec->cap_mixer) {
2432 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2433 if (err < 0)
2434 return err;
2435 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002437 err = snd_hda_create_spdif_out_ctls(codec,
2438 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 if (err < 0)
2440 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002441 if (!spec->no_analog) {
2442 err = snd_hda_create_spdif_share_sw(codec,
2443 &spec->multiout);
2444 if (err < 0)
2445 return err;
2446 spec->multiout.share_spdif = 1;
2447 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 }
2449 if (spec->dig_in_nid) {
2450 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2451 if (err < 0)
2452 return err;
2453 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002454
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002455 /* create beep controls if needed */
2456 if (spec->beep_amp) {
2457 struct snd_kcontrol_new *knew;
2458 for (knew = alc_beep_mixer; knew->name; knew++) {
2459 struct snd_kcontrol *kctl;
2460 kctl = snd_ctl_new1(knew, codec);
2461 if (!kctl)
2462 return -ENOMEM;
2463 kctl->private_value = spec->beep_amp;
2464 err = snd_hda_ctl_add(codec, kctl);
2465 if (err < 0)
2466 return err;
2467 }
2468 }
2469
Takashi Iwai2134ea42008-01-10 16:53:55 +01002470 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002471 if (!spec->no_analog &&
2472 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002473 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002474 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002475 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002476 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002477 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002478 if (err < 0)
2479 return err;
2480 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002481 if (!spec->no_analog &&
2482 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002483 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2484 NULL, alc_slave_sws);
2485 if (err < 0)
2486 return err;
2487 }
2488
Takashi Iwai603c4012008-07-30 15:01:44 +02002489 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 return 0;
2491}
2492
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494/*
2495 * initialize the codec volumes, etc
2496 */
2497
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498/*
2499 * generic initialization of ADC, input mixers and output mixers
2500 */
2501static struct hda_verb alc880_volume_init_verbs[] = {
2502 /*
2503 * Unmute ADC0-2 and set the default input to mic-in
2504 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002505 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002507 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002509 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002512 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2513 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002514 * Note: PASD motherboards uses the Line In 2 as the input for front
2515 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002517 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 /*
2527 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529 /* set vol=0 to output mixers */
2530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2533 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2534 /* set up input amps for analog loopback */
2535 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002542 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2543 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544
2545 { }
2546};
2547
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548/*
2549 * 3-stack pin configuration:
2550 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2551 */
2552static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2553 /*
2554 * preset connection lists of input pins
2555 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2556 */
2557 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2558 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2559 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2560
2561 /*
2562 * Set pin mode and muting
2563 */
2564 /* set front pin widgets 0x14 for output */
2565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2567 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2570 /* Mic2 (as headphone out) for HP output */
2571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573 /* Line In pin widget for input */
2574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2576 /* Line2 (as front mic) pin widget for input and vref at 80% */
2577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2578 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2579 /* CD pin widget for input */
2580 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2581
2582 { }
2583};
2584
2585/*
2586 * 5-stack pin configuration:
2587 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2588 * line-in/side = 0x1a, f-mic = 0x1b
2589 */
2590static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2591 /*
2592 * preset connection lists of input pins
2593 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2594 */
2595 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2596 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2597
2598 /*
2599 * Set pin mode and muting
2600 */
2601 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2604 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2605 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002606 /* unmute pins for output (no gain on this amp) */
2607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2611
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2615 /* Mic2 (as headphone out) for HP output */
2616 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002617 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002618 /* Line In pin widget for input */
2619 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2620 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2621 /* Line2 (as front mic) pin widget for input and vref at 80% */
2622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2623 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2624 /* CD pin widget for input */
2625 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626
2627 { }
2628};
2629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630/*
2631 * W810 pin configuration:
2632 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2633 */
2634static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 /* hphone/speaker input selector: front DAC */
2636 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2637
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2642 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2643 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2644
2645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002646 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648 { }
2649};
2650
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002651/*
2652 * Z71V pin configuration:
2653 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2654 */
2655static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002660
Takashi Iwai16ded522005-06-10 19:58:24 +02002661 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002663 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002665
2666 { }
2667};
2668
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669/*
2670 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002671 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2672 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673 */
2674static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2675 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2676
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002681 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2685
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002693 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002694 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002695
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002696 { }
2697};
Takashi Iwai16ded522005-06-10 19:58:24 +02002698
Kailang Yangccc656c2006-10-17 12:32:26 +02002699/*
2700 * Uniwill pin configuration:
2701 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2702 * line = 0x1a
2703 */
2704static struct hda_verb alc880_uniwill_init_verbs[] = {
2705 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2706
2707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2709 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2711 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2712 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2721
2722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2725 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2728 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2729 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2730 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2731
2732 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2733 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2734
2735 { }
2736};
2737
2738/*
2739* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002740* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002741 */
2742static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2743 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2744
2745 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2746 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2757
2758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2759 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2760 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2761 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2764
2765 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2766 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2767
2768 { }
2769};
2770
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002771static struct hda_verb alc880_beep_init_verbs[] = {
2772 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2773 { }
2774};
2775
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002776/* auto-toggle front mic */
2777static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2778{
2779 unsigned int present;
2780 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002781
2782 present = snd_hda_codec_read(codec, 0x18, 0,
2783 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002784 bits = present ? HDA_AMP_MUTE : 0;
2785 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002786}
2787
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002788static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002789{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002790 struct alc_spec *spec = codec->spec;
2791
2792 spec->autocfg.hp_pins[0] = 0x14;
2793 spec->autocfg.speaker_pins[0] = 0x15;
2794 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002795}
2796
2797static void alc880_uniwill_init_hook(struct hda_codec *codec)
2798{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002799 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002800 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002801}
2802
2803static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2804 unsigned int res)
2805{
2806 /* Looks like the unsol event is incompatible with the standard
2807 * definition. 4bit tag is placed at 28 bit!
2808 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002809 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002810 case ALC880_MIC_EVENT:
2811 alc880_uniwill_mic_automute(codec);
2812 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002813 default:
2814 alc_automute_amp_unsol_event(codec, res);
2815 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002816 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002817}
2818
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002819static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002820{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002821 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002822
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002823 spec->autocfg.hp_pins[0] = 0x14;
2824 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002825}
2826
2827static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2828{
2829 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002830
Kailang Yangccc656c2006-10-17 12:32:26 +02002831 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002832 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2833 present &= HDA_AMP_VOLMASK;
2834 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2835 HDA_AMP_VOLMASK, present);
2836 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2837 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002838}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002839
Kailang Yangccc656c2006-10-17 12:32:26 +02002840static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2841 unsigned int res)
2842{
2843 /* Looks like the unsol event is incompatible with the standard
2844 * definition. 4bit tag is placed at 28 bit!
2845 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002846 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002847 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002848 else
2849 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002850}
2851
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002852/*
2853 * F1734 pin configuration:
2854 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2855 */
2856static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002857 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002858 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2859 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2860 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2861 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2862
2863 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2864 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2867
2868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2869 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002871 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2872 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2873 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2874 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2875 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2876 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002877
Takashi Iwai937b4162008-02-11 14:52:36 +01002878 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2879 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2880
Takashi Iwai16ded522005-06-10 19:58:24 +02002881 { }
2882};
2883
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002884/*
2885 * ASUS pin configuration:
2886 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2887 */
2888static struct hda_verb alc880_pin_asus_init_verbs[] = {
2889 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2890 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2891 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2892 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2893
2894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2898 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2900 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2902
2903 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2905 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2909 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002912
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913 { }
2914};
2915
2916/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002917#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2918#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002919#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002920
Kailang Yangdf694da2005-12-05 19:42:22 +01002921/* Clevo m520g init */
2922static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2923 /* headphone output */
2924 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2925 /* line-out */
2926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2928 /* Line-in */
2929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2931 /* CD */
2932 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2933 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2934 /* Mic1 (rear panel) */
2935 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2936 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2937 /* Mic2 (front panel) */
2938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2940 /* headphone */
2941 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2942 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2943 /* change to EAPD mode */
2944 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2945 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2946
2947 { }
2948};
2949
2950static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002951 /* change to EAPD mode */
2952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2953 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2954
Kailang Yangdf694da2005-12-05 19:42:22 +01002955 /* Headphone output */
2956 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2957 /* Front output*/
2958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2959 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2960
2961 /* Line In pin widget for input */
2962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2963 /* CD pin widget for input */
2964 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2965 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2967
2968 /* change to EAPD mode */
2969 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2970 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2971
2972 { }
2973};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974
2975/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002976 * LG m1 express dual
2977 *
2978 * Pin assignment:
2979 * Rear Line-In/Out (blue): 0x14
2980 * Build-in Mic-In: 0x15
2981 * Speaker-out: 0x17
2982 * HP-Out (green): 0x1b
2983 * Mic-In/Out (red): 0x19
2984 * SPDIF-Out: 0x1e
2985 */
2986
2987/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2988static hda_nid_t alc880_lg_dac_nids[3] = {
2989 0x05, 0x02, 0x03
2990};
2991
2992/* seems analog CD is not working */
2993static struct hda_input_mux alc880_lg_capture_source = {
2994 .num_items = 3,
2995 .items = {
2996 { "Mic", 0x1 },
2997 { "Line", 0x5 },
2998 { "Internal Mic", 0x6 },
2999 },
3000};
3001
3002/* 2,4,6 channel modes */
3003static struct hda_verb alc880_lg_ch2_init[] = {
3004 /* set line-in and mic-in to input */
3005 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3006 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3007 { }
3008};
3009
3010static struct hda_verb alc880_lg_ch4_init[] = {
3011 /* set line-in to out and mic-in to input */
3012 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3013 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3014 { }
3015};
3016
3017static struct hda_verb alc880_lg_ch6_init[] = {
3018 /* set line-in and mic-in to output */
3019 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3020 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3021 { }
3022};
3023
3024static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3025 { 2, alc880_lg_ch2_init },
3026 { 4, alc880_lg_ch4_init },
3027 { 6, alc880_lg_ch6_init },
3028};
3029
3030static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003031 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3032 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003033 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3034 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3035 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3036 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3037 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3038 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3040 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3041 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3042 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3043 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3044 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3045 {
3046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3047 .name = "Channel Mode",
3048 .info = alc_ch_mode_info,
3049 .get = alc_ch_mode_get,
3050 .put = alc_ch_mode_put,
3051 },
3052 { } /* end */
3053};
3054
3055static struct hda_verb alc880_lg_init_verbs[] = {
3056 /* set capture source to mic-in */
3057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3060 /* mute all amp mixer inputs */
3061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003064 /* line-in to input */
3065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067 /* built-in mic */
3068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3070 /* speaker-out */
3071 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3072 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3073 /* mic-in to input */
3074 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3077 /* HP-out */
3078 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3081 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003082 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003083 { }
3084};
3085
3086/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003087static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003088{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003089 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003090
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003091 spec->autocfg.hp_pins[0] = 0x1b;
3092 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003093}
3094
3095/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003096 * LG LW20
3097 *
3098 * Pin assignment:
3099 * Speaker-out: 0x14
3100 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003101 * Built-in Mic-In: 0x19
3102 * Line-In: 0x1b
3103 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003104 * SPDIF-Out: 0x1e
3105 */
3106
Takashi Iwaid6815182006-03-23 16:06:23 +01003107static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003108 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003109 .items = {
3110 { "Mic", 0x0 },
3111 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003112 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003113 },
3114};
3115
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003116#define alc880_lg_lw_modes alc880_threestack_modes
3117
Takashi Iwaid6815182006-03-23 16:06:23 +01003118static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3120 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3121 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3122 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3123 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3125 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3126 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3131 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3132 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003133 {
3134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3135 .name = "Channel Mode",
3136 .info = alc_ch_mode_info,
3137 .get = alc_ch_mode_get,
3138 .put = alc_ch_mode_put,
3139 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003140 { } /* end */
3141};
3142
3143static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003144 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3145 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3146 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3147
Takashi Iwaid6815182006-03-23 16:06:23 +01003148 /* set capture source to mic-in */
3149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3151 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003153 /* speaker-out */
3154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3156 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003157 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3158 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3159 /* mic-in to input */
3160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3162 /* built-in mic */
3163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3165 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003166 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003167 { }
3168};
3169
3170/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003171static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003172{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003173 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003174
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003175 spec->autocfg.hp_pins[0] = 0x1b;
3176 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003177}
3178
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003179static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3180 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3181 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3184 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3185 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3186 { } /* end */
3187};
3188
3189static struct hda_input_mux alc880_medion_rim_capture_source = {
3190 .num_items = 2,
3191 .items = {
3192 { "Mic", 0x0 },
3193 { "Internal Mic", 0x1 },
3194 },
3195};
3196
3197static struct hda_verb alc880_medion_rim_init_verbs[] = {
3198 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3199
3200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3201 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3202
3203 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3206 /* Mic2 (as headphone out) for HP output */
3207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3209 /* Internal Speaker */
3210 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3211 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3212
3213 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3214 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3215
3216 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3217 { }
3218};
3219
3220/* toggle speaker-output according to the hp-jack state */
3221static void alc880_medion_rim_automute(struct hda_codec *codec)
3222{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003223 struct alc_spec *spec = codec->spec;
3224 alc_automute_amp(codec);
3225 /* toggle EAPD */
3226 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003227 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3228 else
3229 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3230}
3231
3232static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3233 unsigned int res)
3234{
3235 /* Looks like the unsol event is incompatible with the standard
3236 * definition. 4bit tag is placed at 28 bit!
3237 */
3238 if ((res >> 28) == ALC880_HP_EVENT)
3239 alc880_medion_rim_automute(codec);
3240}
3241
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003242static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003243{
3244 struct alc_spec *spec = codec->spec;
3245
3246 spec->autocfg.hp_pins[0] = 0x14;
3247 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003248}
3249
Takashi Iwaicb53c622007-08-10 17:21:45 +02003250#ifdef CONFIG_SND_HDA_POWER_SAVE
3251static struct hda_amp_list alc880_loopbacks[] = {
3252 { 0x0b, HDA_INPUT, 0 },
3253 { 0x0b, HDA_INPUT, 1 },
3254 { 0x0b, HDA_INPUT, 2 },
3255 { 0x0b, HDA_INPUT, 3 },
3256 { 0x0b, HDA_INPUT, 4 },
3257 { } /* end */
3258};
3259
3260static struct hda_amp_list alc880_lg_loopbacks[] = {
3261 { 0x0b, HDA_INPUT, 1 },
3262 { 0x0b, HDA_INPUT, 6 },
3263 { 0x0b, HDA_INPUT, 7 },
3264 { } /* end */
3265};
3266#endif
3267
Takashi Iwaid6815182006-03-23 16:06:23 +01003268/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003269 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003271
Linus Torvalds1da177e2005-04-16 15:20:36 -07003272static int alc_init(struct hda_codec *codec)
3273{
3274 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 unsigned int i;
3276
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003277 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003278 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 for (i = 0; i < spec->num_init_verbs; i++)
3281 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003282
3283 if (spec->init_hook)
3284 spec->init_hook(codec);
3285
Linus Torvalds1da177e2005-04-16 15:20:36 -07003286 return 0;
3287}
3288
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003289static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3290{
3291 struct alc_spec *spec = codec->spec;
3292
3293 if (spec->unsol_event)
3294 spec->unsol_event(codec, res);
3295}
3296
Takashi Iwaicb53c622007-08-10 17:21:45 +02003297#ifdef CONFIG_SND_HDA_POWER_SAVE
3298static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3299{
3300 struct alc_spec *spec = codec->spec;
3301 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3302}
3303#endif
3304
Linus Torvalds1da177e2005-04-16 15:20:36 -07003305/*
3306 * Analog playback callbacks
3307 */
3308static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3309 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003310 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003311{
3312 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003313 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3314 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003315}
3316
3317static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3318 struct hda_codec *codec,
3319 unsigned int stream_tag,
3320 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003321 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003322{
3323 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003324 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3325 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003326}
3327
3328static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3329 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003330 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003331{
3332 struct alc_spec *spec = codec->spec;
3333 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3334}
3335
3336/*
3337 * Digital out
3338 */
3339static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3340 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003341 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003342{
3343 struct alc_spec *spec = codec->spec;
3344 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3345}
3346
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003347static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3348 struct hda_codec *codec,
3349 unsigned int stream_tag,
3350 unsigned int format,
3351 struct snd_pcm_substream *substream)
3352{
3353 struct alc_spec *spec = codec->spec;
3354 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3355 stream_tag, format, substream);
3356}
3357
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003358static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3359 struct hda_codec *codec,
3360 struct snd_pcm_substream *substream)
3361{
3362 struct alc_spec *spec = codec->spec;
3363 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3364}
3365
Linus Torvalds1da177e2005-04-16 15:20:36 -07003366static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3367 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003368 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369{
3370 struct alc_spec *spec = codec->spec;
3371 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3372}
3373
3374/*
3375 * Analog capture
3376 */
Takashi Iwai63300792008-01-24 15:31:36 +01003377static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003378 struct hda_codec *codec,
3379 unsigned int stream_tag,
3380 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003381 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003382{
3383 struct alc_spec *spec = codec->spec;
3384
Takashi Iwai63300792008-01-24 15:31:36 +01003385 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386 stream_tag, 0, format);
3387 return 0;
3388}
3389
Takashi Iwai63300792008-01-24 15:31:36 +01003390static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003391 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003392 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393{
3394 struct alc_spec *spec = codec->spec;
3395
Takashi Iwai888afa12008-03-18 09:57:50 +01003396 snd_hda_codec_cleanup_stream(codec,
3397 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003398 return 0;
3399}
3400
3401
3402/*
3403 */
3404static struct hda_pcm_stream alc880_pcm_analog_playback = {
3405 .substreams = 1,
3406 .channels_min = 2,
3407 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003408 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003409 .ops = {
3410 .open = alc880_playback_pcm_open,
3411 .prepare = alc880_playback_pcm_prepare,
3412 .cleanup = alc880_playback_pcm_cleanup
3413 },
3414};
3415
3416static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003417 .substreams = 1,
3418 .channels_min = 2,
3419 .channels_max = 2,
3420 /* NID is set in alc_build_pcms */
3421};
3422
3423static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3424 .substreams = 1,
3425 .channels_min = 2,
3426 .channels_max = 2,
3427 /* NID is set in alc_build_pcms */
3428};
3429
3430static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3431 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432 .channels_min = 2,
3433 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003434 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003435 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003436 .prepare = alc880_alt_capture_pcm_prepare,
3437 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003438 },
3439};
3440
3441static struct hda_pcm_stream alc880_pcm_digital_playback = {
3442 .substreams = 1,
3443 .channels_min = 2,
3444 .channels_max = 2,
3445 /* NID is set in alc_build_pcms */
3446 .ops = {
3447 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003448 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003449 .prepare = alc880_dig_playback_pcm_prepare,
3450 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003451 },
3452};
3453
3454static struct hda_pcm_stream alc880_pcm_digital_capture = {
3455 .substreams = 1,
3456 .channels_min = 2,
3457 .channels_max = 2,
3458 /* NID is set in alc_build_pcms */
3459};
3460
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003461/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003462static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003463 .substreams = 0,
3464 .channels_min = 0,
3465 .channels_max = 0,
3466};
3467
Linus Torvalds1da177e2005-04-16 15:20:36 -07003468static int alc_build_pcms(struct hda_codec *codec)
3469{
3470 struct alc_spec *spec = codec->spec;
3471 struct hda_pcm *info = spec->pcm_rec;
3472 int i;
3473
3474 codec->num_pcms = 1;
3475 codec->pcm_info = info;
3476
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003477 if (spec->no_analog)
3478 goto skip_analog;
3479
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003480 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3481 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003482 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003483
Takashi Iwai4a471b72005-12-07 13:56:29 +01003484 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003485 if (snd_BUG_ON(!spec->multiout.dac_nids))
3486 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003487 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3488 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3489 }
3490 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003491 if (snd_BUG_ON(!spec->adc_nids))
3492 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003493 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3494 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3495 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496
Takashi Iwai4a471b72005-12-07 13:56:29 +01003497 if (spec->channel_mode) {
3498 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3499 for (i = 0; i < spec->num_channel_mode; i++) {
3500 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3501 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3502 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503 }
3504 }
3505
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003506 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003507 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003509 snprintf(spec->stream_name_digital,
3510 sizeof(spec->stream_name_digital),
3511 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003512 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003513 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003514 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003515 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003516 if (spec->dig_out_type)
3517 info->pcm_type = spec->dig_out_type;
3518 else
3519 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003520 if (spec->multiout.dig_out_nid &&
3521 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003522 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3523 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3524 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003525 if (spec->dig_in_nid &&
3526 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003527 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3528 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3529 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003530 /* FIXME: do we need this for all Realtek codec models? */
3531 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003532 }
3533
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003534 if (spec->no_analog)
3535 return 0;
3536
Takashi Iwaie08a0072006-09-07 17:52:14 +02003537 /* If the use of more than one ADC is requested for the current
3538 * model, configure a second analog capture-only PCM.
3539 */
3540 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003541 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3542 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003543 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003544 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003545 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003546 if (spec->alt_dac_nid) {
3547 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3548 *spec->stream_analog_alt_playback;
3549 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3550 spec->alt_dac_nid;
3551 } else {
3552 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3553 alc_pcm_null_stream;
3554 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3555 }
3556 if (spec->num_adc_nids > 1) {
3557 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3558 *spec->stream_analog_alt_capture;
3559 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3560 spec->adc_nids[1];
3561 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3562 spec->num_adc_nids - 1;
3563 } else {
3564 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3565 alc_pcm_null_stream;
3566 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003567 }
3568 }
3569
Linus Torvalds1da177e2005-04-16 15:20:36 -07003570 return 0;
3571}
3572
Takashi Iwai603c4012008-07-30 15:01:44 +02003573static void alc_free_kctls(struct hda_codec *codec)
3574{
3575 struct alc_spec *spec = codec->spec;
3576
3577 if (spec->kctls.list) {
3578 struct snd_kcontrol_new *kctl = spec->kctls.list;
3579 int i;
3580 for (i = 0; i < spec->kctls.used; i++)
3581 kfree(kctl[i].name);
3582 }
3583 snd_array_free(&spec->kctls);
3584}
3585
Linus Torvalds1da177e2005-04-16 15:20:36 -07003586static void alc_free(struct hda_codec *codec)
3587{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003588 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003590 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003591 return;
3592
Takashi Iwai603c4012008-07-30 15:01:44 +02003593 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003595 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003596}
3597
Takashi Iwaie044c392008-10-27 16:56:24 +01003598#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003599static int alc_resume(struct hda_codec *codec)
3600{
Takashi Iwaie044c392008-10-27 16:56:24 +01003601 codec->patch_ops.init(codec);
3602 snd_hda_codec_resume_amp(codec);
3603 snd_hda_codec_resume_cache(codec);
3604 return 0;
3605}
Takashi Iwaie044c392008-10-27 16:56:24 +01003606#endif
3607
Linus Torvalds1da177e2005-04-16 15:20:36 -07003608/*
3609 */
3610static struct hda_codec_ops alc_patch_ops = {
3611 .build_controls = alc_build_controls,
3612 .build_pcms = alc_build_pcms,
3613 .init = alc_init,
3614 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003615 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003616#ifdef SND_HDA_NEEDS_RESUME
3617 .resume = alc_resume,
3618#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003619#ifdef CONFIG_SND_HDA_POWER_SAVE
3620 .check_power_status = alc_check_power_status,
3621#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003622};
3623
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003624
3625/*
3626 * Test configuration for debugging
3627 *
3628 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3629 * enum controls.
3630 */
3631#ifdef CONFIG_SND_DEBUG
3632static hda_nid_t alc880_test_dac_nids[4] = {
3633 0x02, 0x03, 0x04, 0x05
3634};
3635
3636static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003637 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003638 .items = {
3639 { "In-1", 0x0 },
3640 { "In-2", 0x1 },
3641 { "In-3", 0x2 },
3642 { "In-4", 0x3 },
3643 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003644 { "Front", 0x5 },
3645 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003646 },
3647};
3648
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003649static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003650 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003651 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003652 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003653 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003654};
3655
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003656static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3657 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003658{
3659 static char *texts[] = {
3660 "N/A", "Line Out", "HP Out",
3661 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3662 };
3663 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3664 uinfo->count = 1;
3665 uinfo->value.enumerated.items = 8;
3666 if (uinfo->value.enumerated.item >= 8)
3667 uinfo->value.enumerated.item = 7;
3668 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3669 return 0;
3670}
3671
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003672static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3673 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003674{
3675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3676 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3677 unsigned int pin_ctl, item = 0;
3678
3679 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3680 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3681 if (pin_ctl & AC_PINCTL_OUT_EN) {
3682 if (pin_ctl & AC_PINCTL_HP_EN)
3683 item = 2;
3684 else
3685 item = 1;
3686 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3687 switch (pin_ctl & AC_PINCTL_VREFEN) {
3688 case AC_PINCTL_VREF_HIZ: item = 3; break;
3689 case AC_PINCTL_VREF_50: item = 4; break;
3690 case AC_PINCTL_VREF_GRD: item = 5; break;
3691 case AC_PINCTL_VREF_80: item = 6; break;
3692 case AC_PINCTL_VREF_100: item = 7; break;
3693 }
3694 }
3695 ucontrol->value.enumerated.item[0] = item;
3696 return 0;
3697}
3698
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003699static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3700 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003701{
3702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3703 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3704 static unsigned int ctls[] = {
3705 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3706 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3707 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3708 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3709 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3710 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3711 };
3712 unsigned int old_ctl, new_ctl;
3713
3714 old_ctl = snd_hda_codec_read(codec, nid, 0,
3715 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3716 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3717 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003718 int val;
3719 snd_hda_codec_write_cache(codec, nid, 0,
3720 AC_VERB_SET_PIN_WIDGET_CONTROL,
3721 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003722 val = ucontrol->value.enumerated.item[0] >= 3 ?
3723 HDA_AMP_MUTE : 0;
3724 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3725 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003726 return 1;
3727 }
3728 return 0;
3729}
3730
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003731static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3732 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003733{
3734 static char *texts[] = {
3735 "Front", "Surround", "CLFE", "Side"
3736 };
3737 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3738 uinfo->count = 1;
3739 uinfo->value.enumerated.items = 4;
3740 if (uinfo->value.enumerated.item >= 4)
3741 uinfo->value.enumerated.item = 3;
3742 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3743 return 0;
3744}
3745
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003746static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3747 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003748{
3749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3750 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3751 unsigned int sel;
3752
3753 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3754 ucontrol->value.enumerated.item[0] = sel & 3;
3755 return 0;
3756}
3757
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003758static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3759 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003760{
3761 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3762 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3763 unsigned int sel;
3764
3765 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3766 if (ucontrol->value.enumerated.item[0] != sel) {
3767 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003768 snd_hda_codec_write_cache(codec, nid, 0,
3769 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003770 return 1;
3771 }
3772 return 0;
3773}
3774
3775#define PIN_CTL_TEST(xname,nid) { \
3776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3777 .name = xname, \
3778 .info = alc_test_pin_ctl_info, \
3779 .get = alc_test_pin_ctl_get, \
3780 .put = alc_test_pin_ctl_put, \
3781 .private_value = nid \
3782 }
3783
3784#define PIN_SRC_TEST(xname,nid) { \
3785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3786 .name = xname, \
3787 .info = alc_test_pin_src_info, \
3788 .get = alc_test_pin_src_get, \
3789 .put = alc_test_pin_src_put, \
3790 .private_value = nid \
3791 }
3792
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003793static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3796 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3797 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003798 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3799 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3800 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3801 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003802 PIN_CTL_TEST("Front Pin Mode", 0x14),
3803 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3804 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3805 PIN_CTL_TEST("Side Pin Mode", 0x17),
3806 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3807 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3808 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3809 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3810 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3811 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3812 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3813 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3814 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3815 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3816 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3817 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3818 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3819 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3820 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3821 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3822 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3823 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003824 {
3825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3826 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003827 .info = alc_ch_mode_info,
3828 .get = alc_ch_mode_get,
3829 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003830 },
3831 { } /* end */
3832};
3833
3834static struct hda_verb alc880_test_init_verbs[] = {
3835 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3838 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3840 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3842 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003844 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003849 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3851 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3852 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3853 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003854 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003855 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3858 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003859 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003860 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3861 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3863 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3864 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003865 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3868 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3869 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003870 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003872 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003874 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003876 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003877 /* Analog input/passthru */
3878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003883 { }
3884};
3885#endif
3886
Linus Torvalds1da177e2005-04-16 15:20:36 -07003887/*
3888 */
3889
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003890static const char *alc880_models[ALC880_MODEL_LAST] = {
3891 [ALC880_3ST] = "3stack",
3892 [ALC880_TCL_S700] = "tcl",
3893 [ALC880_3ST_DIG] = "3stack-digout",
3894 [ALC880_CLEVO] = "clevo",
3895 [ALC880_5ST] = "5stack",
3896 [ALC880_5ST_DIG] = "5stack-digout",
3897 [ALC880_W810] = "w810",
3898 [ALC880_Z71V] = "z71v",
3899 [ALC880_6ST] = "6stack",
3900 [ALC880_6ST_DIG] = "6stack-digout",
3901 [ALC880_ASUS] = "asus",
3902 [ALC880_ASUS_W1V] = "asus-w1v",
3903 [ALC880_ASUS_DIG] = "asus-dig",
3904 [ALC880_ASUS_DIG2] = "asus-dig2",
3905 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003906 [ALC880_UNIWILL_P53] = "uniwill-p53",
3907 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003908 [ALC880_F1734] = "F1734",
3909 [ALC880_LG] = "lg",
3910 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003911 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003912#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003913 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003914#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003915 [ALC880_AUTO] = "auto",
3916};
3917
3918static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003919 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003920 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3921 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3922 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3923 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3924 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3925 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3926 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3927 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003928 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3929 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003930 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3931 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3932 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3933 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3934 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3935 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3936 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3937 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3938 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3939 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003940 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003941 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3942 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3943 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003944 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003945 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003946 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3947 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003948 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3949 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003950 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3951 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3952 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3953 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003954 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3955 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003956 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003957 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003958 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003959 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003960 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3961 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003962 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003963 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003964 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003965 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003966 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003967 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003968 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003969 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003970 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003971 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3972 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003973 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003974 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3975 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3976 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3977 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003978 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3979 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003980 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003981 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003982 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3983 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003984 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3985 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3986 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003987 /* default Intel */
3988 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003989 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3990 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003991 {}
3992};
3993
Takashi Iwai16ded522005-06-10 19:58:24 +02003994/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003995 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003996 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003997static struct alc_config_preset alc880_presets[] = {
3998 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003999 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004000 .init_verbs = { alc880_volume_init_verbs,
4001 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004002 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004003 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004004 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4005 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004006 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004007 .input_mux = &alc880_capture_source,
4008 },
4009 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004010 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004011 .init_verbs = { alc880_volume_init_verbs,
4012 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004013 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004014 .dac_nids = alc880_dac_nids,
4015 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004016 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4017 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004018 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004019 .input_mux = &alc880_capture_source,
4020 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004021 [ALC880_TCL_S700] = {
4022 .mixers = { alc880_tcl_s700_mixer },
4023 .init_verbs = { alc880_volume_init_verbs,
4024 alc880_pin_tcl_S700_init_verbs,
4025 alc880_gpio2_init_verbs },
4026 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4027 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004028 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4029 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004030 .hp_nid = 0x03,
4031 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4032 .channel_mode = alc880_2_jack_modes,
4033 .input_mux = &alc880_capture_source,
4034 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004035 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004036 .mixers = { alc880_three_stack_mixer,
4037 alc880_five_stack_mixer},
4038 .init_verbs = { alc880_volume_init_verbs,
4039 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004040 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4041 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004042 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4043 .channel_mode = alc880_fivestack_modes,
4044 .input_mux = &alc880_capture_source,
4045 },
4046 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004047 .mixers = { alc880_three_stack_mixer,
4048 alc880_five_stack_mixer },
4049 .init_verbs = { alc880_volume_init_verbs,
4050 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004051 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4052 .dac_nids = alc880_dac_nids,
4053 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004054 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4055 .channel_mode = alc880_fivestack_modes,
4056 .input_mux = &alc880_capture_source,
4057 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004058 [ALC880_6ST] = {
4059 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004060 .init_verbs = { alc880_volume_init_verbs,
4061 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004062 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4063 .dac_nids = alc880_6st_dac_nids,
4064 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4065 .channel_mode = alc880_sixstack_modes,
4066 .input_mux = &alc880_6stack_capture_source,
4067 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004068 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004070 .init_verbs = { alc880_volume_init_verbs,
4071 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004072 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4073 .dac_nids = alc880_6st_dac_nids,
4074 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004075 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4076 .channel_mode = alc880_sixstack_modes,
4077 .input_mux = &alc880_6stack_capture_source,
4078 },
4079 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004081 .init_verbs = { alc880_volume_init_verbs,
4082 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004083 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004084 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4085 .dac_nids = alc880_w810_dac_nids,
4086 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004087 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4088 .channel_mode = alc880_w810_modes,
4089 .input_mux = &alc880_capture_source,
4090 },
4091 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004092 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004093 .init_verbs = { alc880_volume_init_verbs,
4094 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004095 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4096 .dac_nids = alc880_z71v_dac_nids,
4097 .dig_out_nid = ALC880_DIGOUT_NID,
4098 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4100 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004101 .input_mux = &alc880_capture_source,
4102 },
4103 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004105 .init_verbs = { alc880_volume_init_verbs,
4106 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4108 .dac_nids = alc880_f1734_dac_nids,
4109 .hp_nid = 0x02,
4110 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4111 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004112 .input_mux = &alc880_f1734_capture_source,
4113 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004114 .setup = alc880_uniwill_p53_setup,
4115 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004116 },
4117 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004119 .init_verbs = { alc880_volume_init_verbs,
4120 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121 alc880_gpio1_init_verbs },
4122 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4123 .dac_nids = alc880_asus_dac_nids,
4124 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4125 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004126 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004127 .input_mux = &alc880_capture_source,
4128 },
4129 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004130 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004131 .init_verbs = { alc880_volume_init_verbs,
4132 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004133 alc880_gpio1_init_verbs },
4134 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4135 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004136 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4138 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004139 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004140 .input_mux = &alc880_capture_source,
4141 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004142 [ALC880_ASUS_DIG2] = {
4143 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004144 .init_verbs = { alc880_volume_init_verbs,
4145 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004146 alc880_gpio2_init_verbs }, /* use GPIO2 */
4147 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4148 .dac_nids = alc880_asus_dac_nids,
4149 .dig_out_nid = ALC880_DIGOUT_NID,
4150 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4151 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004152 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004153 .input_mux = &alc880_capture_source,
4154 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004155 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004157 .init_verbs = { alc880_volume_init_verbs,
4158 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 alc880_gpio1_init_verbs },
4160 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4161 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004162 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4164 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004165 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004166 .input_mux = &alc880_capture_source,
4167 },
4168 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004169 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004170 .init_verbs = { alc880_volume_init_verbs,
4171 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004172 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4173 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004174 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4176 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004177 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004178 .input_mux = &alc880_capture_source,
4179 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004180 [ALC880_UNIWILL] = {
4181 .mixers = { alc880_uniwill_mixer },
4182 .init_verbs = { alc880_volume_init_verbs,
4183 alc880_uniwill_init_verbs },
4184 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4185 .dac_nids = alc880_asus_dac_nids,
4186 .dig_out_nid = ALC880_DIGOUT_NID,
4187 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4188 .channel_mode = alc880_threestack_modes,
4189 .need_dac_fix = 1,
4190 .input_mux = &alc880_capture_source,
4191 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004192 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004193 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004194 },
4195 [ALC880_UNIWILL_P53] = {
4196 .mixers = { alc880_uniwill_p53_mixer },
4197 .init_verbs = { alc880_volume_init_verbs,
4198 alc880_uniwill_p53_init_verbs },
4199 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4200 .dac_nids = alc880_asus_dac_nids,
4201 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004202 .channel_mode = alc880_threestack_modes,
4203 .input_mux = &alc880_capture_source,
4204 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004205 .setup = alc880_uniwill_p53_setup,
4206 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004207 },
4208 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004209 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004210 .init_verbs = { alc880_volume_init_verbs,
4211 alc880_uniwill_p53_init_verbs,
4212 alc880_beep_init_verbs },
4213 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4214 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004215 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004216 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4217 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004218 .input_mux = &alc880_capture_source,
4219 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004220 .setup = alc880_uniwill_p53_setup,
4221 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004222 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004223 [ALC880_CLEVO] = {
4224 .mixers = { alc880_three_stack_mixer },
4225 .init_verbs = { alc880_volume_init_verbs,
4226 alc880_pin_clevo_init_verbs },
4227 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4228 .dac_nids = alc880_dac_nids,
4229 .hp_nid = 0x03,
4230 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4231 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004232 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004233 .input_mux = &alc880_capture_source,
4234 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004235 [ALC880_LG] = {
4236 .mixers = { alc880_lg_mixer },
4237 .init_verbs = { alc880_volume_init_verbs,
4238 alc880_lg_init_verbs },
4239 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4240 .dac_nids = alc880_lg_dac_nids,
4241 .dig_out_nid = ALC880_DIGOUT_NID,
4242 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4243 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004244 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004245 .input_mux = &alc880_lg_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_setup,
4248 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004249#ifdef CONFIG_SND_HDA_POWER_SAVE
4250 .loopbacks = alc880_lg_loopbacks,
4251#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004252 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004253 [ALC880_LG_LW] = {
4254 .mixers = { alc880_lg_lw_mixer },
4255 .init_verbs = { alc880_volume_init_verbs,
4256 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004257 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004258 .dac_nids = alc880_dac_nids,
4259 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004260 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4261 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004262 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004263 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004264 .setup = alc880_lg_lw_setup,
4265 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004266 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004267 [ALC880_MEDION_RIM] = {
4268 .mixers = { alc880_medion_rim_mixer },
4269 .init_verbs = { alc880_volume_init_verbs,
4270 alc880_medion_rim_init_verbs,
4271 alc_gpio2_init_verbs },
4272 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4273 .dac_nids = alc880_dac_nids,
4274 .dig_out_nid = ALC880_DIGOUT_NID,
4275 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4276 .channel_mode = alc880_2_jack_modes,
4277 .input_mux = &alc880_medion_rim_capture_source,
4278 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004279 .setup = alc880_medion_rim_setup,
4280 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004281 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004282#ifdef CONFIG_SND_DEBUG
4283 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004284 .mixers = { alc880_test_mixer },
4285 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004286 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4287 .dac_nids = alc880_test_dac_nids,
4288 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004289 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4290 .channel_mode = alc880_test_modes,
4291 .input_mux = &alc880_test_capture_source,
4292 },
4293#endif
4294};
4295
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296/*
4297 * Automatic parse of I/O pins from the BIOS configuration
4298 */
4299
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004300enum {
4301 ALC_CTL_WIDGET_VOL,
4302 ALC_CTL_WIDGET_MUTE,
4303 ALC_CTL_BIND_MUTE,
4304};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004305static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004306 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4307 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004308 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004309};
4310
4311/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004312static int add_control(struct alc_spec *spec, int type, const char *name,
4313 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004315 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316
Takashi Iwai603c4012008-07-30 15:01:44 +02004317 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4318 knew = snd_array_new(&spec->kctls);
4319 if (!knew)
4320 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004321 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004322 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004323 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 return -ENOMEM;
4325 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004326 return 0;
4327}
4328
4329#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4330#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4331#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4332#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4334#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4335#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4336#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4337#define ALC880_PIN_CD_NID 0x1c
4338
4339/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004340static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4341 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004342{
4343 hda_nid_t nid;
4344 int assigned[4];
4345 int i, j;
4346
4347 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004348 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004349
4350 /* check the pins hardwired to audio widget */
4351 for (i = 0; i < cfg->line_outs; i++) {
4352 nid = cfg->line_out_pins[i];
4353 if (alc880_is_fixed_pin(nid)) {
4354 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004355 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004356 assigned[idx] = 1;
4357 }
4358 }
4359 /* left pins can be connect to any audio widget */
4360 for (i = 0; i < cfg->line_outs; i++) {
4361 nid = cfg->line_out_pins[i];
4362 if (alc880_is_fixed_pin(nid))
4363 continue;
4364 /* search for an empty channel */
4365 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004366 if (!assigned[j]) {
4367 spec->multiout.dac_nids[i] =
4368 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369 assigned[j] = 1;
4370 break;
4371 }
4372 }
4373 }
4374 spec->multiout.num_dacs = cfg->line_outs;
4375 return 0;
4376}
4377
4378/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004379static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4380 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004381{
4382 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004383 static const char *chname[4] = {
4384 "Front", "Surround", NULL /*CLFE*/, "Side"
4385 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004386 hda_nid_t nid;
4387 int i, err;
4388
4389 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004390 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004391 continue;
4392 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4393 if (i == 2) {
4394 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004395 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4396 "Center Playback Volume",
4397 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4398 HDA_OUTPUT));
4399 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004401 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4402 "LFE Playback Volume",
4403 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4404 HDA_OUTPUT));
4405 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004406 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004407 err = add_control(spec, ALC_CTL_BIND_MUTE,
4408 "Center Playback Switch",
4409 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4410 HDA_INPUT));
4411 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004413 err = add_control(spec, ALC_CTL_BIND_MUTE,
4414 "LFE Playback Switch",
4415 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4416 HDA_INPUT));
4417 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004418 return err;
4419 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004420 const char *pfx;
4421 if (cfg->line_outs == 1 &&
4422 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4423 pfx = "Speaker";
4424 else
4425 pfx = chname[i];
4426 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004427 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4428 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4429 HDA_OUTPUT));
4430 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004431 return err;
Takashi Iwaicb162b62009-08-25 16:05:03 +02004432 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004433 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4434 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4435 HDA_INPUT));
4436 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004437 return err;
4438 }
4439 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440 return 0;
4441}
4442
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004443/* add playback controls for speaker and HP outputs */
4444static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4445 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004446{
4447 hda_nid_t nid;
4448 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004449 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004452 return 0;
4453
4454 if (alc880_is_fixed_pin(pin)) {
4455 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004456 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004457 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004459 else
4460 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461 /* control HP volume/switch on the output mixer amp */
4462 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004463 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004464 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4465 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4466 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004468 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4470 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4471 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472 return err;
4473 } else if (alc880_is_multi_pin(pin)) {
4474 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004476 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004477 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4478 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4479 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004480 return err;
4481 }
4482 return 0;
4483}
4484
4485/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004486static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4487 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004488 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489{
4490 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004491 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004492
4493 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004494 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4495 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4496 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497 return err;
4498 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004499 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4500 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4501 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502 return err;
4503 return 0;
4504}
4505
Takashi Iwai05f5f472009-08-25 13:10:18 +02004506static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004508 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4509 return (pincap & AC_PINCAP_IN) != 0;
4510}
4511
4512/* create playback/capture controls for input pins */
4513static int alc_auto_create_input_ctls(struct hda_codec *codec,
4514 const struct auto_pin_cfg *cfg,
4515 hda_nid_t mixer,
4516 hda_nid_t cap1, hda_nid_t cap2)
4517{
4518 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004519 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004520 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004521
4522 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004523 hda_nid_t pin;
4524
4525 pin = cfg->input_pins[i];
4526 if (!alc_is_input_pin(codec, pin))
4527 continue;
4528
4529 if (mixer) {
4530 idx = get_connection_index(codec, mixer, pin);
4531 if (idx >= 0) {
4532 err = new_analog_input(spec, pin,
4533 auto_pin_cfg_labels[i],
4534 idx, mixer);
4535 if (err < 0)
4536 return err;
4537 }
4538 }
4539
4540 if (!cap1)
4541 continue;
4542 idx = get_connection_index(codec, cap1, pin);
4543 if (idx < 0 && cap2)
4544 idx = get_connection_index(codec, cap2, pin);
4545 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004546 imux->items[imux->num_items].label =
4547 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004548 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004549 imux->num_items++;
4550 }
4551 }
4552 return 0;
4553}
4554
Takashi Iwai05f5f472009-08-25 13:10:18 +02004555static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4556 const struct auto_pin_cfg *cfg)
4557{
4558 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4559}
4560
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004561static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4562 unsigned int pin_type)
4563{
4564 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4565 pin_type);
4566 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004567 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4568 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004569}
4570
Kailang Yangdf694da2005-12-05 19:42:22 +01004571static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4572 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004573 int dac_idx)
4574{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004575 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004576 /* need the manual connection? */
4577 if (alc880_is_multi_pin(nid)) {
4578 struct alc_spec *spec = codec->spec;
4579 int idx = alc880_multi_pin_idx(nid);
4580 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4581 AC_VERB_SET_CONNECT_SEL,
4582 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4583 }
4584}
4585
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004586static int get_pin_type(int line_out_type)
4587{
4588 if (line_out_type == AUTO_PIN_HP_OUT)
4589 return PIN_HP;
4590 else
4591 return PIN_OUT;
4592}
4593
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594static void alc880_auto_init_multi_out(struct hda_codec *codec)
4595{
4596 struct alc_spec *spec = codec->spec;
4597 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004598
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004599 for (i = 0; i < spec->autocfg.line_outs; i++) {
4600 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004601 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4602 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004603 }
4604}
4605
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004606static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004607{
4608 struct alc_spec *spec = codec->spec;
4609 hda_nid_t pin;
4610
Takashi Iwai82bc9552006-03-21 11:24:42 +01004611 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004612 if (pin) /* connect to front */
4613 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004614 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004615 if (pin) /* connect to front */
4616 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4617}
4618
4619static void alc880_auto_init_analog_input(struct hda_codec *codec)
4620{
4621 struct alc_spec *spec = codec->spec;
4622 int i;
4623
4624 for (i = 0; i < AUTO_PIN_LAST; i++) {
4625 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004626 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004627 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004628 if (nid != ALC880_PIN_CD_NID &&
4629 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004630 snd_hda_codec_write(codec, nid, 0,
4631 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004632 AMP_OUT_MUTE);
4633 }
4634 }
4635}
4636
4637/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004638/* return 1 if successful, 0 if the proper config is not found,
4639 * or a negative error code
4640 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004641static int alc880_parse_auto_config(struct hda_codec *codec)
4642{
4643 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004644 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004645 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004646
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004647 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4648 alc880_ignore);
4649 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004651 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004653
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004654 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4655 if (err < 0)
4656 return err;
4657 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4658 if (err < 0)
4659 return err;
4660 err = alc880_auto_create_extra_out(spec,
4661 spec->autocfg.speaker_pins[0],
4662 "Speaker");
4663 if (err < 0)
4664 return err;
4665 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4666 "Headphone");
4667 if (err < 0)
4668 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004669 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004670 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004671 return err;
4672
4673 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4674
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004675 /* check multiple SPDIF-out (for recent codecs) */
4676 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4677 hda_nid_t dig_nid;
4678 err = snd_hda_get_connections(codec,
4679 spec->autocfg.dig_out_pins[i],
4680 &dig_nid, 1);
4681 if (err < 0)
4682 continue;
4683 if (!i)
4684 spec->multiout.dig_out_nid = dig_nid;
4685 else {
4686 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4687 spec->slave_dig_outs[i - 1] = dig_nid;
4688 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4689 break;
4690 }
4691 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004692 if (spec->autocfg.dig_in_pin)
4693 spec->dig_in_nid = ALC880_DIGIN_NID;
4694
Takashi Iwai603c4012008-07-30 15:01:44 +02004695 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004696 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004697
Takashi Iwaid88897e2008-10-31 15:01:37 +01004698 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004699
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004700 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004701 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004702
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004703 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4704
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004705 return 1;
4706}
4707
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004708/* additional initialization for auto-configuration model */
4709static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004710{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004711 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004712 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004713 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004714 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004715 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004716 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004717}
4718
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004719/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4720 * one of two digital mic pins, e.g. on ALC272
4721 */
4722static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004723{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004724 struct alc_spec *spec = codec->spec;
4725 int i;
4726
4727 for (i = 0; i < spec->num_adc_nids; i++) {
4728 hda_nid_t cap = spec->capsrc_nids ?
4729 spec->capsrc_nids[i] : spec->adc_nids[i];
4730 int iidx, eidx;
4731
4732 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4733 if (iidx < 0)
4734 continue;
4735 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4736 if (eidx < 0)
4737 continue;
4738 spec->int_mic.mux_idx = iidx;
4739 spec->ext_mic.mux_idx = eidx;
4740 if (spec->capsrc_nids)
4741 spec->capsrc_nids += i;
4742 spec->adc_nids += i;
4743 spec->num_adc_nids = 1;
4744 return;
4745 }
4746 snd_printd(KERN_INFO "hda_codec: %s: "
4747 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4748 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4749 spec->auto_mic = 0; /* disable auto-mic to be sure */
4750}
4751
4752static void set_capture_mixer(struct hda_codec *codec)
4753{
4754 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004755 static struct snd_kcontrol_new *caps[2][3] = {
4756 { alc_capture_mixer_nosrc1,
4757 alc_capture_mixer_nosrc2,
4758 alc_capture_mixer_nosrc3 },
4759 { alc_capture_mixer1,
4760 alc_capture_mixer2,
4761 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004762 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004763 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4764 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004765 if (spec->auto_mic) {
4766 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004767 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004768 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004769 mux = 1;
4770 else
4771 mux = 0;
4772 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4773 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004774}
4775
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004776#define set_beep_amp(spec, nid, idx, dir) \
4777 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4778
4779/*
4780 * OK, here we have finally the patch for ALC880
4781 */
4782
Linus Torvalds1da177e2005-04-16 15:20:36 -07004783static int patch_alc880(struct hda_codec *codec)
4784{
4785 struct alc_spec *spec;
4786 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004787 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004788
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004789 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004790 if (spec == NULL)
4791 return -ENOMEM;
4792
4793 codec->spec = spec;
4794
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004795 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4796 alc880_models,
4797 alc880_cfg_tbl);
4798 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004799 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4800 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004801 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004802 }
4803
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004804 if (board_config == ALC880_AUTO) {
4805 /* automatic parse from the BIOS config */
4806 err = alc880_parse_auto_config(codec);
4807 if (err < 0) {
4808 alc_free(codec);
4809 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004810 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004811 printk(KERN_INFO
4812 "hda_codec: Cannot set up configuration "
4813 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004814 board_config = ALC880_3ST;
4815 }
4816 }
4817
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004818 err = snd_hda_attach_beep_device(codec, 0x1);
4819 if (err < 0) {
4820 alc_free(codec);
4821 return err;
4822 }
4823
Kailang Yangdf694da2005-12-05 19:42:22 +01004824 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004825 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004826
Linus Torvalds1da177e2005-04-16 15:20:36 -07004827 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4828 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004829 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004830
Linus Torvalds1da177e2005-04-16 15:20:36 -07004831 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4832 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4833
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004834 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004836 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004837 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004838 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004839 if (wcap != AC_WID_AUD_IN) {
4840 spec->adc_nids = alc880_adc_nids_alt;
4841 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004842 } else {
4843 spec->adc_nids = alc880_adc_nids;
4844 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845 }
4846 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004847 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004848 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004849
Takashi Iwai2134ea42008-01-10 16:53:55 +01004850 spec->vmaster_nid = 0x0c;
4851
Linus Torvalds1da177e2005-04-16 15:20:36 -07004852 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004853 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004854 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004855#ifdef CONFIG_SND_HDA_POWER_SAVE
4856 if (!spec->loopback.amplist)
4857 spec->loopback.amplist = alc880_loopbacks;
4858#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004859 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004860
4861 return 0;
4862}
4863
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004864
Linus Torvalds1da177e2005-04-16 15:20:36 -07004865/*
4866 * ALC260 support
4867 */
4868
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869static hda_nid_t alc260_dac_nids[1] = {
4870 /* front */
4871 0x02,
4872};
4873
4874static hda_nid_t alc260_adc_nids[1] = {
4875 /* ADC0 */
4876 0x04,
4877};
4878
Kailang Yangdf694da2005-12-05 19:42:22 +01004879static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004880 /* ADC1 */
4881 0x05,
4882};
4883
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004884/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4885 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4886 */
4887static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004888 /* ADC0, ADC1 */
4889 0x04, 0x05
4890};
4891
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004892#define ALC260_DIGOUT_NID 0x03
4893#define ALC260_DIGIN_NID 0x06
4894
4895static struct hda_input_mux alc260_capture_source = {
4896 .num_items = 4,
4897 .items = {
4898 { "Mic", 0x0 },
4899 { "Front Mic", 0x1 },
4900 { "Line", 0x2 },
4901 { "CD", 0x4 },
4902 },
4903};
4904
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004905/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004906 * headphone jack and the internal CD lines since these are the only pins at
4907 * which audio can appear. For flexibility, also allow the option of
4908 * recording the mixer output on the second ADC (ADC0 doesn't have a
4909 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004910 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004911static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4912 {
4913 .num_items = 3,
4914 .items = {
4915 { "Mic/Line", 0x0 },
4916 { "CD", 0x4 },
4917 { "Headphone", 0x2 },
4918 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004919 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004920 {
4921 .num_items = 4,
4922 .items = {
4923 { "Mic/Line", 0x0 },
4924 { "CD", 0x4 },
4925 { "Headphone", 0x2 },
4926 { "Mixer", 0x5 },
4927 },
4928 },
4929
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004930};
4931
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004932/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4933 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004934 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004935static struct hda_input_mux alc260_acer_capture_sources[2] = {
4936 {
4937 .num_items = 4,
4938 .items = {
4939 { "Mic", 0x0 },
4940 { "Line", 0x2 },
4941 { "CD", 0x4 },
4942 { "Headphone", 0x5 },
4943 },
4944 },
4945 {
4946 .num_items = 5,
4947 .items = {
4948 { "Mic", 0x0 },
4949 { "Line", 0x2 },
4950 { "CD", 0x4 },
4951 { "Headphone", 0x6 },
4952 { "Mixer", 0x5 },
4953 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004954 },
4955};
Michael Schwingencc959482009-02-22 18:58:45 +01004956
4957/* Maxdata Favorit 100XS */
4958static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4959 {
4960 .num_items = 2,
4961 .items = {
4962 { "Line/Mic", 0x0 },
4963 { "CD", 0x4 },
4964 },
4965 },
4966 {
4967 .num_items = 3,
4968 .items = {
4969 { "Line/Mic", 0x0 },
4970 { "CD", 0x4 },
4971 { "Mixer", 0x5 },
4972 },
4973 },
4974};
4975
Linus Torvalds1da177e2005-04-16 15:20:36 -07004976/*
4977 * This is just place-holder, so there's something for alc_build_pcms to look
4978 * at when it calculates the maximum number of channels. ALC260 has no mixer
4979 * element which allows changing the channel mode, so the verb list is
4980 * never used.
4981 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004982static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004983 { 2, NULL },
4984};
4985
Kailang Yangdf694da2005-12-05 19:42:22 +01004986
4987/* Mixer combinations
4988 *
4989 * basic: base_output + input + pc_beep + capture
4990 * HP: base_output + input + capture_alt
4991 * HP_3013: hp_3013 + input + capture
4992 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004993 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004994 */
4995
4996static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004997 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004998 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004999 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5000 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5001 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5002 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5003 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005004};
Kailang Yangdf694da2005-12-05 19:42:22 +01005005
5006static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005007 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5008 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5009 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5010 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5012 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005015 { } /* end */
5016};
5017
Takashi Iwaibec15c32008-01-28 18:16:30 +01005018/* update HP, line and mono out pins according to the master switch */
5019static void alc260_hp_master_update(struct hda_codec *codec,
5020 hda_nid_t hp, hda_nid_t line,
5021 hda_nid_t mono)
5022{
5023 struct alc_spec *spec = codec->spec;
5024 unsigned int val = spec->master_sw ? PIN_HP : 0;
5025 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005026 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005027 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005028 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005029 val);
5030 /* mono (speaker) depending on the HP jack sense */
5031 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005032 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005033 val);
5034}
5035
5036static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5037 struct snd_ctl_elem_value *ucontrol)
5038{
5039 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5040 struct alc_spec *spec = codec->spec;
5041 *ucontrol->value.integer.value = spec->master_sw;
5042 return 0;
5043}
5044
5045static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5046 struct snd_ctl_elem_value *ucontrol)
5047{
5048 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5049 struct alc_spec *spec = codec->spec;
5050 int val = !!*ucontrol->value.integer.value;
5051 hda_nid_t hp, line, mono;
5052
5053 if (val == spec->master_sw)
5054 return 0;
5055 spec->master_sw = val;
5056 hp = (kcontrol->private_value >> 16) & 0xff;
5057 line = (kcontrol->private_value >> 8) & 0xff;
5058 mono = kcontrol->private_value & 0xff;
5059 alc260_hp_master_update(codec, hp, line, mono);
5060 return 1;
5061}
5062
5063static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5064 {
5065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5066 .name = "Master Playback Switch",
5067 .info = snd_ctl_boolean_mono_info,
5068 .get = alc260_hp_master_sw_get,
5069 .put = alc260_hp_master_sw_put,
5070 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5071 },
5072 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5073 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5074 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5075 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5076 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5077 HDA_OUTPUT),
5078 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5079 { } /* end */
5080};
5081
5082static struct hda_verb alc260_hp_unsol_verbs[] = {
5083 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5084 {},
5085};
5086
5087static void alc260_hp_automute(struct hda_codec *codec)
5088{
5089 struct alc_spec *spec = codec->spec;
5090 unsigned int present;
5091
5092 present = snd_hda_codec_read(codec, 0x10, 0,
5093 AC_VERB_GET_PIN_SENSE, 0);
5094 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5095 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5096}
5097
5098static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5099{
5100 if ((res >> 26) == ALC880_HP_EVENT)
5101 alc260_hp_automute(codec);
5102}
5103
Kailang Yangdf694da2005-12-05 19:42:22 +01005104static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005105 {
5106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5107 .name = "Master Playback Switch",
5108 .info = snd_ctl_boolean_mono_info,
5109 .get = alc260_hp_master_sw_get,
5110 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005111 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005112 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005113 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5114 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5115 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5116 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005119 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5120 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005121 { } /* end */
5122};
5123
Kailang Yang3f878302008-08-26 13:02:23 +02005124static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5125 .ops = &snd_hda_bind_vol,
5126 .values = {
5127 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5128 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5129 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5130 0
5131 },
5132};
5133
5134static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5135 .ops = &snd_hda_bind_sw,
5136 .values = {
5137 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5138 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5139 0
5140 },
5141};
5142
5143static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5144 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5145 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5146 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5148 { } /* end */
5149};
5150
Takashi Iwaibec15c32008-01-28 18:16:30 +01005151static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5152 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5153 {},
5154};
5155
5156static void alc260_hp_3013_automute(struct hda_codec *codec)
5157{
5158 struct alc_spec *spec = codec->spec;
5159 unsigned int present;
5160
5161 present = snd_hda_codec_read(codec, 0x15, 0,
5162 AC_VERB_GET_PIN_SENSE, 0);
5163 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005164 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005165}
5166
5167static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5168 unsigned int res)
5169{
5170 if ((res >> 26) == ALC880_HP_EVENT)
5171 alc260_hp_3013_automute(codec);
5172}
5173
Kailang Yang3f878302008-08-26 13:02:23 +02005174static void alc260_hp_3012_automute(struct hda_codec *codec)
5175{
5176 unsigned int present, bits;
5177
5178 present = snd_hda_codec_read(codec, 0x10, 0,
5179 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5180
5181 bits = present ? 0 : PIN_OUT;
5182 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5183 bits);
5184 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5185 bits);
5186 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5187 bits);
5188}
5189
5190static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5191 unsigned int res)
5192{
5193 if ((res >> 26) == ALC880_HP_EVENT)
5194 alc260_hp_3012_automute(codec);
5195}
5196
5197/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005198 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5199 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005200static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005201 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005202 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005203 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005204 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5205 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5206 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5207 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005208 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005209 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5210 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005211 { } /* end */
5212};
5213
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005214/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5215 * versions of the ALC260 don't act on requests to enable mic bias from NID
5216 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5217 * datasheet doesn't mention this restriction. At this stage it's not clear
5218 * whether this behaviour is intentional or is a hardware bug in chip
5219 * revisions available in early 2006. Therefore for now allow the
5220 * "Headphone Jack Mode" control to span all choices, but if it turns out
5221 * that the lack of mic bias for this NID is intentional we could change the
5222 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5223 *
5224 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5225 * don't appear to make the mic bias available from the "line" jack, even
5226 * though the NID used for this jack (0x14) can supply it. The theory is
5227 * that perhaps Acer have included blocking capacitors between the ALC260
5228 * and the output jack. If this turns out to be the case for all such
5229 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5230 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005231 *
5232 * The C20x Tablet series have a mono internal speaker which is controlled
5233 * via the chip's Mono sum widget and pin complex, so include the necessary
5234 * controls for such models. On models without a "mono speaker" the control
5235 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005236 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005237static struct snd_kcontrol_new alc260_acer_mixer[] = {
5238 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5239 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005240 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005241 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005242 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005243 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005244 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005245 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5246 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5248 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5249 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5250 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5251 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5252 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005253 { } /* end */
5254};
5255
Michael Schwingencc959482009-02-22 18:58:45 +01005256/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5257 */
5258static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5259 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5260 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5261 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5262 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5263 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5264 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5265 { } /* end */
5266};
5267
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005268/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5269 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5270 */
5271static struct snd_kcontrol_new alc260_will_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("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5278 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5279 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5280 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5281 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005282 { } /* end */
5283};
5284
5285/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5286 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5287 */
5288static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5289 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5290 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5292 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5293 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5294 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5295 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5296 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5297 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5298 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5299 { } /* end */
5300};
5301
Kailang Yangdf694da2005-12-05 19:42:22 +01005302/*
5303 * initialization verbs
5304 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005305static struct hda_verb alc260_init_verbs[] = {
5306 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005308 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005309 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005310 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005311 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005312 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005313 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005314 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005316 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005317 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005318 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005319 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005320 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005321 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005322 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005323 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5324 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005325 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005326 /* set connection select to line in (default select for this ADC) */
5327 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005328 /* mute capture amp left and right */
5329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5330 /* set connection select to line in (default select for this ADC) */
5331 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005332 /* set vol=0 Line-Out mixer amp left and right */
5333 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5334 /* unmute pin widget amp left and right (no gain on this amp) */
5335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5336 /* set vol=0 HP mixer amp left and right */
5337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5338 /* unmute pin widget amp left and right (no gain on this amp) */
5339 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5340 /* set vol=0 Mono mixer amp left and right */
5341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5342 /* unmute pin widget amp left and right (no gain on this amp) */
5343 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5344 /* unmute LINE-2 out pin */
5345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005346 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5347 * Line In 2 = 0x03
5348 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005349 /* mute analog inputs */
5350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005355 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005356 /* mute Front out path */
5357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5359 /* mute Headphone out path */
5360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5362 /* mute Mono out path */
5363 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5364 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005365 { }
5366};
5367
Takashi Iwai474167d2006-05-17 17:17:43 +02005368#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005369static struct hda_verb alc260_hp_init_verbs[] = {
5370 /* Headphone and output */
5371 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5372 /* mono output */
5373 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5374 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5375 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5376 /* Mic2 (front panel) pin widget for input and vref at 80% */
5377 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5378 /* Line In pin widget for input */
5379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5380 /* Line-2 pin widget for output */
5381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5382 /* CD pin widget for input */
5383 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5384 /* unmute amp left and right */
5385 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5386 /* set connection select to line in (default select for this ADC) */
5387 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5388 /* unmute Line-Out mixer amp left and right (volume = 0) */
5389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5390 /* mute pin widget amp left and right (no gain on this amp) */
5391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5392 /* unmute HP mixer amp left and right (volume = 0) */
5393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5394 /* mute pin widget amp left and right (no gain on this amp) */
5395 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005396 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5397 * Line In 2 = 0x03
5398 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005399 /* mute analog inputs */
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005405 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5406 /* Unmute Front out path */
5407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5409 /* Unmute Headphone out path */
5410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5411 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5412 /* Unmute Mono out path */
5413 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5414 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5415 { }
5416};
Takashi Iwai474167d2006-05-17 17:17:43 +02005417#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005418
5419static struct hda_verb alc260_hp_3013_init_verbs[] = {
5420 /* Line out and output */
5421 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5422 /* mono output */
5423 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5424 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5425 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5426 /* Mic2 (front panel) pin widget for input and vref at 80% */
5427 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5428 /* Line In pin widget for input */
5429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5430 /* Headphone pin widget for output */
5431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5432 /* CD pin widget for input */
5433 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5434 /* unmute amp left and right */
5435 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5436 /* set connection select to line in (default select for this ADC) */
5437 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5438 /* unmute Line-Out mixer amp left and right (volume = 0) */
5439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5440 /* mute pin widget amp left and right (no gain on this amp) */
5441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5442 /* unmute HP mixer amp left and right (volume = 0) */
5443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5444 /* mute pin widget amp left and right (no gain on this amp) */
5445 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005446 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5447 * Line In 2 = 0x03
5448 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005449 /* mute analog inputs */
5450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005455 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5456 /* Unmute Front out path */
5457 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5459 /* Unmute Headphone out path */
5460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5461 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5462 /* Unmute Mono out path */
5463 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5464 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5465 { }
5466};
5467
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005468/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005469 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5470 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005471 */
5472static struct hda_verb alc260_fujitsu_init_verbs[] = {
5473 /* Disable all GPIOs */
5474 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5475 /* Internal speaker is connected to headphone pin */
5476 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5477 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005479 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5481 /* Ensure all other unused pins are disabled and muted. */
5482 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5483 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005484 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005485 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005486 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005487 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005490
Jonathan Woithef7ace402006-02-28 11:46:14 +01005491 /* Disable digital (SPDIF) pins */
5492 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5493 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005494
Kailang Yangea1fb292008-08-26 12:58:38 +02005495 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005496 * when acting as an output.
5497 */
5498 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5499
5500 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5507 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5508 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005510
Jonathan Woithef7ace402006-02-28 11:46:14 +01005511 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5512 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5513 /* Unmute Line1 pin widget output buffer since it starts as an output.
5514 * If the pin mode is changed by the user the pin mode control will
5515 * take care of enabling the pin's input/output buffers as needed.
5516 * Therefore there's no need to enable the input buffer at this
5517 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005518 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005520 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005521 * mixer ctrl)
5522 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005523 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005524
Jonathan Woithef7ace402006-02-28 11:46:14 +01005525 /* Mute capture amp left and right */
5526 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005527 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005528 * in (on mic1 pin)
5529 */
5530 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005531
Jonathan Woithef7ace402006-02-28 11:46:14 +01005532 /* Do the same for the second ADC: mute capture input amp and
5533 * set ADC connection to line in (on mic1 pin)
5534 */
5535 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5536 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005537
Jonathan Woithef7ace402006-02-28 11:46:14 +01005538 /* Mute all inputs to mixer widget (even unconnected ones) */
5539 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005547
5548 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005549};
5550
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005551/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5552 * similar laptops (adapted from Fujitsu init verbs).
5553 */
5554static struct hda_verb alc260_acer_init_verbs[] = {
5555 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5556 * the headphone jack. Turn this on and rely on the standard mute
5557 * methods whenever the user wants to turn these outputs off.
5558 */
5559 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5560 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5561 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5562 /* Internal speaker/Headphone jack is connected to Line-out pin */
5563 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5564 /* Internal microphone/Mic jack is connected to Mic1 pin */
5565 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5566 /* Line In jack is connected to Line1 pin */
5567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005568 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5569 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005570 /* Ensure all other unused pins are disabled and muted. */
5571 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5572 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005573 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5574 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5577 /* Disable digital (SPDIF) pins */
5578 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5579 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5580
Kailang Yangea1fb292008-08-26 12:58:38 +02005581 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005582 * bus when acting as outputs.
5583 */
5584 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5585 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5586
5587 /* Start with output sum widgets muted and their output gains at min */
5588 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5589 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5592 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5594 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5596 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5597
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005598 /* Unmute Line-out pin widget amp left and right
5599 * (no equiv mixer ctrl)
5600 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005601 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005602 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5603 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005604 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5605 * inputs. If the pin mode is changed by the user the pin mode control
5606 * will take care of enabling the pin's input/output buffers as needed.
5607 * Therefore there's no need to enable the input buffer at this
5608 * stage.
5609 */
5610 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5611 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5612
5613 /* Mute capture amp left and right */
5614 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5615 /* Set ADC connection select to match default mixer setting - mic
5616 * (on mic1 pin)
5617 */
5618 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5619
5620 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005621 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005622 */
5623 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005624 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005625
5626 /* Mute all inputs to mixer widget (even unconnected ones) */
5627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5635
5636 { }
5637};
5638
Michael Schwingencc959482009-02-22 18:58:45 +01005639/* Initialisation sequence for Maxdata Favorit 100XS
5640 * (adapted from Acer init verbs).
5641 */
5642static struct hda_verb alc260_favorit100_init_verbs[] = {
5643 /* GPIO 0 enables the output jack.
5644 * Turn this on and rely on the standard mute
5645 * methods whenever the user wants to turn these outputs off.
5646 */
5647 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5648 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5649 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5650 /* Line/Mic input jack is connected to Mic1 pin */
5651 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5652 /* Ensure all other unused pins are disabled and muted. */
5653 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5654 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5655 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5656 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5658 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5663 /* Disable digital (SPDIF) pins */
5664 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5665 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5666
5667 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5668 * bus when acting as outputs.
5669 */
5670 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5671 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5672
5673 /* Start with output sum widgets muted and their output gains at min */
5674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5675 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5677 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5678 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5679 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5680 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5681 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5682 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5683
5684 /* Unmute Line-out pin widget amp left and right
5685 * (no equiv mixer ctrl)
5686 */
5687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5688 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5689 * inputs. If the pin mode is changed by the user the pin mode control
5690 * will take care of enabling the pin's input/output buffers as needed.
5691 * Therefore there's no need to enable the input buffer at this
5692 * stage.
5693 */
5694 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5695
5696 /* Mute capture amp left and right */
5697 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5698 /* Set ADC connection select to match default mixer setting - mic
5699 * (on mic1 pin)
5700 */
5701 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5702
5703 /* Do similar with the second ADC: mute capture input amp and
5704 * set ADC connection to mic to match ALSA's default state.
5705 */
5706 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5707 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5708
5709 /* Mute all inputs to mixer widget (even unconnected ones) */
5710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5718
5719 { }
5720};
5721
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005722static struct hda_verb alc260_will_verbs[] = {
5723 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5724 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5725 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5726 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5727 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5728 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5729 {}
5730};
5731
5732static struct hda_verb alc260_replacer_672v_verbs[] = {
5733 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5734 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5735 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5736
5737 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5738 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5739 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5740
5741 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5742 {}
5743};
5744
5745/* toggle speaker-output according to the hp-jack state */
5746static void alc260_replacer_672v_automute(struct hda_codec *codec)
5747{
5748 unsigned int present;
5749
5750 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5751 present = snd_hda_codec_read(codec, 0x0f, 0,
5752 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5753 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005754 snd_hda_codec_write_cache(codec, 0x01, 0,
5755 AC_VERB_SET_GPIO_DATA, 1);
5756 snd_hda_codec_write_cache(codec, 0x0f, 0,
5757 AC_VERB_SET_PIN_WIDGET_CONTROL,
5758 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005759 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005760 snd_hda_codec_write_cache(codec, 0x01, 0,
5761 AC_VERB_SET_GPIO_DATA, 0);
5762 snd_hda_codec_write_cache(codec, 0x0f, 0,
5763 AC_VERB_SET_PIN_WIDGET_CONTROL,
5764 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005765 }
5766}
5767
5768static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5769 unsigned int res)
5770{
5771 if ((res >> 26) == ALC880_HP_EVENT)
5772 alc260_replacer_672v_automute(codec);
5773}
5774
Kailang Yang3f878302008-08-26 13:02:23 +02005775static struct hda_verb alc260_hp_dc7600_verbs[] = {
5776 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5777 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5778 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5779 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5780 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5782 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5783 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5784 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5785 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5786 {}
5787};
5788
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005789/* Test configuration for debugging, modelled after the ALC880 test
5790 * configuration.
5791 */
5792#ifdef CONFIG_SND_DEBUG
5793static hda_nid_t alc260_test_dac_nids[1] = {
5794 0x02,
5795};
5796static hda_nid_t alc260_test_adc_nids[2] = {
5797 0x04, 0x05,
5798};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005799/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005800 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005801 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005802 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005803static struct hda_input_mux alc260_test_capture_sources[2] = {
5804 {
5805 .num_items = 7,
5806 .items = {
5807 { "MIC1 pin", 0x0 },
5808 { "MIC2 pin", 0x1 },
5809 { "LINE1 pin", 0x2 },
5810 { "LINE2 pin", 0x3 },
5811 { "CD pin", 0x4 },
5812 { "LINE-OUT pin", 0x5 },
5813 { "HP-OUT pin", 0x6 },
5814 },
5815 },
5816 {
5817 .num_items = 8,
5818 .items = {
5819 { "MIC1 pin", 0x0 },
5820 { "MIC2 pin", 0x1 },
5821 { "LINE1 pin", 0x2 },
5822 { "LINE2 pin", 0x3 },
5823 { "CD pin", 0x4 },
5824 { "Mixer", 0x5 },
5825 { "LINE-OUT pin", 0x6 },
5826 { "HP-OUT pin", 0x7 },
5827 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005828 },
5829};
5830static struct snd_kcontrol_new alc260_test_mixer[] = {
5831 /* Output driver widgets */
5832 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5833 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5834 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5835 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5836 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5837 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5838
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005839 /* Modes for retasking pin widgets
5840 * Note: the ALC260 doesn't seem to act on requests to enable mic
5841 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5842 * mention this restriction. At this stage it's not clear whether
5843 * this behaviour is intentional or is a hardware bug in chip
5844 * revisions available at least up until early 2006. Therefore for
5845 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5846 * choices, but if it turns out that the lack of mic bias for these
5847 * NIDs is intentional we could change their modes from
5848 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5849 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005850 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5851 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5852 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5853 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5854 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5855 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5856
5857 /* Loopback mixer controls */
5858 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5859 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5860 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5861 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5862 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5863 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5864 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5865 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5866 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5867 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005868 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5869 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5870 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5871 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005872
5873 /* Controls for GPIO pins, assuming they are configured as outputs */
5874 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5875 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5876 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5877 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5878
Jonathan Woithe92621f12006-02-28 11:47:47 +01005879 /* Switches to allow the digital IO pins to be enabled. The datasheet
5880 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005881 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005882 */
5883 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5884 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5885
Jonathan Woithef8225f62008-01-08 12:16:54 +01005886 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5887 * this output to turn on an external amplifier.
5888 */
5889 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5890 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5891
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005892 { } /* end */
5893};
5894static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005895 /* Enable all GPIOs as outputs with an initial value of 0 */
5896 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5897 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5898 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5899
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005900 /* Enable retasking pins as output, initially without power amp */
5901 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5902 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5903 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5905 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5906 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5907
Jonathan Woithe92621f12006-02-28 11:47:47 +01005908 /* Disable digital (SPDIF) pins initially, but users can enable
5909 * them via a mixer switch. In the case of SPDIF-out, this initverb
5910 * payload also sets the generation to 0, output to be in "consumer"
5911 * PCM format, copyright asserted, no pre-emphasis and no validity
5912 * control.
5913 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005914 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5915 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5916
Kailang Yangea1fb292008-08-26 12:58:38 +02005917 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005918 * OUT1 sum bus when acting as an output.
5919 */
5920 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5921 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5922 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5923 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5924
5925 /* Start with output sum widgets muted and their output gains at min */
5926 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5930 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5932 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5934 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5935
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005936 /* Unmute retasking pin widget output buffers since the default
5937 * state appears to be output. As the pin mode is changed by the
5938 * user the pin mode control will take care of enabling the pin's
5939 * input/output buffers as needed.
5940 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005941 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5942 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5944 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5945 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5946 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5947 /* Also unmute the mono-out pin widget */
5948 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5949
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005950 /* Mute capture amp left and right */
5951 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005952 /* Set ADC connection select to match default mixer setting (mic1
5953 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005954 */
5955 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5956
5957 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005958 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005959 */
5960 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5961 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5962
5963 /* Mute all inputs to mixer widget (even unconnected ones) */
5964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5972
5973 { }
5974};
5975#endif
5976
Takashi Iwai63300792008-01-24 15:31:36 +01005977#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5978#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005979
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005980#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5981#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5982
Kailang Yangdf694da2005-12-05 19:42:22 +01005983/*
5984 * for BIOS auto-configuration
5985 */
5986
5987static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005988 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005989{
5990 hda_nid_t nid_vol;
5991 unsigned long vol_val, sw_val;
5992 char name[32];
5993 int err;
5994
5995 if (nid >= 0x0f && nid < 0x11) {
5996 nid_vol = nid - 0x7;
5997 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5998 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5999 } else if (nid == 0x11) {
6000 nid_vol = nid - 0x7;
6001 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6002 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6003 } else if (nid >= 0x12 && nid <= 0x15) {
6004 nid_vol = 0x08;
6005 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6006 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6007 } else
6008 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006009
Takashi Iwai863b4512008-10-21 17:01:47 +02006010 if (!(*vol_bits & (1 << nid_vol))) {
6011 /* first control for the volume widget */
6012 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
6013 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
6014 if (err < 0)
6015 return err;
6016 *vol_bits |= (1 << nid_vol);
6017 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006018 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006019 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
6020 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006021 return err;
6022 return 1;
6023}
6024
6025/* add playback controls from the parsed DAC table */
6026static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6027 const struct auto_pin_cfg *cfg)
6028{
6029 hda_nid_t nid;
6030 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006031 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006032
6033 spec->multiout.num_dacs = 1;
6034 spec->multiout.dac_nids = spec->private_dac_nids;
6035 spec->multiout.dac_nids[0] = 0x02;
6036
6037 nid = cfg->line_out_pins[0];
6038 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006039 const char *pfx;
6040 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6041 pfx = "Master";
6042 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6043 pfx = "Speaker";
6044 else
6045 pfx = "Front";
6046 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006047 if (err < 0)
6048 return err;
6049 }
6050
Takashi Iwai82bc9552006-03-21 11:24:42 +01006051 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006052 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006053 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006054 if (err < 0)
6055 return err;
6056 }
6057
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006058 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006059 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006060 err = alc260_add_playback_controls(spec, nid, "Headphone",
6061 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006062 if (err < 0)
6063 return err;
6064 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006065 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006066}
6067
6068/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006069static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006070 const struct auto_pin_cfg *cfg)
6071{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006072 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006073}
6074
6075static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6076 hda_nid_t nid, int pin_type,
6077 int sel_idx)
6078{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006079 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006080 /* need the manual connection? */
6081 if (nid >= 0x12) {
6082 int idx = nid - 0x12;
6083 snd_hda_codec_write(codec, idx + 0x0b, 0,
6084 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006085 }
6086}
6087
6088static void alc260_auto_init_multi_out(struct hda_codec *codec)
6089{
6090 struct alc_spec *spec = codec->spec;
6091 hda_nid_t nid;
6092
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006093 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006094 if (nid) {
6095 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6096 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6097 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006098
Takashi Iwai82bc9552006-03-21 11:24:42 +01006099 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006100 if (nid)
6101 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6102
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006103 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006104 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006105 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006106}
Kailang Yangdf694da2005-12-05 19:42:22 +01006107
6108#define ALC260_PIN_CD_NID 0x16
6109static void alc260_auto_init_analog_input(struct hda_codec *codec)
6110{
6111 struct alc_spec *spec = codec->spec;
6112 int i;
6113
6114 for (i = 0; i < AUTO_PIN_LAST; i++) {
6115 hda_nid_t nid = spec->autocfg.input_pins[i];
6116 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006117 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006118 if (nid != ALC260_PIN_CD_NID &&
6119 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006120 snd_hda_codec_write(codec, nid, 0,
6121 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006122 AMP_OUT_MUTE);
6123 }
6124 }
6125}
6126
6127/*
6128 * generic initialization of ADC, input mixers and output mixers
6129 */
6130static struct hda_verb alc260_volume_init_verbs[] = {
6131 /*
6132 * Unmute ADC0-1 and set the default input to mic-in
6133 */
6134 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6136 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6137 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006138
Kailang Yangdf694da2005-12-05 19:42:22 +01006139 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6140 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006141 * Note: PASD motherboards uses the Line In 2 as the input for
6142 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006143 */
6144 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006145 /* mute analog inputs */
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006151
6152 /*
6153 * Set up output mixers (0x08 - 0x0a)
6154 */
6155 /* set vol=0 to output mixers */
6156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6159 /* set up input amps for analog loopback */
6160 /* Amp Indices: DAC = 0, mixer = 1 */
6161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6162 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6164 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6165 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6166 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006167
Kailang Yangdf694da2005-12-05 19:42:22 +01006168 { }
6169};
6170
6171static int alc260_parse_auto_config(struct hda_codec *codec)
6172{
6173 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006174 int err;
6175 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6176
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006177 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6178 alc260_ignore);
6179 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006180 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006181 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6182 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006183 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006184 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006185 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006186 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006187 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006188 return err;
6189
6190 spec->multiout.max_channels = 2;
6191
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006192 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006193 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006194 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006195 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006196
Takashi Iwaid88897e2008-10-31 15:01:37 +01006197 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006198
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006199 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006200 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006201
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006202 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6203
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 return 1;
6205}
6206
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006207/* additional initialization for auto-configuration model */
6208static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006209{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006210 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 alc260_auto_init_multi_out(codec);
6212 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006213 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006214 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006215}
6216
Takashi Iwaicb53c622007-08-10 17:21:45 +02006217#ifdef CONFIG_SND_HDA_POWER_SAVE
6218static struct hda_amp_list alc260_loopbacks[] = {
6219 { 0x07, HDA_INPUT, 0 },
6220 { 0x07, HDA_INPUT, 1 },
6221 { 0x07, HDA_INPUT, 2 },
6222 { 0x07, HDA_INPUT, 3 },
6223 { 0x07, HDA_INPUT, 4 },
6224 { } /* end */
6225};
6226#endif
6227
Kailang Yangdf694da2005-12-05 19:42:22 +01006228/*
6229 * ALC260 configurations
6230 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006231static const char *alc260_models[ALC260_MODEL_LAST] = {
6232 [ALC260_BASIC] = "basic",
6233 [ALC260_HP] = "hp",
6234 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006235 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006236 [ALC260_FUJITSU_S702X] = "fujitsu",
6237 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006238 [ALC260_WILL] = "will",
6239 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006240 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006241#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006242 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006243#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006244 [ALC260_AUTO] = "auto",
6245};
6246
6247static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006248 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006249 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006250 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006251 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006252 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006253 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006254 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006255 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006256 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6257 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6258 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6259 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6260 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6261 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6262 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6263 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6264 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006265 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006266 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006267 {}
6268};
6269
Kailang Yangdf694da2005-12-05 19:42:22 +01006270static struct alc_config_preset alc260_presets[] = {
6271 [ALC260_BASIC] = {
6272 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006273 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006274 .init_verbs = { alc260_init_verbs },
6275 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6276 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006277 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006278 .adc_nids = alc260_adc_nids,
6279 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6280 .channel_mode = alc260_modes,
6281 .input_mux = &alc260_capture_source,
6282 },
6283 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006284 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006285 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006286 .init_verbs = { alc260_init_verbs,
6287 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006288 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6289 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006290 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6291 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006292 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6293 .channel_mode = alc260_modes,
6294 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006295 .unsol_event = alc260_hp_unsol_event,
6296 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 },
Kailang Yang3f878302008-08-26 13:02:23 +02006298 [ALC260_HP_DC7600] = {
6299 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006300 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006301 .init_verbs = { alc260_init_verbs,
6302 alc260_hp_dc7600_verbs },
6303 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6304 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006305 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6306 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006307 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6308 .channel_mode = alc260_modes,
6309 .input_mux = &alc260_capture_source,
6310 .unsol_event = alc260_hp_3012_unsol_event,
6311 .init_hook = alc260_hp_3012_automute,
6312 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 [ALC260_HP_3013] = {
6314 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006315 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006316 .init_verbs = { alc260_hp_3013_init_verbs,
6317 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6319 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006320 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6321 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006322 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6323 .channel_mode = alc260_modes,
6324 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006325 .unsol_event = alc260_hp_3013_unsol_event,
6326 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006327 },
6328 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006329 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006330 .init_verbs = { alc260_fujitsu_init_verbs },
6331 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6332 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006333 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6334 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006335 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6336 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006337 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6338 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006339 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006340 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006341 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006342 .init_verbs = { alc260_acer_init_verbs },
6343 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6344 .dac_nids = alc260_dac_nids,
6345 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6346 .adc_nids = alc260_dual_adc_nids,
6347 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6348 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006349 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6350 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006351 },
Michael Schwingencc959482009-02-22 18:58:45 +01006352 [ALC260_FAVORIT100] = {
6353 .mixers = { alc260_favorit100_mixer },
6354 .init_verbs = { alc260_favorit100_init_verbs },
6355 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6356 .dac_nids = alc260_dac_nids,
6357 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6358 .adc_nids = alc260_dual_adc_nids,
6359 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6360 .channel_mode = alc260_modes,
6361 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6362 .input_mux = alc260_favorit100_capture_sources,
6363 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006364 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006365 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006366 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6367 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6368 .dac_nids = alc260_dac_nids,
6369 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6370 .adc_nids = alc260_adc_nids,
6371 .dig_out_nid = ALC260_DIGOUT_NID,
6372 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6373 .channel_mode = alc260_modes,
6374 .input_mux = &alc260_capture_source,
6375 },
6376 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006377 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006378 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6379 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6380 .dac_nids = alc260_dac_nids,
6381 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6382 .adc_nids = alc260_adc_nids,
6383 .dig_out_nid = ALC260_DIGOUT_NID,
6384 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6385 .channel_mode = alc260_modes,
6386 .input_mux = &alc260_capture_source,
6387 .unsol_event = alc260_replacer_672v_unsol_event,
6388 .init_hook = alc260_replacer_672v_automute,
6389 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006390#ifdef CONFIG_SND_DEBUG
6391 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006392 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006393 .init_verbs = { alc260_test_init_verbs },
6394 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6395 .dac_nids = alc260_test_dac_nids,
6396 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6397 .adc_nids = alc260_test_adc_nids,
6398 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6399 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006400 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6401 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006402 },
6403#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006404};
6405
Linus Torvalds1da177e2005-04-16 15:20:36 -07006406static int patch_alc260(struct hda_codec *codec)
6407{
6408 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006409 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006410
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006411 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006412 if (spec == NULL)
6413 return -ENOMEM;
6414
6415 codec->spec = spec;
6416
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006417 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6418 alc260_models,
6419 alc260_cfg_tbl);
6420 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006421 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006422 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006423 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006424 }
6425
Kailang Yangdf694da2005-12-05 19:42:22 +01006426 if (board_config == ALC260_AUTO) {
6427 /* automatic parse from the BIOS config */
6428 err = alc260_parse_auto_config(codec);
6429 if (err < 0) {
6430 alc_free(codec);
6431 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006432 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006433 printk(KERN_INFO
6434 "hda_codec: Cannot set up configuration "
6435 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006436 board_config = ALC260_BASIC;
6437 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006438 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006439
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006440 err = snd_hda_attach_beep_device(codec, 0x1);
6441 if (err < 0) {
6442 alc_free(codec);
6443 return err;
6444 }
6445
Kailang Yangdf694da2005-12-05 19:42:22 +01006446 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006447 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006448
Linus Torvalds1da177e2005-04-16 15:20:36 -07006449 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6450 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6451
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006452 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6453 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6454
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006455 if (!spec->adc_nids && spec->input_mux) {
6456 /* check whether NID 0x04 is valid */
6457 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006458 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006459 /* get type */
6460 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6461 spec->adc_nids = alc260_adc_nids_alt;
6462 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6463 } else {
6464 spec->adc_nids = alc260_adc_nids;
6465 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6466 }
6467 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006468 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006469 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006470
Takashi Iwai2134ea42008-01-10 16:53:55 +01006471 spec->vmaster_nid = 0x08;
6472
Linus Torvalds1da177e2005-04-16 15:20:36 -07006473 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006474 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006475 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006476#ifdef CONFIG_SND_HDA_POWER_SAVE
6477 if (!spec->loopback.amplist)
6478 spec->loopback.amplist = alc260_loopbacks;
6479#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006480 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006481
6482 return 0;
6483}
6484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006485
Linus Torvalds1da177e2005-04-16 15:20:36 -07006486/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006487 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006488 *
6489 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6490 * configuration. Each pin widget can choose any input DACs and a mixer.
6491 * Each ADC is connected from a mixer of all inputs. This makes possible
6492 * 6-channel independent captures.
6493 *
6494 * In addition, an independent DAC for the multi-playback (not used in this
6495 * driver yet).
6496 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006497#define ALC882_DIGOUT_NID 0x06
6498#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006499#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6500#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6501#define ALC1200_DIGOUT_NID 0x10
6502
Linus Torvalds1da177e2005-04-16 15:20:36 -07006503
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006504static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006505 { 8, NULL }
6506};
6507
Takashi Iwai4953550a2009-06-30 15:28:30 +02006508/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006509static hda_nid_t alc882_dac_nids[4] = {
6510 /* front, rear, clfe, rear_surr */
6511 0x02, 0x03, 0x04, 0x05
6512};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006513#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006514
Takashi Iwai4953550a2009-06-30 15:28:30 +02006515/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006516#define alc882_adc_nids alc880_adc_nids
6517#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006518#define alc883_adc_nids alc882_adc_nids_alt
6519static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6520static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6521#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006522
Takashi Iwaie1406342008-02-11 18:32:32 +01006523static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6524static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006525#define alc883_capsrc_nids alc882_capsrc_nids_alt
6526static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6527#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006528
Linus Torvalds1da177e2005-04-16 15:20:36 -07006529/* input MUX */
6530/* FIXME: should be a matrix-type input source selection */
6531
6532static struct hda_input_mux alc882_capture_source = {
6533 .num_items = 4,
6534 .items = {
6535 { "Mic", 0x0 },
6536 { "Front Mic", 0x1 },
6537 { "Line", 0x2 },
6538 { "CD", 0x4 },
6539 },
6540};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006541
Takashi Iwai4953550a2009-06-30 15:28:30 +02006542#define alc883_capture_source alc882_capture_source
6543
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006544static struct hda_input_mux alc889_capture_source = {
6545 .num_items = 3,
6546 .items = {
6547 { "Front Mic", 0x0 },
6548 { "Mic", 0x3 },
6549 { "Line", 0x2 },
6550 },
6551};
6552
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006553static struct hda_input_mux mb5_capture_source = {
6554 .num_items = 3,
6555 .items = {
6556 { "Mic", 0x1 },
6557 { "Line", 0x2 },
6558 { "CD", 0x4 },
6559 },
6560};
6561
Takashi Iwai4953550a2009-06-30 15:28:30 +02006562static struct hda_input_mux alc883_3stack_6ch_intel = {
6563 .num_items = 4,
6564 .items = {
6565 { "Mic", 0x1 },
6566 { "Front Mic", 0x0 },
6567 { "Line", 0x2 },
6568 { "CD", 0x4 },
6569 },
6570};
6571
6572static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6573 .num_items = 2,
6574 .items = {
6575 { "Mic", 0x1 },
6576 { "Line", 0x2 },
6577 },
6578};
6579
6580static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6581 .num_items = 4,
6582 .items = {
6583 { "Mic", 0x0 },
6584 { "iMic", 0x1 },
6585 { "Line", 0x2 },
6586 { "CD", 0x4 },
6587 },
6588};
6589
6590static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6591 .num_items = 2,
6592 .items = {
6593 { "Mic", 0x0 },
6594 { "Int Mic", 0x1 },
6595 },
6596};
6597
6598static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6599 .num_items = 3,
6600 .items = {
6601 { "Mic", 0x0 },
6602 { "Front Mic", 0x1 },
6603 { "Line", 0x4 },
6604 },
6605};
6606
6607static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6608 .num_items = 2,
6609 .items = {
6610 { "Mic", 0x0 },
6611 { "Line", 0x2 },
6612 },
6613};
6614
6615static struct hda_input_mux alc889A_mb31_capture_source = {
6616 .num_items = 2,
6617 .items = {
6618 { "Mic", 0x0 },
6619 /* Front Mic (0x01) unused */
6620 { "Line", 0x2 },
6621 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006622 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006623 },
6624};
6625
6626/*
6627 * 2ch mode
6628 */
6629static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6630 { 2, NULL }
6631};
6632
Kailang Yangdf694da2005-12-05 19:42:22 +01006633/*
Kailang Yang272a5272007-05-14 11:00:38 +02006634 * 2ch mode
6635 */
6636static struct hda_verb alc882_3ST_ch2_init[] = {
6637 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6638 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6639 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6640 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6641 { } /* end */
6642};
6643
6644/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006645 * 4ch mode
6646 */
6647static struct hda_verb alc882_3ST_ch4_init[] = {
6648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6650 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6651 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6652 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6653 { } /* end */
6654};
6655
6656/*
Kailang Yang272a5272007-05-14 11:00:38 +02006657 * 6ch mode
6658 */
6659static struct hda_verb alc882_3ST_ch6_init[] = {
6660 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6661 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6662 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6665 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6666 { } /* end */
6667};
6668
Takashi Iwai4953550a2009-06-30 15:28:30 +02006669static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006670 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006671 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006672 { 6, alc882_3ST_ch6_init },
6673};
6674
Takashi Iwai4953550a2009-06-30 15:28:30 +02006675#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6676
Kailang Yang272a5272007-05-14 11:00:38 +02006677/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306678 * 2ch mode
6679 */
6680static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6681 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6682 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6683 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6684 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6685 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6686 { } /* end */
6687};
6688
6689/*
6690 * 4ch mode
6691 */
6692static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6693 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6694 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6695 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6696 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6697 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6698 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6699 { } /* end */
6700};
6701
6702/*
6703 * 6ch mode
6704 */
6705static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6706 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6707 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6708 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6709 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6710 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6711 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6712 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6713 { } /* end */
6714};
6715
6716static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6717 { 2, alc883_3ST_ch2_clevo_init },
6718 { 4, alc883_3ST_ch4_clevo_init },
6719 { 6, alc883_3ST_ch6_clevo_init },
6720};
6721
6722
6723/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 * 6ch mode
6725 */
6726static struct hda_verb alc882_sixstack_ch6_init[] = {
6727 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6730 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6731 { } /* end */
6732};
6733
6734/*
6735 * 8ch mode
6736 */
6737static struct hda_verb alc882_sixstack_ch8_init[] = {
6738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6742 { } /* end */
6743};
6744
6745static struct hda_channel_mode alc882_sixstack_modes[2] = {
6746 { 6, alc882_sixstack_ch6_init },
6747 { 8, alc882_sixstack_ch8_init },
6748};
6749
Takashi Iwai87350ad2007-08-16 18:19:38 +02006750/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006751 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006752 */
6753
6754/*
6755 * 2ch mode
6756 */
6757static struct hda_verb alc885_mbp_ch2_init[] = {
6758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6759 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6760 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6761 { } /* end */
6762};
6763
6764/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006765 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006766 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006767static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6770 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6771 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6772 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6773 { } /* end */
6774};
6775
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006776static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006777 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006778 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006779};
6780
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006781/*
6782 * 2ch
6783 * Speakers/Woofer/HP = Front
6784 * LineIn = Input
6785 */
6786static struct hda_verb alc885_mb5_ch2_init[] = {
6787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6789 { } /* end */
6790};
6791
6792/*
6793 * 6ch mode
6794 * Speakers/HP = Front
6795 * Woofer = LFE
6796 * LineIn = Surround
6797 */
6798static struct hda_verb alc885_mb5_ch6_init[] = {
6799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6802 { } /* end */
6803};
6804
6805static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6806 { 2, alc885_mb5_ch2_init },
6807 { 6, alc885_mb5_ch6_init },
6808};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006809
Takashi Iwai4953550a2009-06-30 15:28:30 +02006810
6811/*
6812 * 2ch mode
6813 */
6814static struct hda_verb alc883_4ST_ch2_init[] = {
6815 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6819 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6820 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6821 { } /* end */
6822};
6823
6824/*
6825 * 4ch mode
6826 */
6827static struct hda_verb alc883_4ST_ch4_init[] = {
6828 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6829 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6834 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6835 { } /* end */
6836};
6837
6838/*
6839 * 6ch mode
6840 */
6841static struct hda_verb alc883_4ST_ch6_init[] = {
6842 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6843 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6844 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6845 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6846 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6849 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6850 { } /* end */
6851};
6852
6853/*
6854 * 8ch mode
6855 */
6856static struct hda_verb alc883_4ST_ch8_init[] = {
6857 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6858 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6859 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6862 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6865 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6866 { } /* end */
6867};
6868
6869static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6870 { 2, alc883_4ST_ch2_init },
6871 { 4, alc883_4ST_ch4_init },
6872 { 6, alc883_4ST_ch6_init },
6873 { 8, alc883_4ST_ch8_init },
6874};
6875
6876
6877/*
6878 * 2ch mode
6879 */
6880static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6881 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6882 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6885 { } /* end */
6886};
6887
6888/*
6889 * 4ch mode
6890 */
6891static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6892 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6893 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6896 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6897 { } /* end */
6898};
6899
6900/*
6901 * 6ch mode
6902 */
6903static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6904 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6905 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6906 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6907 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6908 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6909 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6910 { } /* end */
6911};
6912
6913static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6914 { 2, alc883_3ST_ch2_intel_init },
6915 { 4, alc883_3ST_ch4_intel_init },
6916 { 6, alc883_3ST_ch6_intel_init },
6917};
6918
6919/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006920 * 2ch mode
6921 */
6922static struct hda_verb alc889_ch2_intel_init[] = {
6923 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6924 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6925 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6926 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6927 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6928 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6929 { } /* end */
6930};
6931
6932/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006933 * 6ch mode
6934 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006935static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006936 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6937 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6938 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6939 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6940 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006941 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6942 { } /* end */
6943};
6944
6945/*
6946 * 8ch mode
6947 */
6948static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006949 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6950 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6951 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6952 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6953 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006954 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6955 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006956 { } /* end */
6957};
6958
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006959static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6960 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006961 { 6, alc889_ch6_intel_init },
6962 { 8, alc889_ch8_intel_init },
6963};
6964
6965/*
6966 * 6ch mode
6967 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006968static struct hda_verb alc883_sixstack_ch6_init[] = {
6969 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6970 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6971 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6972 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6973 { } /* end */
6974};
6975
6976/*
6977 * 8ch mode
6978 */
6979static struct hda_verb alc883_sixstack_ch8_init[] = {
6980 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6982 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6983 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6984 { } /* end */
6985};
6986
6987static struct hda_channel_mode alc883_sixstack_modes[2] = {
6988 { 6, alc883_sixstack_ch6_init },
6989 { 8, alc883_sixstack_ch8_init },
6990};
6991
6992
Linus Torvalds1da177e2005-04-16 15:20:36 -07006993/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6994 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6995 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006996static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006997 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006998 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006999 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007000 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007001 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7002 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007003 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7004 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007005 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007006 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007018 { } /* end */
7019};
7020
Takashi Iwai87350ad2007-08-16 18:19:38 +02007021static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007022 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7023 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7025 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7028 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7030 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007031 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7033 { } /* end */
7034};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007035
7036static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7038 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7040 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7041 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7042 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7043 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7044 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7048 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7051 { } /* end */
7052};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007053
Kailang Yangbdd148a2007-05-08 15:19:08 +02007054static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7056 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7062 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007064 { } /* end */
7065};
7066
Kailang Yang272a5272007-05-14 11:00:38 +02007067static struct snd_kcontrol_new alc882_targa_mixer[] = {
7068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7069 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007078 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7079 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007080 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007081 { } /* end */
7082};
7083
7084/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7085 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7086 */
7087static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7097 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007101 { } /* end */
7102};
7103
Takashi Iwai914759b2007-09-06 14:52:04 +02007104static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7105 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7106 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007115 { } /* end */
7116};
7117
Kailang Yangdf694da2005-12-05 19:42:22 +01007118static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7119 {
7120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7121 .name = "Channel Mode",
7122 .info = alc_ch_mode_info,
7123 .get = alc_ch_mode_get,
7124 .put = alc_ch_mode_put,
7125 },
7126 { } /* end */
7127};
7128
Takashi Iwai4953550a2009-06-30 15:28:30 +02007129static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007130 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7133 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007134 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007138 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7141 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007142 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7145 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007146
Takashi Iwaicb638122009-07-03 10:56:10 +02007147 /* mute analog input loopbacks */
7148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7153
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007154 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007157 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007158 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007159 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007162 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007163 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007165 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007166 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007167 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007168 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007169 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007170 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007171 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007172 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7173 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007174 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007175 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7176 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007177 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007178 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7179 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7180 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7182 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007183 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007184 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007185
7186 /* FIXME: use matrix-type input source selection */
7187 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007188 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007193 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007198 /* ADC2: mute amp left and right */
7199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007200 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007201 /* ADC3: mute amp left and right */
7202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007203 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007204
7205 { }
7206};
7207
Takashi Iwai4953550a2009-06-30 15:28:30 +02007208static struct hda_verb alc882_adc1_init_verbs[] = {
7209 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7213 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7214 /* ADC1: mute amp left and right */
7215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7216 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7217 { }
7218};
7219
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007220static struct hda_verb alc882_eapd_verbs[] = {
7221 /* change to EAPD mode */
7222 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007223 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007224 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007225};
7226
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007227static struct hda_verb alc889_eapd_verbs[] = {
7228 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7229 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7230 { }
7231};
7232
Wu Fengguang6732bd02009-07-30 09:19:14 +02007233static struct hda_verb alc_hp15_unsol_verbs[] = {
7234 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7236 {}
7237};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007238
7239static struct hda_verb alc885_init_verbs[] = {
7240 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7244 /* Rear mixer */
7245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7248 /* CLFE mixer */
7249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7252 /* Side mixer */
7253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7255 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7256
7257 /* mute analog input loopbacks */
7258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7261
7262 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7265 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7266 /* Front Pin: output 0 (0x0c) */
7267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7268 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7269 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7270 /* Rear Pin: output 1 (0x0d) */
7271 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7273 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7274 /* CLFE Pin: output 2 (0x0e) */
7275 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7276 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7277 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7278 /* Side Pin: output 3 (0x0f) */
7279 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7280 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7281 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7282 /* Mic (rear) pin: input vref at 80% */
7283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7285 /* Front Mic pin: input vref at 80% */
7286 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7288 /* Line In pin: input */
7289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7290 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7291
7292 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7293 /* Input mixer1 */
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7297 /* Input mixer2 */
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7301 /* Input mixer3 */
7302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7305 /* ADC2: mute amp left and right */
7306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7307 /* ADC3: mute amp left and right */
7308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7309
7310 { }
7311};
7312
7313static struct hda_verb alc885_init_input_verbs[] = {
7314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7317 { }
7318};
7319
7320
7321/* Unmute Selector 24h and set the default input to front mic */
7322static struct hda_verb alc889_init_input_verbs[] = {
7323 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7325 { }
7326};
7327
7328
Takashi Iwai4953550a2009-06-30 15:28:30 +02007329#define alc883_init_verbs alc882_base_init_verbs
7330
Tobin Davis9102cd12006-12-15 10:02:12 +01007331/* Mac Pro test */
7332static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7333 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7334 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7335 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007338 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007339 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7340 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007341 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007342 { } /* end */
7343};
7344
7345static struct hda_verb alc882_macpro_init_verbs[] = {
7346 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7350 /* Front Pin: output 0 (0x0c) */
7351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7354 /* Front Mic pin: input vref at 80% */
7355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7357 /* Speaker: output */
7358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7361 /* Headphone output (output 0 - 0x0c) */
7362 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7363 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7364 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7365
7366 /* FIXME: use matrix-type input source selection */
7367 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7368 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7373 /* Input mixer2 */
7374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7378 /* Input mixer3 */
7379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7383 /* ADC1: mute amp left and right */
7384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7385 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7386 /* ADC2: mute amp left and right */
7387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7388 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7389 /* ADC3: mute amp left and right */
7390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7391 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7392
7393 { }
7394};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007395
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007396/* Macbook 5,1 */
7397static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007398 /* DACs */
7399 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7400 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7401 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7402 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007403 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007407 /* Surround mixer */
7408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7410 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7411 /* LFE mixer */
7412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7415 /* HP mixer */
7416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7418 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7419 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007420 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7421 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007422 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7423 /* LFE Pin (0x0e) */
7424 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7426 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7427 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7429 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007430 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007431 /* Front Mic pin: input vref at 80% */
7432 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7434 /* Line In pin */
7435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7437
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7441 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7442 { }
7443};
7444
Takashi Iwai87350ad2007-08-16 18:19:38 +02007445/* Macbook Pro rev3 */
7446static struct hda_verb alc885_mbp3_init_verbs[] = {
7447 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7451 /* Rear mixer */
7452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007455 /* HP mixer */
7456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007459 /* Front Pin: output 0 (0x0c) */
7460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7462 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007463 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7466 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007467 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7468 /* Mic (rear) pin: input vref at 80% */
7469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7471 /* Front Mic pin: input vref at 80% */
7472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7474 /* Line In pin: use output 1 when in LineOut mode */
7475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7477 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7478
7479 /* FIXME: use matrix-type input source selection */
7480 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7481 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7486 /* Input mixer2 */
7487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7491 /* Input mixer3 */
7492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7496 /* ADC1: mute amp left and right */
7497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7498 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7499 /* ADC2: mute amp left and right */
7500 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7501 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7502 /* ADC3: mute amp left and right */
7503 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7504 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7505
7506 { }
7507};
7508
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007509/* iMac 24 mixer. */
7510static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7511 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7512 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7513 { } /* end */
7514};
7515
7516/* iMac 24 init verbs. */
7517static struct hda_verb alc885_imac24_init_verbs[] = {
7518 /* Internal speakers: output 0 (0x0c) */
7519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7521 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7522 /* Internal speakers: output 0 (0x0c) */
7523 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7524 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7525 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7526 /* Headphone: output 0 (0x0c) */
7527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7529 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7530 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7531 /* Front Mic: input vref at 80% */
7532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7533 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7534 { }
7535};
7536
7537/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007538static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007539{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007540 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007541
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007542 spec->autocfg.hp_pins[0] = 0x14;
7543 spec->autocfg.speaker_pins[0] = 0x18;
7544 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007545}
7546
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007547static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007548{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007549 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007550
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007551 spec->autocfg.hp_pins[0] = 0x15;
7552 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007553}
7554
7555
Kailang Yang272a5272007-05-14 11:00:38 +02007556static struct hda_verb alc882_targa_verbs[] = {
7557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7559
7560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007562
Kailang Yang272a5272007-05-14 11:00:38 +02007563 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7564 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7565 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7566
7567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007568 { } /* end */
7569};
7570
7571/* toggle speaker-output according to the hp-jack state */
7572static void alc882_targa_automute(struct hda_codec *codec)
7573{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007574 struct alc_spec *spec = codec->spec;
7575 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007576 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007577 spec->jack_present ? 1 : 3);
7578}
7579
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007580static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007581{
7582 struct alc_spec *spec = codec->spec;
7583
7584 spec->autocfg.hp_pins[0] = 0x14;
7585 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007586}
7587
7588static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7589{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007590 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007591 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007592}
7593
7594static struct hda_verb alc882_asus_a7j_verbs[] = {
7595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7597
7598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007601
Kailang Yang272a5272007-05-14 11:00:38 +02007602 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7604 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7605
7606 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7607 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7608 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7609 { } /* end */
7610};
7611
Takashi Iwai914759b2007-09-06 14:52:04 +02007612static struct hda_verb alc882_asus_a7m_verbs[] = {
7613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7615
7616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7618 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007619
Takashi Iwai914759b2007-09-06 14:52:04 +02007620 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7622 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7623
7624 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7625 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7626 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7627 { } /* end */
7628};
7629
Tobin Davis9102cd12006-12-15 10:02:12 +01007630static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7631{
7632 unsigned int gpiostate, gpiomask, gpiodir;
7633
7634 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7635 AC_VERB_GET_GPIO_DATA, 0);
7636
7637 if (!muted)
7638 gpiostate |= (1 << pin);
7639 else
7640 gpiostate &= ~(1 << pin);
7641
7642 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7643 AC_VERB_GET_GPIO_MASK, 0);
7644 gpiomask |= (1 << pin);
7645
7646 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7647 AC_VERB_GET_GPIO_DIRECTION, 0);
7648 gpiodir |= (1 << pin);
7649
7650
7651 snd_hda_codec_write(codec, codec->afg, 0,
7652 AC_VERB_SET_GPIO_MASK, gpiomask);
7653 snd_hda_codec_write(codec, codec->afg, 0,
7654 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7655
7656 msleep(1);
7657
7658 snd_hda_codec_write(codec, codec->afg, 0,
7659 AC_VERB_SET_GPIO_DATA, gpiostate);
7660}
7661
Takashi Iwai7debbe52007-08-16 15:01:03 +02007662/* set up GPIO at initialization */
7663static void alc885_macpro_init_hook(struct hda_codec *codec)
7664{
7665 alc882_gpio_mute(codec, 0, 0);
7666 alc882_gpio_mute(codec, 1, 0);
7667}
7668
7669/* set up GPIO and update auto-muting at initialization */
7670static void alc885_imac24_init_hook(struct hda_codec *codec)
7671{
7672 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007673 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007674}
7675
Kailang Yangdf694da2005-12-05 19:42:22 +01007676/*
7677 * generic initialization of ADC, input mixers and output mixers
7678 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007679static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007680 /*
7681 * Unmute ADC0-2 and set the default input to mic-in
7682 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007683 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7684 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7685 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7687
Takashi Iwaicb53c622007-08-10 17:21:45 +02007688 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007689 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007690 * Note: PASD motherboards uses the Line In 2 as the input for
7691 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007692 */
7693 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007699
7700 /*
7701 * Set up output mixers (0x0c - 0x0f)
7702 */
7703 /* set vol=0 to output mixers */
7704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7707 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7708 /* set up input amps for analog loopback */
7709 /* Amp Indices: DAC = 0, mixer = 1 */
7710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7718 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7719 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7720
7721 /* FIXME: use matrix-type input source selection */
7722 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007723 /* Input mixer2 */
7724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7728 /* Input mixer3 */
7729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7733
7734 { }
7735};
7736
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007737/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7738static struct hda_verb alc889A_mb31_ch2_init[] = {
7739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7741 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7742 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7743 { } /* end */
7744};
7745
7746/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7747static struct hda_verb alc889A_mb31_ch4_init[] = {
7748 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7749 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7750 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7752 { } /* end */
7753};
7754
7755/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7756static struct hda_verb alc889A_mb31_ch5_init[] = {
7757 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7759 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7761 { } /* end */
7762};
7763
7764/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7765static struct hda_verb alc889A_mb31_ch6_init[] = {
7766 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7770 { } /* end */
7771};
7772
7773static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7774 { 2, alc889A_mb31_ch2_init },
7775 { 4, alc889A_mb31_ch4_init },
7776 { 5, alc889A_mb31_ch5_init },
7777 { 6, alc889A_mb31_ch6_init },
7778};
7779
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007780static struct hda_verb alc883_medion_eapd_verbs[] = {
7781 /* eanable EAPD on medion laptop */
7782 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7783 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7784 { }
7785};
7786
Takashi Iwai4953550a2009-06-30 15:28:30 +02007787#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007788
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007789static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7791 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7792 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7793 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7794 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7795 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007803 { } /* end */
7804};
7805
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007806static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007807 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7808 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7810 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7814 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7815 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7816 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007817 { } /* end */
7818};
7819
Jiang zhefb97dc62008-03-06 11:07:11 +01007820static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7821 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7822 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7824 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7826 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7829 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7830 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007831 { } /* end */
7832};
7833
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007834static struct snd_kcontrol_new alc883_3ST_2ch_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_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7838 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7839 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7840 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7841 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7845 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007846 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007847 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007848 { } /* end */
7849};
7850
7851static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7852 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7853 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7854 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7855 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7856 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7857 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7858 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7859 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7868 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007869 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007870 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007871 { } /* end */
7872};
7873
Jiang zhe17bba1b2008-06-04 12:11:07 +02007874static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7876 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7877 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7878 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7879 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7880 HDA_OUTPUT),
7881 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7882 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7883 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7890 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7893 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7894 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007895 { } /* end */
7896};
7897
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007898static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7899 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7900 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7901 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7902 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7903 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7904 HDA_OUTPUT),
7905 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7906 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7907 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7908 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7909 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7910 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7914 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7919 { } /* end */
7920};
7921
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007922static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007923 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007924 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007926 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007927 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7928 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007929 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7930 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007937 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007940 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007941 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007942 { } /* end */
7943};
7944
Sasha Alexandrc2592492009-06-16 14:52:54 -04007945static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007949 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007950 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7951 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7952 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7953 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7954 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7955 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7956 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7957 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7959 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007963 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007964};
Kailang Yangccc656c2006-10-17 12:32:26 +02007965
Sasha Alexandrc2592492009-06-16 14:52:54 -04007966static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007970 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007976 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7977 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7978 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007979 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007980};
Kailang Yangccc656c2006-10-17 12:32:26 +02007981
Takashi Iwaib99dba32009-09-17 18:23:00 +02007982static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
7983 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7984 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7986 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7987 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7988 { } /* end */
7989};
7990
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007991static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007994 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7995 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007996 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008000 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008001};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008002
Kailang Yang272a5272007-05-14 11:00:38 +02008003static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8011 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8012 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008013 { } /* end */
8014};
8015
8016static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8019 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8020 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_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008026 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008027};
Kailang Yang272a5272007-05-14 11:00:38 +02008028
Tobin Davis2880a862007-08-07 11:50:26 +02008029static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008033 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8034 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8036 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008038 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008039};
Tobin Davis2880a862007-08-07 11:50:26 +02008040
Tony Vroond2fd4b02009-06-21 00:40:10 +01008041static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8044 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8051 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8052 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8053 { } /* end */
8054};
8055
Kailang Yange2757d52008-08-26 13:17:46 +02008056static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8060 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8061 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8062 0x0d, 1, 0x0, HDA_OUTPUT),
8063 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8064 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8065 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8066 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8067 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8075 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8076 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008078 { } /* end */
8079};
8080
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008081static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8082 /* Output mixers */
8083 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8084 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8085 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8086 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8087 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8088 HDA_OUTPUT),
8089 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8090 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8091 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8092 /* Output switches */
8093 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8094 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8095 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8096 /* Boost mixers */
8097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8098 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8099 /* Input mixers */
8100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8104 { } /* end */
8105};
8106
Guido Günther3e1647c2009-06-05 00:47:26 +02008107static struct snd_kcontrol_new alc883_vaiott_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", 0x15, 0x0, HDA_OUTPUT),
8111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8112 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8114 { } /* end */
8115};
8116
Kailang Yange2757d52008-08-26 13:17:46 +02008117static struct hda_bind_ctls alc883_bind_cap_vol = {
8118 .ops = &snd_hda_bind_vol,
8119 .values = {
8120 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8121 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8122 0
8123 },
8124};
8125
8126static struct hda_bind_ctls alc883_bind_cap_switch = {
8127 .ops = &snd_hda_bind_sw,
8128 .values = {
8129 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8130 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8131 0
8132 },
8133};
8134
8135static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8136 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8137 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8142 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008144 { } /* end */
8145};
8146
8147static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008148 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8149 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8150 {
8151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8152 /* .name = "Capture Source", */
8153 .name = "Input Source",
8154 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008155 .info = alc_mux_enum_info,
8156 .get = alc_mux_enum_get,
8157 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008158 },
8159 { } /* end */
8160};
8161
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008162static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8163 {
8164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8165 .name = "Channel Mode",
8166 .info = alc_ch_mode_info,
8167 .get = alc_ch_mode_get,
8168 .put = alc_ch_mode_put,
8169 },
8170 { } /* end */
8171};
8172
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008173/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008174static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008175{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008176 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008177
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008178 spec->autocfg.hp_pins[0] = 0x15;
8179 spec->autocfg.speaker_pins[0] = 0x14;
8180 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008181}
8182
8183/* auto-toggle front mic */
8184/*
8185static void alc883_mitac_mic_automute(struct hda_codec *codec)
8186{
8187 unsigned int present;
8188 unsigned char bits;
8189
8190 present = snd_hda_codec_read(codec, 0x18, 0,
8191 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8192 bits = present ? HDA_AMP_MUTE : 0;
8193 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8194}
8195*/
8196
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008197static struct hda_verb alc883_mitac_verbs[] = {
8198 /* HP */
8199 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8201 /* Subwoofer */
8202 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8203 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8204
8205 /* enable unsolicited event */
8206 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8207 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8208
8209 { } /* end */
8210};
8211
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308212static struct hda_verb alc883_clevo_m540r_verbs[] = {
8213 /* HP */
8214 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8216 /* Int speaker */
8217 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8218
8219 /* enable unsolicited event */
8220 /*
8221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8222 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8223 */
8224
8225 { } /* end */
8226};
8227
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008228static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008229 /* HP */
8230 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8232 /* Int speaker */
8233 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8235
8236 /* enable unsolicited event */
8237 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008238 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008239
8240 { } /* end */
8241};
8242
Jiang zhefb97dc62008-03-06 11:07:11 +01008243static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8244 /* HP */
8245 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8247 /* Subwoofer */
8248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8250
8251 /* enable unsolicited event */
8252 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8253
8254 { } /* end */
8255};
8256
Sasha Alexandrc2592492009-06-16 14:52:54 -04008257static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8260
8261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8262 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008263
David Heidelberger64a8be72009-06-08 16:15:18 +02008264/* Connect Line-Out side jack (SPDIF) to Side */
8265 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8266 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8267 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8268/* Connect Mic jack to CLFE */
8269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8271 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8272/* Connect Line-in jack to Surround */
8273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8275 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8276/* Connect HP out jack to Front */
8277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8279 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008280
8281 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008282
8283 { } /* end */
8284};
8285
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008286static struct hda_verb alc883_lenovo_101e_verbs[] = {
8287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8288 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8289 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8290 { } /* end */
8291};
8292
Kailang Yang272a5272007-05-14 11:00:38 +02008293static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8296 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8298 { } /* end */
8299};
8300
8301static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8304 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8305 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8306 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8307 { } /* end */
8308};
8309
Kailang Yang189609a2007-08-20 11:31:23 +02008310static struct hda_verb alc883_haier_w66_verbs[] = {
8311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8313
8314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8315
8316 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8318 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8320 { } /* end */
8321};
8322
Kailang Yange2757d52008-08-26 13:17:46 +02008323static struct hda_verb alc888_lenovo_sky_verbs[] = {
8324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8329 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8330 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8332 { } /* end */
8333};
8334
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008335static struct hda_verb alc888_6st_dell_verbs[] = {
8336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8337 { }
8338};
8339
Guido Günther3e1647c2009-06-05 00:47:26 +02008340static struct hda_verb alc883_vaiott_verbs[] = {
8341 /* HP */
8342 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8344
8345 /* enable unsolicited event */
8346 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8347
8348 { } /* end */
8349};
8350
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008351static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008352{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008353 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008354
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008355 spec->autocfg.hp_pins[0] = 0x1b;
8356 spec->autocfg.speaker_pins[0] = 0x14;
8357 spec->autocfg.speaker_pins[1] = 0x16;
8358 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008359}
8360
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008361static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008362 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008363 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8364 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008366 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008367};
8368
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008369/*
8370 * 2ch mode
8371 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008372static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008373 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8374 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8375 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8376 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008377 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008378};
8379
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008380/*
8381 * 4ch mode
8382 */
8383static struct hda_verb alc888_3st_hp_4ch_init[] = {
8384 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8385 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8386 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8387 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8388 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8389 { } /* end */
8390};
8391
8392/*
8393 * 6ch mode
8394 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008395static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008396 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8397 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008398 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008399 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8400 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008401 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8402 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008403};
8404
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008405static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008406 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008407 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008408 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008409};
8410
Kailang Yang272a5272007-05-14 11:00:38 +02008411/* toggle front-jack and RCA according to the hp-jack state */
8412static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8413{
8414 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008415
Kailang Yang272a5272007-05-14 11:00:38 +02008416 present = snd_hda_codec_read(codec, 0x1b, 0,
8417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008418 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8419 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8420 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8421 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008422}
8423
8424/* toggle RCA according to the front-jack state */
8425static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8426{
8427 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008428
Kailang Yang272a5272007-05-14 11:00:38 +02008429 present = snd_hda_codec_read(codec, 0x14, 0,
8430 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008431 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8432 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008433}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008434
Kailang Yang272a5272007-05-14 11:00:38 +02008435static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8436 unsigned int res)
8437{
8438 if ((res >> 26) == ALC880_HP_EVENT)
8439 alc888_lenovo_ms7195_front_automute(codec);
8440 if ((res >> 26) == ALC880_FRONT_EVENT)
8441 alc888_lenovo_ms7195_rca_automute(codec);
8442}
8443
8444static struct hda_verb alc883_medion_md2_verbs[] = {
8445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8447
8448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8449
8450 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8451 { } /* end */
8452};
8453
8454/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008455static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008456{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008457 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008458
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008459 spec->autocfg.hp_pins[0] = 0x14;
8460 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008461}
8462
Kailang Yangccc656c2006-10-17 12:32:26 +02008463/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008464#define alc883_targa_init_hook alc882_targa_init_hook
8465#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008466
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008467static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8468{
8469 unsigned int present;
8470
8471 present = snd_hda_codec_read(codec, 0x18, 0,
8472 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8473 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8474 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8475}
8476
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008477static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008478{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008479 struct alc_spec *spec = codec->spec;
8480
8481 spec->autocfg.hp_pins[0] = 0x15;
8482 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008483}
8484
8485static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8486{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008487 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008488 alc883_clevo_m720_mic_automute(codec);
8489}
8490
8491static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008492 unsigned int res)
8493{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008494 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008495 case ALC880_MIC_EVENT:
8496 alc883_clevo_m720_mic_automute(codec);
8497 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008498 default:
8499 alc_automute_amp_unsol_event(codec, res);
8500 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008501 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008502}
8503
Jiang zhefb97dc62008-03-06 11:07:11 +01008504/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008505static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008506{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008507 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008508
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008509 spec->autocfg.hp_pins[0] = 0x14;
8510 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008511}
8512
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008513static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008514{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008515 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008516
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008517 spec->autocfg.hp_pins[0] = 0x1b;
8518 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008519}
8520
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008521static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8522{
8523 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008524 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008525
David Heidelberger64a8be72009-06-08 16:15:18 +02008526 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8527 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008528 bits = present ? HDA_AMP_MUTE : 0;
8529 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8530 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008531}
8532
8533static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8534{
8535 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008536 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008537
8538 present = snd_hda_codec_read(codec, 0x1b, 0,
8539 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008540 bits = present ? HDA_AMP_MUTE : 0;
8541 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8542 HDA_AMP_MUTE, bits);
8543 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8544 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008545}
8546
8547static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8548 unsigned int res)
8549{
8550 if ((res >> 26) == ALC880_HP_EVENT)
8551 alc883_lenovo_101e_all_automute(codec);
8552 if ((res >> 26) == ALC880_FRONT_EVENT)
8553 alc883_lenovo_101e_ispeaker_automute(codec);
8554}
8555
Takashi Iwai676a9b52007-08-16 15:23:35 +02008556/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008557static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008558{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008559 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008560
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008561 spec->autocfg.hp_pins[0] = 0x14;
8562 spec->autocfg.speaker_pins[0] = 0x15;
8563 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008564}
8565
Kailang Yangd1a991a2007-08-15 16:21:59 +02008566static struct hda_verb alc883_acer_eapd_verbs[] = {
8567 /* HP Pin: output 0 (0x0c) */
8568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8569 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8570 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8571 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008572 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8573 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008574 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008575 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8576 /* eanable EAPD on medion laptop */
8577 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8578 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008579 /* enable unsolicited event */
8580 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008581 { }
8582};
8583
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008584static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8586 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8587 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8588 { } /* end */
8589};
8590
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008591static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008592{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008593 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008594
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008595 spec->autocfg.hp_pins[0] = 0x1b;
8596 spec->autocfg.speaker_pins[0] = 0x14;
8597 spec->autocfg.speaker_pins[1] = 0x15;
8598 spec->autocfg.speaker_pins[2] = 0x16;
8599 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008600}
8601
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008602static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008603{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008604 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008605
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008606 spec->autocfg.hp_pins[0] = 0x1b;
8607 spec->autocfg.speaker_pins[0] = 0x14;
8608 spec->autocfg.speaker_pins[1] = 0x15;
8609 spec->autocfg.speaker_pins[2] = 0x16;
8610 spec->autocfg.speaker_pins[3] = 0x17;
8611 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008612}
8613
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008614static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008615{
8616 struct alc_spec *spec = codec->spec;
8617
8618 spec->autocfg.hp_pins[0] = 0x15;
8619 spec->autocfg.speaker_pins[0] = 0x14;
8620 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008621}
8622
Kailang Yange2757d52008-08-26 13:17:46 +02008623static struct hda_verb alc888_asus_m90v_verbs[] = {
8624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8627 /* enable unsolicited event */
8628 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8629 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8630 { } /* end */
8631};
8632
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008633static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008634{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008635 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008636
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008637 spec->autocfg.hp_pins[0] = 0x1b;
8638 spec->autocfg.speaker_pins[0] = 0x14;
8639 spec->autocfg.speaker_pins[1] = 0x15;
8640 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008641 spec->ext_mic.pin = 0x18;
8642 spec->int_mic.pin = 0x19;
8643 spec->ext_mic.mux_idx = 0;
8644 spec->int_mic.mux_idx = 1;
8645 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008646}
8647
8648static struct hda_verb alc888_asus_eee1601_verbs[] = {
8649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8654 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8655 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8656 /* enable unsolicited event */
8657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8658 { } /* end */
8659};
8660
Kailang Yange2757d52008-08-26 13:17:46 +02008661static void alc883_eee1601_inithook(struct hda_codec *codec)
8662{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008663 struct alc_spec *spec = codec->spec;
8664
8665 spec->autocfg.hp_pins[0] = 0x14;
8666 spec->autocfg.speaker_pins[0] = 0x1b;
8667 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008668}
8669
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008670static struct hda_verb alc889A_mb31_verbs[] = {
8671 /* Init rear pin (used as headphone output) */
8672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8674 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8675 /* Init line pin (used as output in 4ch and 6ch mode) */
8676 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8677 /* Init line 2 pin (used as headphone out by default) */
8678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8680 { } /* end */
8681};
8682
8683/* Mute speakers according to the headphone jack state */
8684static void alc889A_mb31_automute(struct hda_codec *codec)
8685{
8686 unsigned int present;
8687
8688 /* Mute only in 2ch or 4ch mode */
8689 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8690 == 0x00) {
8691 present = snd_hda_codec_read(codec, 0x15, 0,
8692 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8693 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8694 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8695 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8696 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8697 }
8698}
8699
8700static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8701{
8702 if ((res >> 26) == ALC880_HP_EVENT)
8703 alc889A_mb31_automute(codec);
8704}
8705
Takashi Iwai4953550a2009-06-30 15:28:30 +02008706
Takashi Iwaicb53c622007-08-10 17:21:45 +02008707#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008708#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008709#endif
8710
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008711/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008712#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8713#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8714#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8715#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8716
8717static hda_nid_t alc883_slave_dig_outs[] = {
8718 ALC1200_DIGOUT_NID, 0,
8719};
8720
8721static hda_nid_t alc1200_slave_dig_outs[] = {
8722 ALC883_DIGOUT_NID, 0,
8723};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008724
8725/*
8726 * configuration and preset
8727 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008728static const char *alc882_models[ALC882_MODEL_LAST] = {
8729 [ALC882_3ST_DIG] = "3stack-dig",
8730 [ALC882_6ST_DIG] = "6stack-dig",
8731 [ALC882_ARIMA] = "arima",
8732 [ALC882_W2JC] = "w2jc",
8733 [ALC882_TARGA] = "targa",
8734 [ALC882_ASUS_A7J] = "asus-a7j",
8735 [ALC882_ASUS_A7M] = "asus-a7m",
8736 [ALC885_MACPRO] = "macpro",
8737 [ALC885_MB5] = "mb5",
8738 [ALC885_MBP3] = "mbp3",
8739 [ALC885_IMAC24] = "imac24",
8740 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008741 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8742 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008743 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008744 [ALC883_TARGA_DIG] = "targa-dig",
8745 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008746 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008747 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008748 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008749 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008750 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008751 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008752 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008753 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008754 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008755 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008756 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008757 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8758 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008759 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008760 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008761 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008762 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008763 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308764 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008765 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008766 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008767 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008768 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008769 [ALC889A_INTEL] = "intel-alc889a",
8770 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008771 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008772 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008773 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008774 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008775};
8776
Takashi Iwai4953550a2009-06-30 15:28:30 +02008777static struct snd_pci_quirk alc882_cfg_tbl[] = {
8778 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8779
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008780 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008781 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008782 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008783 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8784 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008785 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008786 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8787 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008788 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8789 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008790 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8791 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008792 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8793 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008794 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8795 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008796 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008797 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008798 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008799 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008800 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8801 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008802 /* default Acer -- disabled as it causes more problems.
8803 * model=auto should work fine now
8804 */
8805 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008806
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008807 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008808
Tobin Davisfebe3372007-06-12 11:27:46 +02008809 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008810 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8811 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008812 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008813 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008814 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008815
8816 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8817 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8818 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008819 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008820 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8821 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8822 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008823 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008824 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008825 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008826 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008827
8828 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008829 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008830 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008831 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008832 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8833 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008834 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008835 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008836 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8837
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008838 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8839 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8840 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008841 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008842 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008843 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008844 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008845 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008846 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8847 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8848 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8849 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8850 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8851 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008852 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008853 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8854 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8855 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008856 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008857 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8858 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008859 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008860 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008861 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008862 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008863 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008864 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008865 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008866 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008867
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008868 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008869 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8870 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308871 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008872 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008873 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008874 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008875 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008876 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008877 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008878 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008879 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008880 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008881 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008882 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8883 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008884 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008885 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008886 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008887 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008888 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008889
Jiang zhe17bba1b2008-06-04 12:11:07 +02008890 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8891 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008892 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008893 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8894 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8895 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008896 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008897
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008898 {}
8899};
8900
Takashi Iwai4953550a2009-06-30 15:28:30 +02008901/* codec SSID table for Intel Mac */
8902static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8903 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8904 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8905 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8906 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8907 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8908 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8909 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8910 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8911 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8912 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8913 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8914 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8915 * no perfect solution yet
8916 */
8917 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8918 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008919};
8920
Takashi Iwai4953550a2009-06-30 15:28:30 +02008921static struct alc_config_preset alc882_presets[] = {
8922 [ALC882_3ST_DIG] = {
8923 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008924 .init_verbs = { alc882_base_init_verbs,
8925 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008926 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8927 .dac_nids = alc882_dac_nids,
8928 .dig_out_nid = ALC882_DIGOUT_NID,
8929 .dig_in_nid = ALC882_DIGIN_NID,
8930 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8931 .channel_mode = alc882_ch_modes,
8932 .need_dac_fix = 1,
8933 .input_mux = &alc882_capture_source,
8934 },
8935 [ALC882_6ST_DIG] = {
8936 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008937 .init_verbs = { alc882_base_init_verbs,
8938 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008939 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8940 .dac_nids = alc882_dac_nids,
8941 .dig_out_nid = ALC882_DIGOUT_NID,
8942 .dig_in_nid = ALC882_DIGIN_NID,
8943 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8944 .channel_mode = alc882_sixstack_modes,
8945 .input_mux = &alc882_capture_source,
8946 },
8947 [ALC882_ARIMA] = {
8948 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008949 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8950 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008951 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8952 .dac_nids = alc882_dac_nids,
8953 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8954 .channel_mode = alc882_sixstack_modes,
8955 .input_mux = &alc882_capture_source,
8956 },
8957 [ALC882_W2JC] = {
8958 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008959 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8960 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008961 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8962 .dac_nids = alc882_dac_nids,
8963 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8964 .channel_mode = alc880_threestack_modes,
8965 .need_dac_fix = 1,
8966 .input_mux = &alc882_capture_source,
8967 .dig_out_nid = ALC882_DIGOUT_NID,
8968 },
8969 [ALC885_MBP3] = {
8970 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8971 .init_verbs = { alc885_mbp3_init_verbs,
8972 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008973 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008974 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008975 .hp_nid = 0x04,
8976 .channel_mode = alc885_mbp_4ch_modes,
8977 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008978 .input_mux = &alc882_capture_source,
8979 .dig_out_nid = ALC882_DIGOUT_NID,
8980 .dig_in_nid = ALC882_DIGIN_NID,
8981 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008982 .setup = alc885_mbp3_setup,
8983 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008984 },
8985 [ALC885_MB5] = {
8986 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8987 .init_verbs = { alc885_mb5_init_verbs,
8988 alc880_gpio1_init_verbs },
8989 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8990 .dac_nids = alc882_dac_nids,
8991 .channel_mode = alc885_mb5_6ch_modes,
8992 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8993 .input_mux = &mb5_capture_source,
8994 .dig_out_nid = ALC882_DIGOUT_NID,
8995 .dig_in_nid = ALC882_DIGIN_NID,
8996 },
8997 [ALC885_MACPRO] = {
8998 .mixers = { alc882_macpro_mixer },
8999 .init_verbs = { alc882_macpro_init_verbs },
9000 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9001 .dac_nids = alc882_dac_nids,
9002 .dig_out_nid = ALC882_DIGOUT_NID,
9003 .dig_in_nid = ALC882_DIGIN_NID,
9004 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9005 .channel_mode = alc882_ch_modes,
9006 .input_mux = &alc882_capture_source,
9007 .init_hook = alc885_macpro_init_hook,
9008 },
9009 [ALC885_IMAC24] = {
9010 .mixers = { alc885_imac24_mixer },
9011 .init_verbs = { alc885_imac24_init_verbs },
9012 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9013 .dac_nids = alc882_dac_nids,
9014 .dig_out_nid = ALC882_DIGOUT_NID,
9015 .dig_in_nid = ALC882_DIGIN_NID,
9016 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9017 .channel_mode = alc882_ch_modes,
9018 .input_mux = &alc882_capture_source,
9019 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009020 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009021 .init_hook = alc885_imac24_init_hook,
9022 },
9023 [ALC882_TARGA] = {
9024 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009025 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009026 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009027 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9028 .dac_nids = alc882_dac_nids,
9029 .dig_out_nid = ALC882_DIGOUT_NID,
9030 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9031 .adc_nids = alc882_adc_nids,
9032 .capsrc_nids = alc882_capsrc_nids,
9033 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9034 .channel_mode = alc882_3ST_6ch_modes,
9035 .need_dac_fix = 1,
9036 .input_mux = &alc882_capture_source,
9037 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009038 .setup = alc882_targa_setup,
9039 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009040 },
9041 [ALC882_ASUS_A7J] = {
9042 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009043 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9044 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009045 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9046 .dac_nids = alc882_dac_nids,
9047 .dig_out_nid = ALC882_DIGOUT_NID,
9048 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9049 .adc_nids = alc882_adc_nids,
9050 .capsrc_nids = alc882_capsrc_nids,
9051 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9052 .channel_mode = alc882_3ST_6ch_modes,
9053 .need_dac_fix = 1,
9054 .input_mux = &alc882_capture_source,
9055 },
9056 [ALC882_ASUS_A7M] = {
9057 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009058 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9059 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009060 alc882_asus_a7m_verbs },
9061 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9062 .dac_nids = alc882_dac_nids,
9063 .dig_out_nid = ALC882_DIGOUT_NID,
9064 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9065 .channel_mode = alc880_threestack_modes,
9066 .need_dac_fix = 1,
9067 .input_mux = &alc882_capture_source,
9068 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009069 [ALC883_3ST_2ch_DIG] = {
9070 .mixers = { alc883_3ST_2ch_mixer },
9071 .init_verbs = { alc883_init_verbs },
9072 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9073 .dac_nids = alc883_dac_nids,
9074 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009075 .dig_in_nid = ALC883_DIGIN_NID,
9076 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9077 .channel_mode = alc883_3ST_2ch_modes,
9078 .input_mux = &alc883_capture_source,
9079 },
9080 [ALC883_3ST_6ch_DIG] = {
9081 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9082 .init_verbs = { alc883_init_verbs },
9083 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9084 .dac_nids = alc883_dac_nids,
9085 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009086 .dig_in_nid = ALC883_DIGIN_NID,
9087 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9088 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009089 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009090 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009091 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009092 [ALC883_3ST_6ch] = {
9093 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9094 .init_verbs = { alc883_init_verbs },
9095 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9096 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009097 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9098 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009099 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009100 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009101 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009102 [ALC883_3ST_6ch_INTEL] = {
9103 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9104 .init_verbs = { alc883_init_verbs },
9105 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9106 .dac_nids = alc883_dac_nids,
9107 .dig_out_nid = ALC883_DIGOUT_NID,
9108 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009109 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009110 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9111 .channel_mode = alc883_3ST_6ch_intel_modes,
9112 .need_dac_fix = 1,
9113 .input_mux = &alc883_3stack_6ch_intel,
9114 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009115 [ALC889A_INTEL] = {
9116 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009117 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9118 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009119 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9120 .dac_nids = alc883_dac_nids,
9121 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9122 .adc_nids = alc889_adc_nids,
9123 .dig_out_nid = ALC883_DIGOUT_NID,
9124 .dig_in_nid = ALC883_DIGIN_NID,
9125 .slave_dig_outs = alc883_slave_dig_outs,
9126 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9127 .channel_mode = alc889_8ch_intel_modes,
9128 .capsrc_nids = alc889_capsrc_nids,
9129 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009130 .setup = alc889_automute_setup,
9131 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009132 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009133 .need_dac_fix = 1,
9134 },
9135 [ALC889_INTEL] = {
9136 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9137 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009138 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009139 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9140 .dac_nids = alc883_dac_nids,
9141 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9142 .adc_nids = alc889_adc_nids,
9143 .dig_out_nid = ALC883_DIGOUT_NID,
9144 .dig_in_nid = ALC883_DIGIN_NID,
9145 .slave_dig_outs = alc883_slave_dig_outs,
9146 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9147 .channel_mode = alc889_8ch_intel_modes,
9148 .capsrc_nids = alc889_capsrc_nids,
9149 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009150 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009151 .init_hook = alc889_intel_init_hook,
9152 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009153 .need_dac_fix = 1,
9154 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009155 [ALC883_6ST_DIG] = {
9156 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9157 .init_verbs = { alc883_init_verbs },
9158 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9159 .dac_nids = alc883_dac_nids,
9160 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009161 .dig_in_nid = ALC883_DIGIN_NID,
9162 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9163 .channel_mode = alc883_sixstack_modes,
9164 .input_mux = &alc883_capture_source,
9165 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009166 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009167 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009168 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9169 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9171 .dac_nids = alc883_dac_nids,
9172 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009173 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9174 .channel_mode = alc883_3ST_6ch_modes,
9175 .need_dac_fix = 1,
9176 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009177 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009178 .setup = alc882_targa_setup,
9179 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009180 },
9181 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009182 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009183 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9184 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009185 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9186 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009187 .adc_nids = alc883_adc_nids_alt,
9188 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009189 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9191 .channel_mode = alc883_3ST_2ch_modes,
9192 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009193 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009194 .setup = alc882_targa_setup,
9195 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009196 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009197 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009198 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9199 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009200 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009201 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009202 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9203 .dac_nids = alc883_dac_nids,
9204 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9205 .adc_nids = alc883_adc_nids_rev,
9206 .capsrc_nids = alc883_capsrc_nids_rev,
9207 .dig_out_nid = ALC883_DIGOUT_NID,
9208 .dig_in_nid = ALC883_DIGIN_NID,
9209 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9210 .channel_mode = alc883_4ST_8ch_modes,
9211 .need_dac_fix = 1,
9212 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009213 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009214 .setup = alc882_targa_setup,
9215 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009216 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009217 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009218 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009219 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9220 * and the headphone jack. Turn this on and rely on the
9221 * standard mute methods whenever the user wants to turn
9222 * these outputs off.
9223 */
9224 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9225 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9226 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009227 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9228 .channel_mode = alc883_3ST_2ch_modes,
9229 .input_mux = &alc883_capture_source,
9230 },
Tobin Davis2880a862007-08-07 11:50:26 +02009231 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009232 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009233 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009234 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9235 .dac_nids = alc883_dac_nids,
9236 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009237 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9238 .channel_mode = alc883_3ST_2ch_modes,
9239 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009240 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009241 .setup = alc883_acer_aspire_setup,
9242 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009243 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009244 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009245 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009246 alc883_chmode_mixer },
9247 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9248 alc888_acer_aspire_4930g_verbs },
9249 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9250 .dac_nids = alc883_dac_nids,
9251 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9252 .adc_nids = alc883_adc_nids_rev,
9253 .capsrc_nids = alc883_capsrc_nids_rev,
9254 .dig_out_nid = ALC883_DIGOUT_NID,
9255 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9256 .channel_mode = alc883_3ST_6ch_modes,
9257 .need_dac_fix = 1,
9258 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009259 ARRAY_SIZE(alc888_2_capture_sources),
9260 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009261 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009262 .setup = alc888_acer_aspire_4930g_setup,
9263 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009264 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009265 [ALC888_ACER_ASPIRE_6530G] = {
9266 .mixers = { alc888_acer_aspire_6530_mixer },
9267 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9268 alc888_acer_aspire_6530g_verbs },
9269 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9270 .dac_nids = alc883_dac_nids,
9271 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9272 .adc_nids = alc883_adc_nids_rev,
9273 .capsrc_nids = alc883_capsrc_nids_rev,
9274 .dig_out_nid = ALC883_DIGOUT_NID,
9275 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9276 .channel_mode = alc883_3ST_2ch_modes,
9277 .num_mux_defs =
9278 ARRAY_SIZE(alc888_2_capture_sources),
9279 .input_mux = alc888_acer_aspire_6530_sources,
9280 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009281 .setup = alc888_acer_aspire_6530g_setup,
9282 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009283 },
Hector Martin3b315d72009-06-02 10:54:19 +02009284 [ALC888_ACER_ASPIRE_8930G] = {
9285 .mixers = { alc888_base_mixer,
9286 alc883_chmode_mixer },
9287 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009288 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009289 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9290 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009291 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9292 .adc_nids = alc889_adc_nids,
9293 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009294 .dig_out_nid = ALC883_DIGOUT_NID,
9295 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9296 .channel_mode = alc883_3ST_6ch_modes,
9297 .need_dac_fix = 1,
9298 .const_channel_count = 6,
9299 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009300 ARRAY_SIZE(alc889_capture_sources),
9301 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009302 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009303 .setup = alc889_acer_aspire_8930g_setup,
9304 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009305 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009306 [ALC888_ACER_ASPIRE_7730G] = {
9307 .mixers = { alc883_3ST_6ch_mixer,
9308 alc883_chmode_mixer },
9309 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9310 alc888_acer_aspire_7730G_verbs },
9311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9312 .dac_nids = alc883_dac_nids,
9313 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9314 .adc_nids = alc883_adc_nids_rev,
9315 .capsrc_nids = alc883_capsrc_nids_rev,
9316 .dig_out_nid = ALC883_DIGOUT_NID,
9317 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9318 .channel_mode = alc883_3ST_6ch_modes,
9319 .need_dac_fix = 1,
9320 .const_channel_count = 6,
9321 .input_mux = &alc883_capture_source,
9322 .unsol_event = alc_automute_amp_unsol_event,
9323 .setup = alc888_acer_aspire_6530g_setup,
9324 .init_hook = alc_automute_amp,
9325 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009326 [ALC883_MEDION] = {
9327 .mixers = { alc883_fivestack_mixer,
9328 alc883_chmode_mixer },
9329 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009330 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009331 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9332 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009333 .adc_nids = alc883_adc_nids_alt,
9334 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009335 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9336 .channel_mode = alc883_sixstack_modes,
9337 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009338 },
Kailang Yang272a5272007-05-14 11:00:38 +02009339 [ALC883_MEDION_MD2] = {
9340 .mixers = { alc883_medion_md2_mixer},
9341 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9342 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9343 .dac_nids = alc883_dac_nids,
9344 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009345 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9346 .channel_mode = alc883_3ST_2ch_modes,
9347 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009348 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009349 .setup = alc883_medion_md2_setup,
9350 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009351 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009352 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009353 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009354 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9355 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9356 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009357 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9358 .channel_mode = alc883_3ST_2ch_modes,
9359 .input_mux = &alc883_capture_source,
9360 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309361 [ALC883_CLEVO_M540R] = {
9362 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9363 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9364 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9365 .dac_nids = alc883_dac_nids,
9366 .dig_out_nid = ALC883_DIGOUT_NID,
9367 .dig_in_nid = ALC883_DIGIN_NID,
9368 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9369 .channel_mode = alc883_3ST_6ch_clevo_modes,
9370 .need_dac_fix = 1,
9371 .input_mux = &alc883_capture_source,
9372 /* This machine has the hardware HP auto-muting, thus
9373 * we need no software mute via unsol event
9374 */
9375 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009376 [ALC883_CLEVO_M720] = {
9377 .mixers = { alc883_clevo_m720_mixer },
9378 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009379 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9380 .dac_nids = alc883_dac_nids,
9381 .dig_out_nid = ALC883_DIGOUT_NID,
9382 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9383 .channel_mode = alc883_3ST_2ch_modes,
9384 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009385 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009386 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009387 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009388 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009389 [ALC883_LENOVO_101E_2ch] = {
9390 .mixers = { alc883_lenovo_101e_2ch_mixer},
9391 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9392 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9393 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009394 .adc_nids = alc883_adc_nids_alt,
9395 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009396 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9397 .channel_mode = alc883_3ST_2ch_modes,
9398 .input_mux = &alc883_lenovo_101e_capture_source,
9399 .unsol_event = alc883_lenovo_101e_unsol_event,
9400 .init_hook = alc883_lenovo_101e_all_automute,
9401 },
Kailang Yang272a5272007-05-14 11:00:38 +02009402 [ALC883_LENOVO_NB0763] = {
9403 .mixers = { alc883_lenovo_nb0763_mixer },
9404 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9405 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9406 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009407 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9408 .channel_mode = alc883_3ST_2ch_modes,
9409 .need_dac_fix = 1,
9410 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009411 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009412 .setup = alc883_medion_md2_setup,
9413 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009414 },
9415 [ALC888_LENOVO_MS7195_DIG] = {
9416 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9417 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9419 .dac_nids = alc883_dac_nids,
9420 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009421 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9422 .channel_mode = alc883_3ST_6ch_modes,
9423 .need_dac_fix = 1,
9424 .input_mux = &alc883_capture_source,
9425 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9426 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009427 },
9428 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009429 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009430 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9431 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9432 .dac_nids = alc883_dac_nids,
9433 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9435 .channel_mode = alc883_3ST_2ch_modes,
9436 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009437 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009438 .setup = alc883_haier_w66_setup,
9439 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009440 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009441 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009442 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009443 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009444 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9445 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009446 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9447 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009448 .need_dac_fix = 1,
9449 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009450 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009451 .setup = alc888_3st_hp_setup,
9452 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009453 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009454 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009455 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009456 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9457 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9458 .dac_nids = alc883_dac_nids,
9459 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009460 .dig_in_nid = ALC883_DIGIN_NID,
9461 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9462 .channel_mode = alc883_sixstack_modes,
9463 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009464 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009465 .setup = alc888_6st_dell_setup,
9466 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009467 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009468 [ALC883_MITAC] = {
9469 .mixers = { alc883_mitac_mixer },
9470 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9471 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9472 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009473 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9474 .channel_mode = alc883_3ST_2ch_modes,
9475 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009476 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009477 .setup = alc883_mitac_setup,
9478 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009479 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009480 [ALC883_FUJITSU_PI2515] = {
9481 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9482 .init_verbs = { alc883_init_verbs,
9483 alc883_2ch_fujitsu_pi2515_verbs},
9484 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9485 .dac_nids = alc883_dac_nids,
9486 .dig_out_nid = ALC883_DIGOUT_NID,
9487 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9488 .channel_mode = alc883_3ST_2ch_modes,
9489 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009490 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009491 .setup = alc883_2ch_fujitsu_pi2515_setup,
9492 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009493 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009494 [ALC888_FUJITSU_XA3530] = {
9495 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9496 .init_verbs = { alc883_init_verbs,
9497 alc888_fujitsu_xa3530_verbs },
9498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9499 .dac_nids = alc883_dac_nids,
9500 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9501 .adc_nids = alc883_adc_nids_rev,
9502 .capsrc_nids = alc883_capsrc_nids_rev,
9503 .dig_out_nid = ALC883_DIGOUT_NID,
9504 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9505 .channel_mode = alc888_4ST_8ch_intel_modes,
9506 .num_mux_defs =
9507 ARRAY_SIZE(alc888_2_capture_sources),
9508 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009509 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009510 .setup = alc888_fujitsu_xa3530_setup,
9511 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009512 },
Kailang Yange2757d52008-08-26 13:17:46 +02009513 [ALC888_LENOVO_SKY] = {
9514 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9515 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9516 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9517 .dac_nids = alc883_dac_nids,
9518 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009519 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9520 .channel_mode = alc883_sixstack_modes,
9521 .need_dac_fix = 1,
9522 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009523 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009524 .setup = alc888_lenovo_sky_setup,
9525 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009526 },
9527 [ALC888_ASUS_M90V] = {
9528 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9529 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9530 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9531 .dac_nids = alc883_dac_nids,
9532 .dig_out_nid = ALC883_DIGOUT_NID,
9533 .dig_in_nid = ALC883_DIGIN_NID,
9534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9535 .channel_mode = alc883_3ST_6ch_modes,
9536 .need_dac_fix = 1,
9537 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009538 .unsol_event = alc_sku_unsol_event,
9539 .setup = alc883_mode2_setup,
9540 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009541 },
9542 [ALC888_ASUS_EEE1601] = {
9543 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009544 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009545 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9547 .dac_nids = alc883_dac_nids,
9548 .dig_out_nid = ALC883_DIGOUT_NID,
9549 .dig_in_nid = ALC883_DIGIN_NID,
9550 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9551 .channel_mode = alc883_3ST_2ch_modes,
9552 .need_dac_fix = 1,
9553 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009554 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009555 .init_hook = alc883_eee1601_inithook,
9556 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009557 [ALC1200_ASUS_P5Q] = {
9558 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9559 .init_verbs = { alc883_init_verbs },
9560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9561 .dac_nids = alc883_dac_nids,
9562 .dig_out_nid = ALC1200_DIGOUT_NID,
9563 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009564 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009565 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9566 .channel_mode = alc883_sixstack_modes,
9567 .input_mux = &alc883_capture_source,
9568 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009569 [ALC889A_MB31] = {
9570 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9571 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9572 alc880_gpio1_init_verbs },
9573 .adc_nids = alc883_adc_nids,
9574 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9575 .dac_nids = alc883_dac_nids,
9576 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9577 .channel_mode = alc889A_mb31_6ch_modes,
9578 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9579 .input_mux = &alc889A_mb31_capture_source,
9580 .dig_out_nid = ALC883_DIGOUT_NID,
9581 .unsol_event = alc889A_mb31_unsol_event,
9582 .init_hook = alc889A_mb31_automute,
9583 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009584 [ALC883_SONY_VAIO_TT] = {
9585 .mixers = { alc883_vaiott_mixer },
9586 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9587 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9588 .dac_nids = alc883_dac_nids,
9589 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9590 .channel_mode = alc883_3ST_2ch_modes,
9591 .input_mux = &alc883_capture_source,
9592 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009593 .setup = alc883_vaiott_setup,
9594 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009595 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009596};
9597
9598
9599/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009600 * Pin config fixes
9601 */
9602enum {
9603 PINFIX_ABIT_AW9D_MAX
9604};
9605
9606static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9607 { 0x15, 0x01080104 }, /* side */
9608 { 0x16, 0x01011012 }, /* rear */
9609 { 0x17, 0x01016011 }, /* clfe */
9610 { }
9611};
9612
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009613static const struct alc_fixup alc882_fixups[] = {
9614 [PINFIX_ABIT_AW9D_MAX] = {
9615 .pins = alc882_abit_aw9d_pinfix
9616 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009617};
9618
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009619static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009620 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9621 {}
9622};
9623
9624/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009625 * BIOS auto configuration
9626 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009627static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9628 const struct auto_pin_cfg *cfg)
9629{
9630 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9631}
9632
Takashi Iwai4953550a2009-06-30 15:28:30 +02009633static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009634 hda_nid_t nid, int pin_type,
9635 int dac_idx)
9636{
9637 /* set as output */
9638 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009639 int idx;
9640
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009641 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009642 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9643 idx = 4;
9644 else
9645 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009646 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9647
9648}
9649
Takashi Iwai4953550a2009-06-30 15:28:30 +02009650static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009651{
9652 struct alc_spec *spec = codec->spec;
9653 int i;
9654
9655 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009656 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009657 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009658 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009659 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009660 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009661 }
9662}
9663
Takashi Iwai4953550a2009-06-30 15:28:30 +02009664static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009665{
9666 struct alc_spec *spec = codec->spec;
9667 hda_nid_t pin;
9668
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009669 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009670 if (pin) /* connect to front */
9671 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009672 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009673 pin = spec->autocfg.speaker_pins[0];
9674 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009675 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009676}
9677
Takashi Iwai4953550a2009-06-30 15:28:30 +02009678static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009679{
9680 struct alc_spec *spec = codec->spec;
9681 int i;
9682
9683 for (i = 0; i < AUTO_PIN_LAST; i++) {
9684 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009685 if (!nid)
9686 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009687 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009688 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9689 snd_hda_codec_write(codec, nid, 0,
9690 AC_VERB_SET_AMP_GAIN_MUTE,
9691 AMP_OUT_MUTE);
9692 }
9693}
9694
9695static void alc882_auto_init_input_src(struct hda_codec *codec)
9696{
9697 struct alc_spec *spec = codec->spec;
9698 int c;
9699
9700 for (c = 0; c < spec->num_adc_nids; c++) {
9701 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9702 hda_nid_t nid = spec->capsrc_nids[c];
9703 unsigned int mux_idx;
9704 const struct hda_input_mux *imux;
9705 int conns, mute, idx, item;
9706
9707 conns = snd_hda_get_connections(codec, nid, conn_list,
9708 ARRAY_SIZE(conn_list));
9709 if (conns < 0)
9710 continue;
9711 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9712 imux = &spec->input_mux[mux_idx];
9713 for (idx = 0; idx < conns; idx++) {
9714 /* if the current connection is the selected one,
9715 * unmute it as default - otherwise mute it
9716 */
9717 mute = AMP_IN_MUTE(idx);
9718 for (item = 0; item < imux->num_items; item++) {
9719 if (imux->items[item].index == idx) {
9720 if (spec->cur_mux[c] == item)
9721 mute = AMP_IN_UNMUTE(idx);
9722 break;
9723 }
9724 }
9725 /* check if we have a selector or mixer
9726 * we could check for the widget type instead, but
9727 * just check for Amp-In presence (in case of mixer
9728 * without amp-in there is something wrong, this
9729 * function shouldn't be used or capsrc nid is wrong)
9730 */
9731 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009732 snd_hda_codec_write(codec, nid, 0,
9733 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009734 mute);
9735 else if (mute != AMP_IN_MUTE(idx))
9736 snd_hda_codec_write(codec, nid, 0,
9737 AC_VERB_SET_CONNECT_SEL,
9738 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009739 }
9740 }
9741}
9742
Takashi Iwai4953550a2009-06-30 15:28:30 +02009743/* add mic boosts if needed */
9744static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009745{
9746 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009747 int err;
9748 hda_nid_t nid;
9749
9750 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9751 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9752 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9753 "Mic Boost",
9754 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9755 if (err < 0)
9756 return err;
9757 }
9758 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9759 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9760 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9761 "Front Mic Boost",
9762 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9763 if (err < 0)
9764 return err;
9765 }
9766 return 0;
9767}
9768
9769/* almost identical with ALC880 parser... */
9770static int alc882_parse_auto_config(struct hda_codec *codec)
9771{
9772 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009773 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9774 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009775
Takashi Iwai05f5f472009-08-25 13:10:18 +02009776 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9777 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009778 if (err < 0)
9779 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009780 if (!spec->autocfg.line_outs)
9781 return 0; /* can't find valid BIOS pin config */
9782
9783 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9784 if (err < 0)
9785 return err;
9786 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9787 if (err < 0)
9788 return err;
9789 err = alc880_auto_create_extra_out(spec,
9790 spec->autocfg.speaker_pins[0],
9791 "Speaker");
9792 if (err < 0)
9793 return err;
9794 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9795 "Headphone");
9796 if (err < 0)
9797 return err;
9798 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9799 if (err < 0)
9800 return err;
9801
9802 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9803
9804 /* check multiple SPDIF-out (for recent codecs) */
9805 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9806 hda_nid_t dig_nid;
9807 err = snd_hda_get_connections(codec,
9808 spec->autocfg.dig_out_pins[i],
9809 &dig_nid, 1);
9810 if (err < 0)
9811 continue;
9812 if (!i)
9813 spec->multiout.dig_out_nid = dig_nid;
9814 else {
9815 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9816 spec->slave_dig_outs[i - 1] = dig_nid;
9817 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9818 break;
9819 }
9820 }
9821 if (spec->autocfg.dig_in_pin)
9822 spec->dig_in_nid = ALC880_DIGIN_NID;
9823
9824 if (spec->kctls.list)
9825 add_mixer(spec, spec->kctls.list);
9826
9827 add_verb(spec, alc883_auto_init_verbs);
9828 /* if ADC 0x07 is available, initialize it, too */
9829 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9830 add_verb(spec, alc882_adc1_init_verbs);
9831
9832 spec->num_mux_defs = 1;
9833 spec->input_mux = &spec->private_imux[0];
9834
9835 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009836
9837 err = alc_auto_add_mic_boost(codec);
9838 if (err < 0)
9839 return err;
9840
Takashi Iwai776e1842007-08-29 15:07:11 +02009841 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009842}
9843
9844/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009845static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009846{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009847 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009848 alc882_auto_init_multi_out(codec);
9849 alc882_auto_init_hp_out(codec);
9850 alc882_auto_init_analog_input(codec);
9851 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009852 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009853 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009854}
9855
Takashi Iwai4953550a2009-06-30 15:28:30 +02009856static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009857{
9858 struct alc_spec *spec;
9859 int err, board_config;
9860
9861 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9862 if (spec == NULL)
9863 return -ENOMEM;
9864
9865 codec->spec = spec;
9866
Takashi Iwai4953550a2009-06-30 15:28:30 +02009867 switch (codec->vendor_id) {
9868 case 0x10ec0882:
9869 case 0x10ec0885:
9870 break;
9871 default:
9872 /* ALC883 and variants */
9873 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9874 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009875 }
9876
Takashi Iwai4953550a2009-06-30 15:28:30 +02009877 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9878 alc882_models,
9879 alc882_cfg_tbl);
9880
9881 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9882 board_config = snd_hda_check_board_codec_sid_config(codec,
9883 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9884
9885 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009886 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009887 codec->chip_name);
9888 board_config = ALC882_AUTO;
9889 }
9890
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009891 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009892
9893 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009894 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009895 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009896 if (err < 0) {
9897 alc_free(codec);
9898 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009899 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009900 printk(KERN_INFO
9901 "hda_codec: Cannot set up configuration "
9902 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009903 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009904 }
9905 }
9906
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009907 err = snd_hda_attach_beep_device(codec, 0x1);
9908 if (err < 0) {
9909 alc_free(codec);
9910 return err;
9911 }
9912
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009914 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009915
Takashi Iwai4953550a2009-06-30 15:28:30 +02009916 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9917 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9918 /* FIXME: setup DAC5 */
9919 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9920 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9921
9922 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9923 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9924
9925 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009926 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009927
9928 if (!spec->adc_nids && spec->input_mux) {
9929 int i;
9930 spec->num_adc_nids = 0;
9931 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9932 hda_nid_t cap;
9933 hda_nid_t nid = alc882_adc_nids[i];
9934 unsigned int wcap = get_wcaps(codec, nid);
9935 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009936 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009937 if (wcap != AC_WID_AUD_IN)
9938 continue;
9939 spec->private_adc_nids[spec->num_adc_nids] = nid;
9940 err = snd_hda_get_connections(codec, nid, &cap, 1);
9941 if (err < 0)
9942 continue;
9943 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9944 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009945 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009946 spec->adc_nids = spec->private_adc_nids;
9947 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009948 }
9949
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009950 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009951 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009952
Takashi Iwai2134ea42008-01-10 16:53:55 +01009953 spec->vmaster_nid = 0x0c;
9954
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009955 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009956 if (board_config == ALC882_AUTO)
9957 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009958#ifdef CONFIG_SND_HDA_POWER_SAVE
9959 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009960 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009961#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009962 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009963
9964 return 0;
9965}
9966
Takashi Iwai4953550a2009-06-30 15:28:30 +02009967
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009968/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009969 * ALC262 support
9970 */
9971
9972#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9973#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9974
9975#define alc262_dac_nids alc260_dac_nids
9976#define alc262_adc_nids alc882_adc_nids
9977#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009978#define alc262_capsrc_nids alc882_capsrc_nids
9979#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009980
9981#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009982#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009983
Kailang Yang4e555fe2008-08-26 13:05:55 +02009984static hda_nid_t alc262_dmic_adc_nids[1] = {
9985 /* ADC0 */
9986 0x09
9987};
9988
9989static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9990
Kailang Yangdf694da2005-12-05 19:42:22 +01009991static struct snd_kcontrol_new alc262_base_mixer[] = {
9992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9993 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9995 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9996 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9997 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010003 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010004 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10006 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10007 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010008 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010009};
10010
Takashi Iwaice875f02008-01-28 18:17:43 +010010011/* update HP, line and mono-out pins according to the master switch */
10012static void alc262_hp_master_update(struct hda_codec *codec)
10013{
10014 struct alc_spec *spec = codec->spec;
10015 int val = spec->master_sw;
10016
10017 /* HP & line-out */
10018 snd_hda_codec_write_cache(codec, 0x1b, 0,
10019 AC_VERB_SET_PIN_WIDGET_CONTROL,
10020 val ? PIN_HP : 0);
10021 snd_hda_codec_write_cache(codec, 0x15, 0,
10022 AC_VERB_SET_PIN_WIDGET_CONTROL,
10023 val ? PIN_HP : 0);
10024 /* mono (speaker) depending on the HP jack sense */
10025 val = val && !spec->jack_present;
10026 snd_hda_codec_write_cache(codec, 0x16, 0,
10027 AC_VERB_SET_PIN_WIDGET_CONTROL,
10028 val ? PIN_OUT : 0);
10029}
10030
10031static void alc262_hp_bpc_automute(struct hda_codec *codec)
10032{
10033 struct alc_spec *spec = codec->spec;
10034 unsigned int presence;
10035 presence = snd_hda_codec_read(codec, 0x1b, 0,
10036 AC_VERB_GET_PIN_SENSE, 0);
10037 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10038 alc262_hp_master_update(codec);
10039}
10040
10041static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10042{
10043 if ((res >> 26) != ALC880_HP_EVENT)
10044 return;
10045 alc262_hp_bpc_automute(codec);
10046}
10047
10048static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10049{
10050 struct alc_spec *spec = codec->spec;
10051 unsigned int presence;
10052 presence = snd_hda_codec_read(codec, 0x15, 0,
10053 AC_VERB_GET_PIN_SENSE, 0);
10054 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10055 alc262_hp_master_update(codec);
10056}
10057
10058static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10059 unsigned int res)
10060{
10061 if ((res >> 26) != ALC880_HP_EVENT)
10062 return;
10063 alc262_hp_wildwest_automute(codec);
10064}
10065
Takashi Iwaib72519b2009-05-08 14:31:55 +020010066#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010067
10068static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10069 struct snd_ctl_elem_value *ucontrol)
10070{
10071 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10072 struct alc_spec *spec = codec->spec;
10073 int val = !!*ucontrol->value.integer.value;
10074
10075 if (val == spec->master_sw)
10076 return 0;
10077 spec->master_sw = val;
10078 alc262_hp_master_update(codec);
10079 return 1;
10080}
10081
Takashi Iwaib72519b2009-05-08 14:31:55 +020010082#define ALC262_HP_MASTER_SWITCH \
10083 { \
10084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10085 .name = "Master Playback Switch", \
10086 .info = snd_ctl_boolean_mono_info, \
10087 .get = alc262_hp_master_sw_get, \
10088 .put = alc262_hp_master_sw_put, \
10089 }
10090
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010091static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010092 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010093 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10094 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010096 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10097 HDA_OUTPUT),
10098 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10099 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010102 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010103 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010105 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010110 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10111 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10112 { } /* end */
10113};
10114
Kailang Yangcd7509a2007-01-26 18:33:17 +010010115static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010116 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10118 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10119 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010121 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10122 HDA_OUTPUT),
10123 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10124 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010125 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010127 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10130 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10131 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010132 { } /* end */
10133};
10134
10135static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10136 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10137 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010138 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010139 { } /* end */
10140};
10141
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010142/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010143static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010144{
10145 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010146
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010147 spec->autocfg.hp_pins[0] = 0x15;
10148 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010149}
10150
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010151static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010152 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10153 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010154 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10155 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10159 { } /* end */
10160};
10161
10162static struct hda_verb alc262_hp_t5735_verbs[] = {
10163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10165
10166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10167 { }
10168};
10169
Kailang Yang8c427222008-01-10 13:03:59 +010010170static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010173 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10174 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10177 { } /* end */
10178};
10179
10180static struct hda_verb alc262_hp_rp5700_verbs[] = {
10181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10182 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10185 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10186 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10191 {}
10192};
10193
10194static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10195 .num_items = 1,
10196 .items = {
10197 { "Line", 0x1 },
10198 },
10199};
10200
Takashi Iwai42171c12009-05-08 14:11:43 +020010201/* bind hp and internal speaker mute (with plug check) as master switch */
10202static void alc262_hippo_master_update(struct hda_codec *codec)
10203{
10204 struct alc_spec *spec = codec->spec;
10205 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10206 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10207 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10208 unsigned int mute;
10209
10210 /* HP */
10211 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10212 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10213 HDA_AMP_MUTE, mute);
10214 /* mute internal speaker per jack sense */
10215 if (spec->jack_present)
10216 mute = HDA_AMP_MUTE;
10217 if (line_nid)
10218 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10219 HDA_AMP_MUTE, mute);
10220 if (speaker_nid && speaker_nid != line_nid)
10221 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10222 HDA_AMP_MUTE, mute);
10223}
10224
10225#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10226
10227static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10228 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010229{
10230 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010231 struct alc_spec *spec = codec->spec;
10232 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010233
Takashi Iwai42171c12009-05-08 14:11:43 +020010234 if (val == spec->master_sw)
10235 return 0;
10236 spec->master_sw = val;
10237 alc262_hippo_master_update(codec);
10238 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010239}
Takashi Iwai5b319542007-07-26 11:49:22 +020010240
Takashi Iwai42171c12009-05-08 14:11:43 +020010241#define ALC262_HIPPO_MASTER_SWITCH \
10242 { \
10243 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10244 .name = "Master Playback Switch", \
10245 .info = snd_ctl_boolean_mono_info, \
10246 .get = alc262_hippo_master_sw_get, \
10247 .put = alc262_hippo_master_sw_put, \
10248 }
10249
10250static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10251 ALC262_HIPPO_MASTER_SWITCH,
10252 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10253 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10254 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10255 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10256 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10259 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10262 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10263 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10264 { } /* end */
10265};
10266
10267static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10268 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10269 ALC262_HIPPO_MASTER_SWITCH,
10270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10275 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10276 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10277 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10278 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10279 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10280 { } /* end */
10281};
10282
10283/* mute/unmute internal speaker according to the hp jack and mute state */
10284static void alc262_hippo_automute(struct hda_codec *codec)
10285{
10286 struct alc_spec *spec = codec->spec;
10287 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10288 unsigned int present;
10289
10290 /* need to execute and sync at first */
10291 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10292 present = snd_hda_codec_read(codec, hp_nid, 0,
10293 AC_VERB_GET_PIN_SENSE, 0);
10294 spec->jack_present = (present & 0x80000000) != 0;
10295 alc262_hippo_master_update(codec);
10296}
10297
10298static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10299{
10300 if ((res >> 26) != ALC880_HP_EVENT)
10301 return;
10302 alc262_hippo_automute(codec);
10303}
10304
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010305static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010306{
10307 struct alc_spec *spec = codec->spec;
10308
10309 spec->autocfg.hp_pins[0] = 0x15;
10310 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010311}
10312
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010313static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010314{
10315 struct alc_spec *spec = codec->spec;
10316
10317 spec->autocfg.hp_pins[0] = 0x1b;
10318 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010319}
10320
10321
Kailang Yang272a5272007-05-14 11:00:38 +020010322static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010323 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010324 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10326 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10327 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10328 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10329 { } /* end */
10330};
10331
Kailang Yang83c34212007-07-05 11:43:05 +020010332static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010333 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10334 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010335 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10338 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10339 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10340 { } /* end */
10341};
Kailang Yang272a5272007-05-14 11:00:38 +020010342
Tony Vroonba340e82009-02-02 19:01:30 +000010343static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10344 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10345 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10346 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10347 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10348 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10349 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10352 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10353 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10354 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10355 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10356 { } /* end */
10357};
10358
10359static struct hda_verb alc262_tyan_verbs[] = {
10360 /* Headphone automute */
10361 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10363 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10364
10365 /* P11 AUX_IN, white 4-pin connector */
10366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10367 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10368 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10369 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10370
10371 {}
10372};
10373
10374/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010375static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010376{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010377 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010378
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010379 spec->autocfg.hp_pins[0] = 0x1b;
10380 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010381}
10382
Tony Vroonba340e82009-02-02 19:01:30 +000010383
Kailang Yangdf694da2005-12-05 19:42:22 +010010384#define alc262_capture_mixer alc882_capture_mixer
10385#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10386
10387/*
10388 * generic initialization of ADC, input mixers and output mixers
10389 */
10390static struct hda_verb alc262_init_verbs[] = {
10391 /*
10392 * Unmute ADC0-2 and set the default input to mic-in
10393 */
10394 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10396 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10398 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10399 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10400
Takashi Iwaicb53c622007-08-10 17:21:45 +020010401 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010402 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010403 * Note: PASD motherboards uses the Line In 2 as the input for
10404 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010405 */
10406 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10411 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010412
10413 /*
10414 * Set up output mixers (0x0c - 0x0e)
10415 */
10416 /* set vol=0 to output mixers */
10417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10418 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10420 /* set up input amps for analog loopback */
10421 /* Amp Indices: DAC = 0, mixer = 1 */
10422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10425 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10426 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10427 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10428
10429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10431 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10433 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10434 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10435
10436 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10437 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10438 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10439 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010441
Kailang Yangdf694da2005-12-05 19:42:22 +010010442 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10443 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010444
Kailang Yangdf694da2005-12-05 19:42:22 +010010445 /* FIXME: use matrix-type input source selection */
10446 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10447 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10452 /* Input mixer2 */
10453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10457 /* Input mixer3 */
10458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010462
10463 { }
10464};
10465
Kailang Yang4e555fe2008-08-26 13:05:55 +020010466static struct hda_verb alc262_eapd_verbs[] = {
10467 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10468 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10469 { }
10470};
10471
Kailang Yangccc656c2006-10-17 12:32:26 +020010472static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10473 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10474 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10475 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10476
10477 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10479 {}
10480};
10481
Kailang Yang272a5272007-05-14 11:00:38 +020010482static struct hda_verb alc262_sony_unsol_verbs[] = {
10483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10486
10487 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010489 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010490};
10491
Kailang Yang4e555fe2008-08-26 13:05:55 +020010492static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10493 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10494 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10497 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010498 { } /* end */
10499};
10500
10501static struct hda_verb alc262_toshiba_s06_verbs[] = {
10502 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10503 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10506 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10508 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10509 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10510 {}
10511};
10512
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010513static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010514{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010515 struct alc_spec *spec = codec->spec;
10516
10517 spec->autocfg.hp_pins[0] = 0x15;
10518 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010519 spec->ext_mic.pin = 0x18;
10520 spec->ext_mic.mux_idx = 0;
10521 spec->int_mic.pin = 0x12;
10522 spec->int_mic.mux_idx = 9;
10523 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010524}
10525
Takashi Iwai834be882006-03-01 14:16:17 +010010526/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010527 * nec model
10528 * 0x15 = headphone
10529 * 0x16 = internal speaker
10530 * 0x18 = external mic
10531 */
10532
10533static struct snd_kcontrol_new alc262_nec_mixer[] = {
10534 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10535 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10536
10537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10538 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10539 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10540
10541 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10542 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10543 { } /* end */
10544};
10545
10546static struct hda_verb alc262_nec_verbs[] = {
10547 /* Unmute Speaker */
10548 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10549
10550 /* Headphone */
10551 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10552 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10553
10554 /* External mic to headphone */
10555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10556 /* External mic to speaker */
10557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10558 {}
10559};
10560
10561/*
Takashi Iwai834be882006-03-01 14:16:17 +010010562 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010563 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10564 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010565 */
10566
10567#define ALC_HP_EVENT 0x37
10568
10569static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10570 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010572 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10573 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010574 {}
10575};
10576
Jiang zhe0e31daf2008-03-20 12:12:39 +010010577static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10578 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10580 {}
10581};
10582
Takashi Iwai834be882006-03-01 14:16:17 +010010583static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010584 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010585 .items = {
10586 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010587 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010588 { "CD", 0x4 },
10589 },
10590};
10591
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010592static struct hda_input_mux alc262_HP_capture_source = {
10593 .num_items = 5,
10594 .items = {
10595 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010596 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010597 { "Line", 0x2 },
10598 { "CD", 0x4 },
10599 { "AUX IN", 0x6 },
10600 },
10601};
10602
zhejiangaccbe492007-08-31 12:36:05 +020010603static struct hda_input_mux alc262_HP_D7000_capture_source = {
10604 .num_items = 4,
10605 .items = {
10606 { "Mic", 0x0 },
10607 { "Front Mic", 0x2 },
10608 { "Line", 0x1 },
10609 { "CD", 0x4 },
10610 },
10611};
10612
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010613/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010614static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10615{
10616 struct alc_spec *spec = codec->spec;
10617 unsigned int mute;
10618
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010619 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010620 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010621 /* need to execute and sync at first */
10622 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010623 /* check laptop HP jack */
10624 present = snd_hda_codec_read(codec, 0x14, 0,
10625 AC_VERB_GET_PIN_SENSE, 0);
10626 /* need to execute and sync at first */
10627 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10628 /* check docking HP jack */
10629 present |= snd_hda_codec_read(codec, 0x1b, 0,
10630 AC_VERB_GET_PIN_SENSE, 0);
10631 if (present & AC_PINSENSE_PRESENCE)
10632 spec->jack_present = 1;
10633 else
10634 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010635 spec->sense_updated = 1;
10636 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010637 /* unmute internal speaker only if both HPs are unplugged and
10638 * master switch is on
10639 */
10640 if (spec->jack_present)
10641 mute = HDA_AMP_MUTE;
10642 else
Takashi Iwai834be882006-03-01 14:16:17 +010010643 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010644 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10645 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010646}
10647
10648/* unsolicited event for HP jack sensing */
10649static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10650 unsigned int res)
10651{
10652 if ((res >> 26) != ALC_HP_EVENT)
10653 return;
10654 alc262_fujitsu_automute(codec, 1);
10655}
10656
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010657static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10658{
10659 alc262_fujitsu_automute(codec, 1);
10660}
10661
Takashi Iwai834be882006-03-01 14:16:17 +010010662/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010663static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10664 .ops = &snd_hda_bind_vol,
10665 .values = {
10666 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10667 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10668 0
10669 },
10670};
Takashi Iwai834be882006-03-01 14:16:17 +010010671
Jiang zhe0e31daf2008-03-20 12:12:39 +010010672/* mute/unmute internal speaker according to the hp jack and mute state */
10673static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10674{
10675 struct alc_spec *spec = codec->spec;
10676 unsigned int mute;
10677
10678 if (force || !spec->sense_updated) {
10679 unsigned int present_int_hp;
10680 /* need to execute and sync at first */
10681 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10682 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10683 AC_VERB_GET_PIN_SENSE, 0);
10684 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10685 spec->sense_updated = 1;
10686 }
10687 if (spec->jack_present) {
10688 /* mute internal speaker */
10689 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10690 HDA_AMP_MUTE, HDA_AMP_MUTE);
10691 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10692 HDA_AMP_MUTE, HDA_AMP_MUTE);
10693 } else {
10694 /* unmute internal speaker if necessary */
10695 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10696 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10697 HDA_AMP_MUTE, mute);
10698 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10699 HDA_AMP_MUTE, mute);
10700 }
10701}
10702
10703/* unsolicited event for HP jack sensing */
10704static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10705 unsigned int res)
10706{
10707 if ((res >> 26) != ALC_HP_EVENT)
10708 return;
10709 alc262_lenovo_3000_automute(codec, 1);
10710}
10711
Takashi Iwai8de56b72009-07-24 16:51:47 +020010712static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10713 int dir, int idx, long *valp)
10714{
10715 int i, change = 0;
10716
10717 for (i = 0; i < 2; i++, valp++)
10718 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10719 HDA_AMP_MUTE,
10720 *valp ? 0 : HDA_AMP_MUTE);
10721 return change;
10722}
10723
Takashi Iwai834be882006-03-01 14:16:17 +010010724/* bind hp and internal speaker mute (with plug check) */
10725static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10726 struct snd_ctl_elem_value *ucontrol)
10727{
10728 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10729 long *valp = ucontrol->value.integer.value;
10730 int change;
10731
Takashi Iwai8de56b72009-07-24 16:51:47 +020010732 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10733 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010734 if (change)
10735 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010736 return change;
10737}
10738
10739static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010740 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010741 {
10742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10743 .name = "Master Playback Switch",
10744 .info = snd_hda_mixer_amp_switch_info,
10745 .get = snd_hda_mixer_amp_switch_get,
10746 .put = alc262_fujitsu_master_sw_put,
10747 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10748 },
10749 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10750 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10751 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010754 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10756 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010757 { } /* end */
10758};
10759
Jiang zhe0e31daf2008-03-20 12:12:39 +010010760/* bind hp and internal speaker mute (with plug check) */
10761static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10762 struct snd_ctl_elem_value *ucontrol)
10763{
10764 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10765 long *valp = ucontrol->value.integer.value;
10766 int change;
10767
Takashi Iwai8de56b72009-07-24 16:51:47 +020010768 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010769 if (change)
10770 alc262_lenovo_3000_automute(codec, 0);
10771 return change;
10772}
10773
10774static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10775 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10776 {
10777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10778 .name = "Master Playback Switch",
10779 .info = snd_hda_mixer_amp_switch_info,
10780 .get = snd_hda_mixer_amp_switch_get,
10781 .put = alc262_lenovo_3000_master_sw_put,
10782 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10783 },
10784 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10785 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10786 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10789 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10790 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10791 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10792 { } /* end */
10793};
10794
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010795static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10796 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010797 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10800 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10801 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10803 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10804 { } /* end */
10805};
10806
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010807/* additional init verbs for Benq laptops */
10808static struct hda_verb alc262_EAPD_verbs[] = {
10809 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10810 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10811 {}
10812};
10813
Kailang Yang83c34212007-07-05 11:43:05 +020010814static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10817
10818 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10819 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10820 {}
10821};
10822
Tobin Davisf651b502007-10-26 12:40:47 +020010823/* Samsung Q1 Ultra Vista model setup */
10824static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010825 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10826 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10828 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10829 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010830 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010831 { } /* end */
10832};
10833
10834static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010835 /* output mixer */
10836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10839 /* speaker */
10840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10843 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10844 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010845 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10848 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10849 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10850 /* internal mic */
10851 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10853 /* ADC, choose mic */
10854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010864 {}
10865};
10866
Tobin Davisf651b502007-10-26 12:40:47 +020010867/* mute/unmute internal speaker according to the hp jack and mute state */
10868static void alc262_ultra_automute(struct hda_codec *codec)
10869{
10870 struct alc_spec *spec = codec->spec;
10871 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010872
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010873 mute = 0;
10874 /* auto-mute only when HP is used as HP */
10875 if (!spec->cur_mux[0]) {
10876 unsigned int present;
10877 /* need to execute and sync at first */
10878 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10879 present = snd_hda_codec_read(codec, 0x15, 0,
10880 AC_VERB_GET_PIN_SENSE, 0);
10881 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10882 if (spec->jack_present)
10883 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010884 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010885 /* mute/unmute internal speaker */
10886 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10887 HDA_AMP_MUTE, mute);
10888 /* mute/unmute HP */
10889 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10890 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010891}
10892
10893/* unsolicited event for HP jack sensing */
10894static void alc262_ultra_unsol_event(struct hda_codec *codec,
10895 unsigned int res)
10896{
10897 if ((res >> 26) != ALC880_HP_EVENT)
10898 return;
10899 alc262_ultra_automute(codec);
10900}
10901
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010902static struct hda_input_mux alc262_ultra_capture_source = {
10903 .num_items = 2,
10904 .items = {
10905 { "Mic", 0x1 },
10906 { "Headphone", 0x7 },
10907 },
10908};
10909
10910static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10911 struct snd_ctl_elem_value *ucontrol)
10912{
10913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10914 struct alc_spec *spec = codec->spec;
10915 int ret;
10916
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010917 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010918 if (!ret)
10919 return 0;
10920 /* reprogram the HP pin as mic or HP according to the input source */
10921 snd_hda_codec_write_cache(codec, 0x15, 0,
10922 AC_VERB_SET_PIN_WIDGET_CONTROL,
10923 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10924 alc262_ultra_automute(codec); /* mute/unmute HP */
10925 return ret;
10926}
10927
10928static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10929 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10930 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10931 {
10932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10933 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010934 .info = alc_mux_enum_info,
10935 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010936 .put = alc262_ultra_mux_enum_put,
10937 },
10938 { } /* end */
10939};
10940
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010941/* We use two mixers depending on the output pin; 0x16 is a mono output
10942 * and thus it's bound with a different mixer.
10943 * This function returns which mixer amp should be used.
10944 */
10945static int alc262_check_volbit(hda_nid_t nid)
10946{
10947 if (!nid)
10948 return 0;
10949 else if (nid == 0x16)
10950 return 2;
10951 else
10952 return 1;
10953}
10954
10955static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10956 const char *pfx, int *vbits)
10957{
10958 char name[32];
10959 unsigned long val;
10960 int vbit;
10961
10962 vbit = alc262_check_volbit(nid);
10963 if (!vbit)
10964 return 0;
10965 if (*vbits & vbit) /* a volume control for this mixer already there */
10966 return 0;
10967 *vbits |= vbit;
10968 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10969 if (vbit == 2)
10970 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10971 else
10972 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10973 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10974}
10975
10976static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10977 const char *pfx)
10978{
10979 char name[32];
10980 unsigned long val;
10981
10982 if (!nid)
10983 return 0;
10984 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10985 if (nid == 0x16)
10986 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10987 else
10988 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10989 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10990}
10991
Kailang Yangdf694da2005-12-05 19:42:22 +010010992/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010993static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10994 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010995{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010996 const char *pfx;
10997 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010010998 int err;
10999
11000 spec->multiout.num_dacs = 1; /* only use one dac */
11001 spec->multiout.dac_nids = spec->private_dac_nids;
11002 spec->multiout.dac_nids[0] = 2;
11003
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011004 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11005 pfx = "Master";
11006 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11007 pfx = "Speaker";
11008 else
11009 pfx = "Front";
11010 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11011 if (err < 0)
11012 return err;
11013 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11014 if (err < 0)
11015 return err;
11016 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11017 if (err < 0)
11018 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011019
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011020 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11021 alc262_check_volbit(cfg->speaker_pins[0]) |
11022 alc262_check_volbit(cfg->hp_pins[0]);
11023 if (vbits == 1 || vbits == 2)
11024 pfx = "Master"; /* only one mixer is used */
11025 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11026 pfx = "Speaker";
11027 else
11028 pfx = "Front";
11029 vbits = 0;
11030 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11031 if (err < 0)
11032 return err;
11033 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11034 &vbits);
11035 if (err < 0)
11036 return err;
11037 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11038 &vbits);
11039 if (err < 0)
11040 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011041 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011042}
11043
Takashi Iwai05f5f472009-08-25 13:10:18 +020011044#define alc262_auto_create_input_ctls \
11045 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011046
11047/*
11048 * generic initialization of ADC, input mixers and output mixers
11049 */
11050static struct hda_verb alc262_volume_init_verbs[] = {
11051 /*
11052 * Unmute ADC0-2 and set the default input to mic-in
11053 */
11054 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11056 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11057 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11058 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11060
Takashi Iwaicb53c622007-08-10 17:21:45 +020011061 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011062 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011063 * Note: PASD motherboards uses the Line In 2 as the input for
11064 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011065 */
11066 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011072
11073 /*
11074 * Set up output mixers (0x0c - 0x0f)
11075 */
11076 /* set vol=0 to output mixers */
11077 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011080
Kailang Yangdf694da2005-12-05 19:42:22 +010011081 /* set up input amps for analog loopback */
11082 /* Amp Indices: DAC = 0, mixer = 1 */
11083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11085 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11086 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11087 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11089
11090 /* FIXME: use matrix-type input source selection */
11091 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11092 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11093 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11097 /* Input mixer2 */
11098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11102 /* Input mixer3 */
11103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11107
11108 { }
11109};
11110
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011111static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11112 /*
11113 * Unmute ADC0-2 and set the default input to mic-in
11114 */
11115 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11117 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11119 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11121
Takashi Iwaicb53c622007-08-10 17:21:45 +020011122 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011123 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011124 * Note: PASD motherboards uses the Line In 2 as the input for
11125 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011126 */
11127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011135
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011136 /*
11137 * Set up output mixers (0x0c - 0x0e)
11138 */
11139 /* set vol=0 to output mixers */
11140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11142 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11143
11144 /* set up input amps for analog loopback */
11145 /* Amp Indices: DAC = 0, mixer = 1 */
11146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11148 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11150 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11151 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11152
Takashi Iwaice875f02008-01-28 18:17:43 +010011153 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11155 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11156
11157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11159
11160 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11162
11163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11164 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11165 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11167 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11168
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011169 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011170 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11171 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011173 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11174 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11175
11176
11177 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011178 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11179 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11184 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11186 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011189 /* Input mixer2 */
11190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11195 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011199 /* Input mixer3 */
11200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011209
Takashi Iwaice875f02008-01-28 18:17:43 +010011210 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11211
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011212 { }
11213};
11214
Kailang Yangcd7509a2007-01-26 18:33:17 +010011215static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11216 /*
11217 * Unmute ADC0-2 and set the default input to mic-in
11218 */
11219 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11221 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11223 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11225
Takashi Iwaicb53c622007-08-10 17:21:45 +020011226 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011227 * mixer widget
11228 * Note: PASD motherboards uses the Line In 2 as the input for front
11229 * panel mic (mic 2)
11230 */
11231 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011240 /*
11241 * Set up output mixers (0x0c - 0x0e)
11242 */
11243 /* set vol=0 to output mixers */
11244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11246 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11247
11248 /* set up input amps for analog loopback */
11249 /* Amp Indices: DAC = 0, mixer = 1 */
11250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11252 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11253 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11254 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11256
11257
11258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11259 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11260 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11261 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11262 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11264 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11265
11266 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11268
11269 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11271
11272 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11273 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11274 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11276 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11277 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11278
11279 /* FIXME: use matrix-type input source selection */
11280 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11281 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11287 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11289 /* Input mixer2 */
11290 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11295 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11297 /* Input mixer3 */
11298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11303 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11305
Takashi Iwaice875f02008-01-28 18:17:43 +010011306 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11307
Kailang Yangcd7509a2007-01-26 18:33:17 +010011308 { }
11309};
11310
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011311static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11312
11313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11315 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11316
11317 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11318 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11320 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11321
11322 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11323 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11325 {}
11326};
11327
11328
Takashi Iwaicb53c622007-08-10 17:21:45 +020011329#ifdef CONFIG_SND_HDA_POWER_SAVE
11330#define alc262_loopbacks alc880_loopbacks
11331#endif
11332
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011333/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011334#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11335#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11336#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11337#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11338
11339/*
11340 * BIOS auto configuration
11341 */
11342static int alc262_parse_auto_config(struct hda_codec *codec)
11343{
11344 struct alc_spec *spec = codec->spec;
11345 int err;
11346 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11347
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011348 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11349 alc262_ignore);
11350 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011351 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011352 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011353 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011354 spec->multiout.max_channels = 2;
11355 spec->no_analog = 1;
11356 goto dig_only;
11357 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011358 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011359 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011360 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11361 if (err < 0)
11362 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011363 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011364 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011365 return err;
11366
11367 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11368
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011369 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011370 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011371 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011372 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011373 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011374 if (spec->autocfg.dig_in_pin)
11375 spec->dig_in_nid = ALC262_DIGIN_NID;
11376
Takashi Iwai603c4012008-07-30 15:01:44 +020011377 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011378 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011379
Takashi Iwaid88897e2008-10-31 15:01:37 +010011380 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011381 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011382 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011383
Takashi Iwai776e1842007-08-29 15:07:11 +020011384 err = alc_auto_add_mic_boost(codec);
11385 if (err < 0)
11386 return err;
11387
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011388 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11389
Kailang Yangdf694da2005-12-05 19:42:22 +010011390 return 1;
11391}
11392
11393#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11394#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11395#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011396#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011397
11398
11399/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011400static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011401{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011402 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011403 alc262_auto_init_multi_out(codec);
11404 alc262_auto_init_hp_out(codec);
11405 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011406 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011407 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011408 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011409}
11410
11411/*
11412 * configuration and preset
11413 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011414static const char *alc262_models[ALC262_MODEL_LAST] = {
11415 [ALC262_BASIC] = "basic",
11416 [ALC262_HIPPO] = "hippo",
11417 [ALC262_HIPPO_1] = "hippo_1",
11418 [ALC262_FUJITSU] = "fujitsu",
11419 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011420 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011421 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011422 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011423 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011424 [ALC262_BENQ_T31] = "benq-t31",
11425 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011426 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011427 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011428 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011429 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011430 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011431 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011432 [ALC262_AUTO] = "auto",
11433};
11434
11435static struct snd_pci_quirk alc262_cfg_tbl[] = {
11436 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011437 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011438 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11439 ALC262_HP_BPC),
11440 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11441 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011442 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11443 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011444 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011445 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011446 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011447 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011448 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011449 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011450 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011451 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011452 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11453 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11454 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011455 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11456 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011457 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011458 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011459 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011460 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011461 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011462 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011463 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11464 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011465 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011466 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011467 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011468 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011469 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011470 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011471 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11472 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011473 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011474 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011475 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011476 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011477 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011478 {}
11479};
11480
11481static struct alc_config_preset alc262_presets[] = {
11482 [ALC262_BASIC] = {
11483 .mixers = { alc262_base_mixer },
11484 .init_verbs = { alc262_init_verbs },
11485 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11486 .dac_nids = alc262_dac_nids,
11487 .hp_nid = 0x03,
11488 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11489 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011490 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011491 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011492 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011493 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011494 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011495 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11496 .dac_nids = alc262_dac_nids,
11497 .hp_nid = 0x03,
11498 .dig_out_nid = ALC262_DIGOUT_NID,
11499 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11500 .channel_mode = alc262_modes,
11501 .input_mux = &alc262_capture_source,
11502 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011503 .setup = alc262_hippo_setup,
11504 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011505 },
11506 [ALC262_HIPPO_1] = {
11507 .mixers = { alc262_hippo1_mixer },
11508 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11509 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11510 .dac_nids = alc262_dac_nids,
11511 .hp_nid = 0x02,
11512 .dig_out_nid = ALC262_DIGOUT_NID,
11513 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11514 .channel_mode = alc262_modes,
11515 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011516 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011517 .setup = alc262_hippo1_setup,
11518 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011519 },
Takashi Iwai834be882006-03-01 14:16:17 +010011520 [ALC262_FUJITSU] = {
11521 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011522 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11523 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011524 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11525 .dac_nids = alc262_dac_nids,
11526 .hp_nid = 0x03,
11527 .dig_out_nid = ALC262_DIGOUT_NID,
11528 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11529 .channel_mode = alc262_modes,
11530 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011531 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011532 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011533 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011534 [ALC262_HP_BPC] = {
11535 .mixers = { alc262_HP_BPC_mixer },
11536 .init_verbs = { alc262_HP_BPC_init_verbs },
11537 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11538 .dac_nids = alc262_dac_nids,
11539 .hp_nid = 0x03,
11540 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11541 .channel_mode = alc262_modes,
11542 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011543 .unsol_event = alc262_hp_bpc_unsol_event,
11544 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011545 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011546 [ALC262_HP_BPC_D7000_WF] = {
11547 .mixers = { alc262_HP_BPC_WildWest_mixer },
11548 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11549 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11550 .dac_nids = alc262_dac_nids,
11551 .hp_nid = 0x03,
11552 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11553 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011554 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011555 .unsol_event = alc262_hp_wildwest_unsol_event,
11556 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011557 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011558 [ALC262_HP_BPC_D7000_WL] = {
11559 .mixers = { alc262_HP_BPC_WildWest_mixer,
11560 alc262_HP_BPC_WildWest_option_mixer },
11561 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11562 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11563 .dac_nids = alc262_dac_nids,
11564 .hp_nid = 0x03,
11565 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11566 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011567 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011568 .unsol_event = alc262_hp_wildwest_unsol_event,
11569 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011570 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011571 [ALC262_HP_TC_T5735] = {
11572 .mixers = { alc262_hp_t5735_mixer },
11573 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11574 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11575 .dac_nids = alc262_dac_nids,
11576 .hp_nid = 0x03,
11577 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11578 .channel_mode = alc262_modes,
11579 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011580 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011581 .setup = alc262_hp_t5735_setup,
11582 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011583 },
11584 [ALC262_HP_RP5700] = {
11585 .mixers = { alc262_hp_rp5700_mixer },
11586 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11587 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11588 .dac_nids = alc262_dac_nids,
11589 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11590 .channel_mode = alc262_modes,
11591 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011592 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011593 [ALC262_BENQ_ED8] = {
11594 .mixers = { alc262_base_mixer },
11595 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11596 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11597 .dac_nids = alc262_dac_nids,
11598 .hp_nid = 0x03,
11599 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11600 .channel_mode = alc262_modes,
11601 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011602 },
Kailang Yang272a5272007-05-14 11:00:38 +020011603 [ALC262_SONY_ASSAMD] = {
11604 .mixers = { alc262_sony_mixer },
11605 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11606 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11607 .dac_nids = alc262_dac_nids,
11608 .hp_nid = 0x02,
11609 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11610 .channel_mode = alc262_modes,
11611 .input_mux = &alc262_capture_source,
11612 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011613 .setup = alc262_hippo_setup,
11614 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011615 },
11616 [ALC262_BENQ_T31] = {
11617 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011618 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11619 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011620 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11621 .dac_nids = alc262_dac_nids,
11622 .hp_nid = 0x03,
11623 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11624 .channel_mode = alc262_modes,
11625 .input_mux = &alc262_capture_source,
11626 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011627 .setup = alc262_hippo_setup,
11628 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011629 },
Tobin Davisf651b502007-10-26 12:40:47 +020011630 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011631 .mixers = { alc262_ultra_mixer },
11632 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011633 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011634 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11635 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011636 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11637 .channel_mode = alc262_modes,
11638 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011639 .adc_nids = alc262_adc_nids, /* ADC0 */
11640 .capsrc_nids = alc262_capsrc_nids,
11641 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011642 .unsol_event = alc262_ultra_unsol_event,
11643 .init_hook = alc262_ultra_automute,
11644 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011645 [ALC262_LENOVO_3000] = {
11646 .mixers = { alc262_lenovo_3000_mixer },
11647 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11648 alc262_lenovo_3000_unsol_verbs },
11649 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11650 .dac_nids = alc262_dac_nids,
11651 .hp_nid = 0x03,
11652 .dig_out_nid = ALC262_DIGOUT_NID,
11653 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11654 .channel_mode = alc262_modes,
11655 .input_mux = &alc262_fujitsu_capture_source,
11656 .unsol_event = alc262_lenovo_3000_unsol_event,
11657 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011658 [ALC262_NEC] = {
11659 .mixers = { alc262_nec_mixer },
11660 .init_verbs = { alc262_nec_verbs },
11661 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11662 .dac_nids = alc262_dac_nids,
11663 .hp_nid = 0x03,
11664 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11665 .channel_mode = alc262_modes,
11666 .input_mux = &alc262_capture_source,
11667 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011668 [ALC262_TOSHIBA_S06] = {
11669 .mixers = { alc262_toshiba_s06_mixer },
11670 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11671 alc262_eapd_verbs },
11672 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11673 .capsrc_nids = alc262_dmic_capsrc_nids,
11674 .dac_nids = alc262_dac_nids,
11675 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011676 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011677 .dig_out_nid = ALC262_DIGOUT_NID,
11678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11679 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011680 .unsol_event = alc_sku_unsol_event,
11681 .setup = alc262_toshiba_s06_setup,
11682 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011683 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011684 [ALC262_TOSHIBA_RX1] = {
11685 .mixers = { alc262_toshiba_rx1_mixer },
11686 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11687 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11688 .dac_nids = alc262_dac_nids,
11689 .hp_nid = 0x03,
11690 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11691 .channel_mode = alc262_modes,
11692 .input_mux = &alc262_capture_source,
11693 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011694 .setup = alc262_hippo_setup,
11695 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011696 },
Tony Vroonba340e82009-02-02 19:01:30 +000011697 [ALC262_TYAN] = {
11698 .mixers = { alc262_tyan_mixer },
11699 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11700 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11701 .dac_nids = alc262_dac_nids,
11702 .hp_nid = 0x02,
11703 .dig_out_nid = ALC262_DIGOUT_NID,
11704 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11705 .channel_mode = alc262_modes,
11706 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011707 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011708 .setup = alc262_tyan_setup,
11709 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011710 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011711};
11712
11713static int patch_alc262(struct hda_codec *codec)
11714{
11715 struct alc_spec *spec;
11716 int board_config;
11717 int err;
11718
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011719 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011720 if (spec == NULL)
11721 return -ENOMEM;
11722
11723 codec->spec = spec;
11724#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011725 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11726 * under-run
11727 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011728 {
11729 int tmp;
11730 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11731 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11732 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11733 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11734 }
11735#endif
11736
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011737 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11738
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011739 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11740 alc262_models,
11741 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011742
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011743 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011744 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11745 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011746 board_config = ALC262_AUTO;
11747 }
11748
11749 if (board_config == ALC262_AUTO) {
11750 /* automatic parse from the BIOS config */
11751 err = alc262_parse_auto_config(codec);
11752 if (err < 0) {
11753 alc_free(codec);
11754 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011755 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011756 printk(KERN_INFO
11757 "hda_codec: Cannot set up configuration "
11758 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011759 board_config = ALC262_BASIC;
11760 }
11761 }
11762
Takashi Iwai07eba612009-02-19 08:06:35 +010011763 if (!spec->no_analog) {
11764 err = snd_hda_attach_beep_device(codec, 0x1);
11765 if (err < 0) {
11766 alc_free(codec);
11767 return err;
11768 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011769 }
11770
Kailang Yangdf694da2005-12-05 19:42:22 +010011771 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011772 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011773
Kailang Yangdf694da2005-12-05 19:42:22 +010011774 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11775 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011776
Kailang Yangdf694da2005-12-05 19:42:22 +010011777 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11778 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11779
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011780 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011781 int i;
11782 /* check whether the digital-mic has to be supported */
11783 for (i = 0; i < spec->input_mux->num_items; i++) {
11784 if (spec->input_mux->items[i].index >= 9)
11785 break;
11786 }
11787 if (i < spec->input_mux->num_items) {
11788 /* use only ADC0 */
11789 spec->adc_nids = alc262_dmic_adc_nids;
11790 spec->num_adc_nids = 1;
11791 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011792 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011793 /* all analog inputs */
11794 /* check whether NID 0x07 is valid */
11795 unsigned int wcap = get_wcaps(codec, 0x07);
11796
11797 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011798 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011799 if (wcap != AC_WID_AUD_IN) {
11800 spec->adc_nids = alc262_adc_nids_alt;
11801 spec->num_adc_nids =
11802 ARRAY_SIZE(alc262_adc_nids_alt);
11803 spec->capsrc_nids = alc262_capsrc_nids_alt;
11804 } else {
11805 spec->adc_nids = alc262_adc_nids;
11806 spec->num_adc_nids =
11807 ARRAY_SIZE(alc262_adc_nids);
11808 spec->capsrc_nids = alc262_capsrc_nids;
11809 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011810 }
11811 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011812 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011813 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011814 if (!spec->no_analog)
11815 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011816
Takashi Iwai2134ea42008-01-10 16:53:55 +010011817 spec->vmaster_nid = 0x0c;
11818
Kailang Yangdf694da2005-12-05 19:42:22 +010011819 codec->patch_ops = alc_patch_ops;
11820 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011821 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011822#ifdef CONFIG_SND_HDA_POWER_SAVE
11823 if (!spec->loopback.amplist)
11824 spec->loopback.amplist = alc262_loopbacks;
11825#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011826 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011827
Kailang Yangdf694da2005-12-05 19:42:22 +010011828 return 0;
11829}
11830
Kailang Yangdf694da2005-12-05 19:42:22 +010011831/*
Kailang Yanga361d842007-06-05 12:30:55 +020011832 * ALC268 channel source setting (2 channel)
11833 */
11834#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11835#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011836
Kailang Yanga361d842007-06-05 12:30:55 +020011837static hda_nid_t alc268_dac_nids[2] = {
11838 /* front, hp */
11839 0x02, 0x03
11840};
11841
11842static hda_nid_t alc268_adc_nids[2] = {
11843 /* ADC0-1 */
11844 0x08, 0x07
11845};
11846
11847static hda_nid_t alc268_adc_nids_alt[1] = {
11848 /* ADC0 */
11849 0x08
11850};
11851
Takashi Iwaie1406342008-02-11 18:32:32 +010011852static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11853
Kailang Yanga361d842007-06-05 12:30:55 +020011854static struct snd_kcontrol_new alc268_base_mixer[] = {
11855 /* output mixer control */
11856 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11857 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011860 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11861 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11862 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011863 { }
11864};
11865
Takashi Iwai42171c12009-05-08 14:11:43 +020011866static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11867 /* output mixer control */
11868 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11869 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11870 ALC262_HIPPO_MASTER_SWITCH,
11871 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11872 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11873 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11874 { }
11875};
11876
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011877/* bind Beep switches of both NID 0x0f and 0x10 */
11878static struct hda_bind_ctls alc268_bind_beep_sw = {
11879 .ops = &snd_hda_bind_sw,
11880 .values = {
11881 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11882 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11883 0
11884 },
11885};
11886
11887static struct snd_kcontrol_new alc268_beep_mixer[] = {
11888 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11889 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11890 { }
11891};
11892
Kailang Yangd1a991a2007-08-15 16:21:59 +020011893static struct hda_verb alc268_eapd_verbs[] = {
11894 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11895 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11896 { }
11897};
11898
Takashi Iwaid2738092007-08-16 14:59:45 +020011899/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011900static struct hda_verb alc268_toshiba_verbs[] = {
11901 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11902 { } /* end */
11903};
11904
11905/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011906/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011907static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11908 .ops = &snd_hda_bind_vol,
11909 .values = {
11910 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11911 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11912 0
11913 },
11914};
11915
Takashi Iwai889c4392007-08-23 18:56:52 +020011916/* mute/unmute internal speaker according to the hp jack and mute state */
11917static void alc268_acer_automute(struct hda_codec *codec, int force)
11918{
11919 struct alc_spec *spec = codec->spec;
11920 unsigned int mute;
11921
11922 if (force || !spec->sense_updated) {
11923 unsigned int present;
11924 present = snd_hda_codec_read(codec, 0x14, 0,
11925 AC_VERB_GET_PIN_SENSE, 0);
11926 spec->jack_present = (present & 0x80000000) != 0;
11927 spec->sense_updated = 1;
11928 }
11929 if (spec->jack_present)
11930 mute = HDA_AMP_MUTE; /* mute internal speaker */
11931 else /* unmute internal speaker if necessary */
11932 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11933 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11934 HDA_AMP_MUTE, mute);
11935}
11936
11937
11938/* bind hp and internal speaker mute (with plug check) */
11939static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11940 struct snd_ctl_elem_value *ucontrol)
11941{
11942 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11943 long *valp = ucontrol->value.integer.value;
11944 int change;
11945
Takashi Iwai8de56b72009-07-24 16:51:47 +020011946 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011947 if (change)
11948 alc268_acer_automute(codec, 0);
11949 return change;
11950}
Takashi Iwaid2738092007-08-16 14:59:45 +020011951
Kailang Yang8ef355d2008-08-26 13:10:22 +020011952static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11953 /* output mixer control */
11954 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11955 {
11956 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11957 .name = "Master Playback Switch",
11958 .info = snd_hda_mixer_amp_switch_info,
11959 .get = snd_hda_mixer_amp_switch_get,
11960 .put = alc268_acer_master_sw_put,
11961 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11962 },
11963 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11964 { }
11965};
11966
Takashi Iwaid2738092007-08-16 14:59:45 +020011967static struct snd_kcontrol_new alc268_acer_mixer[] = {
11968 /* output mixer control */
11969 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11970 {
11971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11972 .name = "Master Playback Switch",
11973 .info = snd_hda_mixer_amp_switch_info,
11974 .get = snd_hda_mixer_amp_switch_get,
11975 .put = alc268_acer_master_sw_put,
11976 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11977 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011978 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11979 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11980 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011981 { }
11982};
11983
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011984static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11985 /* output mixer control */
11986 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11987 {
11988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11989 .name = "Master Playback Switch",
11990 .info = snd_hda_mixer_amp_switch_info,
11991 .get = snd_hda_mixer_amp_switch_get,
11992 .put = alc268_acer_master_sw_put,
11993 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11994 },
11995 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11996 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11997 { }
11998};
11999
Kailang Yang8ef355d2008-08-26 13:10:22 +020012000static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12001 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12004 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12005 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12007 { }
12008};
12009
Takashi Iwaid2738092007-08-16 14:59:45 +020012010static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012011 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12012 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12014 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012015 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12016 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012017 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12018 { }
12019};
12020
12021/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012022#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012023#define alc268_toshiba_setup alc262_hippo_setup
12024#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012025
12026static void alc268_acer_unsol_event(struct hda_codec *codec,
12027 unsigned int res)
12028{
Takashi Iwai889c4392007-08-23 18:56:52 +020012029 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012030 return;
12031 alc268_acer_automute(codec, 1);
12032}
12033
Takashi Iwai889c4392007-08-23 18:56:52 +020012034static void alc268_acer_init_hook(struct hda_codec *codec)
12035{
12036 alc268_acer_automute(codec, 1);
12037}
12038
Kailang Yang8ef355d2008-08-26 13:10:22 +020012039/* toggle speaker-output according to the hp-jack state */
12040static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12041{
12042 unsigned int present;
12043 unsigned char bits;
12044
12045 present = snd_hda_codec_read(codec, 0x15, 0,
12046 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12047 bits = present ? AMP_IN_MUTE(0) : 0;
12048 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12049 AMP_IN_MUTE(0), bits);
12050 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12051 AMP_IN_MUTE(0), bits);
12052}
12053
Kailang Yang8ef355d2008-08-26 13:10:22 +020012054static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12055 unsigned int res)
12056{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012057 switch (res >> 26) {
12058 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012059 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012060 break;
12061 case ALC880_MIC_EVENT:
12062 alc_mic_automute(codec);
12063 break;
12064 }
12065}
12066
12067static void alc268_acer_lc_setup(struct hda_codec *codec)
12068{
12069 struct alc_spec *spec = codec->spec;
12070 spec->ext_mic.pin = 0x18;
12071 spec->ext_mic.mux_idx = 0;
12072 spec->int_mic.pin = 0x12;
12073 spec->int_mic.mux_idx = 6;
12074 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012075}
12076
12077static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12078{
12079 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012080 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012081}
12082
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012083static struct snd_kcontrol_new alc268_dell_mixer[] = {
12084 /* output mixer control */
12085 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12086 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12087 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12089 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12090 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12091 { }
12092};
12093
12094static struct hda_verb alc268_dell_verbs[] = {
12095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12097 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012098 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012099 { }
12100};
12101
12102/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012103static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012104{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012105 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012106
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012107 spec->autocfg.hp_pins[0] = 0x15;
12108 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012109 spec->ext_mic.pin = 0x18;
12110 spec->ext_mic.mux_idx = 0;
12111 spec->int_mic.pin = 0x19;
12112 spec->int_mic.mux_idx = 1;
12113 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012114}
12115
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012116static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12117 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12118 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12119 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12121 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12122 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12123 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12124 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12125 { }
12126};
12127
12128static struct hda_verb alc267_quanta_il1_verbs[] = {
12129 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12130 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12131 { }
12132};
12133
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012134static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012135{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012136 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012137 spec->autocfg.hp_pins[0] = 0x15;
12138 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012139 spec->ext_mic.pin = 0x18;
12140 spec->ext_mic.mux_idx = 0;
12141 spec->int_mic.pin = 0x19;
12142 spec->int_mic.mux_idx = 1;
12143 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012144}
12145
Kailang Yanga361d842007-06-05 12:30:55 +020012146/*
12147 * generic initialization of ADC, input mixers and output mixers
12148 */
12149static struct hda_verb alc268_base_init_verbs[] = {
12150 /* Unmute DAC0-1 and set vol = 0 */
12151 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012152 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012153
12154 /*
12155 * Set up output mixers (0x0c - 0x0e)
12156 */
12157 /* set vol=0 to output mixers */
12158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012159 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12160
12161 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12162 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12163
12164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12166 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12167 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12170 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12171 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12172
12173 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12175 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012178
12179 /* set PCBEEP vol = 0, mute connections */
12180 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12181 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12182 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012183
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012184 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012185
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012186 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12188 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012190
Kailang Yanga361d842007-06-05 12:30:55 +020012191 { }
12192};
12193
12194/*
12195 * generic initialization of ADC, input mixers and output mixers
12196 */
12197static struct hda_verb alc268_volume_init_verbs[] = {
12198 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012199 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12200 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012201
12202 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12203 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12204 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12205 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12206 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12207
Kailang Yanga361d842007-06-05 12:30:55 +020012208 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012209 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12210 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12211
12212 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012213 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012214
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012215 /* set PCBEEP vol = 0, mute connections */
12216 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12217 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12218 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012219
12220 { }
12221};
12222
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012223static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12224 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12225 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12226 { } /* end */
12227};
12228
Kailang Yanga361d842007-06-05 12:30:55 +020012229static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12230 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12231 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012232 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012233 { } /* end */
12234};
12235
12236static struct snd_kcontrol_new alc268_capture_mixer[] = {
12237 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12238 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12239 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12240 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012241 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012242 { } /* end */
12243};
12244
12245static struct hda_input_mux alc268_capture_source = {
12246 .num_items = 4,
12247 .items = {
12248 { "Mic", 0x0 },
12249 { "Front Mic", 0x1 },
12250 { "Line", 0x2 },
12251 { "CD", 0x3 },
12252 },
12253};
12254
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012255static struct hda_input_mux alc268_acer_capture_source = {
12256 .num_items = 3,
12257 .items = {
12258 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012259 { "Internal Mic", 0x1 },
12260 { "Line", 0x2 },
12261 },
12262};
12263
12264static struct hda_input_mux alc268_acer_dmic_capture_source = {
12265 .num_items = 3,
12266 .items = {
12267 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012268 { "Internal Mic", 0x6 },
12269 { "Line", 0x2 },
12270 },
12271};
12272
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012273#ifdef CONFIG_SND_DEBUG
12274static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012275 /* Volume widgets */
12276 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12277 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12278 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12279 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12280 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12281 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12282 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12283 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12284 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12285 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12286 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12287 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12288 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012289 /* The below appears problematic on some hardwares */
12290 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012291 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12292 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12293 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12294 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12295
12296 /* Modes for retasking pin widgets */
12297 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12298 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12299 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12300 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12301
12302 /* Controls for GPIO pins, assuming they are configured as outputs */
12303 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12304 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12305 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12306 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12307
12308 /* Switches to allow the digital SPDIF output pin to be enabled.
12309 * The ALC268 does not have an SPDIF input.
12310 */
12311 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12312
12313 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12314 * this output to turn on an external amplifier.
12315 */
12316 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12317 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12318
12319 { } /* end */
12320};
12321#endif
12322
Kailang Yanga361d842007-06-05 12:30:55 +020012323/* create input playback/capture controls for the given pin */
12324static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12325 const char *ctlname, int idx)
12326{
12327 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012328 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012329 int err;
12330
12331 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012332 switch (nid) {
12333 case 0x14:
12334 case 0x16:
12335 dac = 0x02;
12336 break;
12337 case 0x15:
12338 dac = 0x03;
12339 break;
12340 default:
12341 return 0;
12342 }
12343 if (spec->multiout.dac_nids[0] != dac &&
12344 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012345 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012346 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012347 HDA_OUTPUT));
12348 if (err < 0)
12349 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012350 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12351 }
12352
Kailang Yanga361d842007-06-05 12:30:55 +020012353 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012354 if (nid != 0x16)
12355 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012356 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012357 else /* mono */
12358 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12359 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012360 if (err < 0)
12361 return err;
12362 return 0;
12363}
12364
12365/* add playback controls from the parsed DAC table */
12366static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12367 const struct auto_pin_cfg *cfg)
12368{
12369 hda_nid_t nid;
12370 int err;
12371
Kailang Yanga361d842007-06-05 12:30:55 +020012372 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012373
12374 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012375 if (nid) {
12376 const char *name;
12377 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12378 name = "Speaker";
12379 else
12380 name = "Front";
12381 err = alc268_new_analog_output(spec, nid, name, 0);
12382 if (err < 0)
12383 return err;
12384 }
Kailang Yanga361d842007-06-05 12:30:55 +020012385
12386 nid = cfg->speaker_pins[0];
12387 if (nid == 0x1d) {
12388 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12389 "Speaker Playback Volume",
12390 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12391 if (err < 0)
12392 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012393 } else {
12394 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12395 if (err < 0)
12396 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012397 }
12398 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012399 if (nid) {
12400 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12401 if (err < 0)
12402 return err;
12403 }
Kailang Yanga361d842007-06-05 12:30:55 +020012404
12405 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12406 if (nid == 0x16) {
12407 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12408 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012409 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012410 if (err < 0)
12411 return err;
12412 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012413 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012414}
12415
12416/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012417static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012418 const struct auto_pin_cfg *cfg)
12419{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012420 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012421}
12422
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012423static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12424 hda_nid_t nid, int pin_type)
12425{
12426 int idx;
12427
12428 alc_set_pin_output(codec, nid, pin_type);
12429 if (nid == 0x14 || nid == 0x16)
12430 idx = 0;
12431 else
12432 idx = 1;
12433 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12434}
12435
12436static void alc268_auto_init_multi_out(struct hda_codec *codec)
12437{
12438 struct alc_spec *spec = codec->spec;
12439 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12440 if (nid) {
12441 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12442 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12443 }
12444}
12445
12446static void alc268_auto_init_hp_out(struct hda_codec *codec)
12447{
12448 struct alc_spec *spec = codec->spec;
12449 hda_nid_t pin;
12450
12451 pin = spec->autocfg.hp_pins[0];
12452 if (pin)
12453 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12454 pin = spec->autocfg.speaker_pins[0];
12455 if (pin)
12456 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12457}
12458
Kailang Yanga361d842007-06-05 12:30:55 +020012459static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12460{
12461 struct alc_spec *spec = codec->spec;
12462 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12463 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12464 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12465 unsigned int dac_vol1, dac_vol2;
12466
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012467 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012468 snd_hda_codec_write(codec, speaker_nid, 0,
12469 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012470 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012471 snd_hda_codec_write(codec, 0x0f, 0,
12472 AC_VERB_SET_AMP_GAIN_MUTE,
12473 AMP_IN_UNMUTE(1));
12474 snd_hda_codec_write(codec, 0x10, 0,
12475 AC_VERB_SET_AMP_GAIN_MUTE,
12476 AMP_IN_UNMUTE(1));
12477 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012478 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012479 snd_hda_codec_write(codec, 0x0f, 0,
12480 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12481 snd_hda_codec_write(codec, 0x10, 0,
12482 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12483 }
12484
12485 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012486 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012487 dac_vol2 = AMP_OUT_ZERO;
12488 else if (line_nid == 0x15)
12489 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012490 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012491 dac_vol2 = AMP_OUT_ZERO;
12492 else if (hp_nid == 0x15)
12493 dac_vol1 = AMP_OUT_ZERO;
12494 if (line_nid != 0x16 || hp_nid != 0x16 ||
12495 spec->autocfg.line_out_pins[1] != 0x16 ||
12496 spec->autocfg.line_out_pins[2] != 0x16)
12497 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12498
12499 snd_hda_codec_write(codec, 0x02, 0,
12500 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12501 snd_hda_codec_write(codec, 0x03, 0,
12502 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12503}
12504
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012505/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012506#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12507#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012508#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012509#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12510
12511/*
12512 * BIOS auto configuration
12513 */
12514static int alc268_parse_auto_config(struct hda_codec *codec)
12515{
12516 struct alc_spec *spec = codec->spec;
12517 int err;
12518 static hda_nid_t alc268_ignore[] = { 0 };
12519
12520 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12521 alc268_ignore);
12522 if (err < 0)
12523 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012524 if (!spec->autocfg.line_outs) {
12525 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12526 spec->multiout.max_channels = 2;
12527 spec->no_analog = 1;
12528 goto dig_only;
12529 }
Kailang Yanga361d842007-06-05 12:30:55 +020012530 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012531 }
Kailang Yanga361d842007-06-05 12:30:55 +020012532 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12533 if (err < 0)
12534 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012535 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012536 if (err < 0)
12537 return err;
12538
12539 spec->multiout.max_channels = 2;
12540
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012541 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012542 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012543 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012544 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012545 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12546 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012547 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012548 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012549
Takashi Iwai892981f2009-03-02 08:04:35 +010012550 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012551 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012552
Takashi Iwaid88897e2008-10-31 15:01:37 +010012553 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012554 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012555 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012556
Takashi Iwai776e1842007-08-29 15:07:11 +020012557 err = alc_auto_add_mic_boost(codec);
12558 if (err < 0)
12559 return err;
12560
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012561 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12562
Kailang Yanga361d842007-06-05 12:30:55 +020012563 return 1;
12564}
12565
Kailang Yanga361d842007-06-05 12:30:55 +020012566#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12567
12568/* init callback for auto-configuration model -- overriding the default init */
12569static void alc268_auto_init(struct hda_codec *codec)
12570{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012571 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012572 alc268_auto_init_multi_out(codec);
12573 alc268_auto_init_hp_out(codec);
12574 alc268_auto_init_mono_speaker_out(codec);
12575 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012576 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012577 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012578}
12579
12580/*
12581 * configuration and preset
12582 */
12583static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012584 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012585 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012586 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012587 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012588 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012589 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012590 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012591 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012592#ifdef CONFIG_SND_DEBUG
12593 [ALC268_TEST] = "test",
12594#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012595 [ALC268_AUTO] = "auto",
12596};
12597
12598static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012599 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012600 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012601 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012602 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012603 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012604 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12605 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012606 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012607 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12608 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012609 /* almost compatible with toshiba but with optional digital outs;
12610 * auto-probing seems working fine
12611 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012612 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012613 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012614 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012615 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012616 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012617 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012618 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012619 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012620 {}
12621};
12622
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012623/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12624static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12625 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12626 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12627 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12628 ALC268_TOSHIBA),
12629 {}
12630};
12631
Kailang Yanga361d842007-06-05 12:30:55 +020012632static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012633 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012634 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12635 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012636 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12637 alc267_quanta_il1_verbs },
12638 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12639 .dac_nids = alc268_dac_nids,
12640 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12641 .adc_nids = alc268_adc_nids_alt,
12642 .hp_nid = 0x03,
12643 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12644 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012645 .unsol_event = alc_sku_unsol_event,
12646 .setup = alc267_quanta_il1_setup,
12647 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012648 },
Kailang Yanga361d842007-06-05 12:30:55 +020012649 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012650 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12651 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012652 .init_verbs = { alc268_base_init_verbs },
12653 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12654 .dac_nids = alc268_dac_nids,
12655 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12656 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012657 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012658 .hp_nid = 0x03,
12659 .dig_out_nid = ALC268_DIGOUT_NID,
12660 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12661 .channel_mode = alc268_modes,
12662 .input_mux = &alc268_capture_source,
12663 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012664 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012665 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012666 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012667 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12668 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012669 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12670 .dac_nids = alc268_dac_nids,
12671 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12672 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012673 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012674 .hp_nid = 0x03,
12675 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12676 .channel_mode = alc268_modes,
12677 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012678 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012679 .setup = alc268_toshiba_setup,
12680 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012681 },
12682 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012683 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012684 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012685 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12686 alc268_acer_verbs },
12687 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12688 .dac_nids = alc268_dac_nids,
12689 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12690 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012691 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012692 .hp_nid = 0x02,
12693 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12694 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012695 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012696 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012697 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012698 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012699 [ALC268_ACER_DMIC] = {
12700 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12701 alc268_beep_mixer },
12702 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12703 alc268_acer_verbs },
12704 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12705 .dac_nids = alc268_dac_nids,
12706 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12707 .adc_nids = alc268_adc_nids_alt,
12708 .capsrc_nids = alc268_capsrc_nids,
12709 .hp_nid = 0x02,
12710 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12711 .channel_mode = alc268_modes,
12712 .input_mux = &alc268_acer_dmic_capture_source,
12713 .unsol_event = alc268_acer_unsol_event,
12714 .init_hook = alc268_acer_init_hook,
12715 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012716 [ALC268_ACER_ASPIRE_ONE] = {
12717 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012718 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012719 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012720 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12721 alc268_acer_aspire_one_verbs },
12722 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12723 .dac_nids = alc268_dac_nids,
12724 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12725 .adc_nids = alc268_adc_nids_alt,
12726 .capsrc_nids = alc268_capsrc_nids,
12727 .hp_nid = 0x03,
12728 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12729 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012730 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012731 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012732 .init_hook = alc268_acer_lc_init_hook,
12733 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012734 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012735 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12736 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012737 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12738 alc268_dell_verbs },
12739 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12740 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012741 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12742 .adc_nids = alc268_adc_nids_alt,
12743 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012744 .hp_nid = 0x02,
12745 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12746 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012747 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012748 .setup = alc268_dell_setup,
12749 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012750 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012751 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012752 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12753 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012754 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12755 alc268_toshiba_verbs },
12756 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12757 .dac_nids = alc268_dac_nids,
12758 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12759 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012760 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012761 .hp_nid = 0x03,
12762 .dig_out_nid = ALC268_DIGOUT_NID,
12763 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12764 .channel_mode = alc268_modes,
12765 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012766 .setup = alc268_toshiba_setup,
12767 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012768 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012769#ifdef CONFIG_SND_DEBUG
12770 [ALC268_TEST] = {
12771 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12772 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12773 alc268_volume_init_verbs },
12774 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12775 .dac_nids = alc268_dac_nids,
12776 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12777 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012778 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012779 .hp_nid = 0x03,
12780 .dig_out_nid = ALC268_DIGOUT_NID,
12781 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12782 .channel_mode = alc268_modes,
12783 .input_mux = &alc268_capture_source,
12784 },
12785#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012786};
12787
12788static int patch_alc268(struct hda_codec *codec)
12789{
12790 struct alc_spec *spec;
12791 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012792 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012793
12794 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12795 if (spec == NULL)
12796 return -ENOMEM;
12797
12798 codec->spec = spec;
12799
12800 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12801 alc268_models,
12802 alc268_cfg_tbl);
12803
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012804 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12805 board_config = snd_hda_check_board_codec_sid_config(codec,
12806 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12807
Kailang Yanga361d842007-06-05 12:30:55 +020012808 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012809 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12810 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012811 board_config = ALC268_AUTO;
12812 }
12813
12814 if (board_config == ALC268_AUTO) {
12815 /* automatic parse from the BIOS config */
12816 err = alc268_parse_auto_config(codec);
12817 if (err < 0) {
12818 alc_free(codec);
12819 return err;
12820 } else if (!err) {
12821 printk(KERN_INFO
12822 "hda_codec: Cannot set up configuration "
12823 "from BIOS. Using base mode...\n");
12824 board_config = ALC268_3ST;
12825 }
12826 }
12827
12828 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012829 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012830
Kailang Yanga361d842007-06-05 12:30:55 +020012831 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12832 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012833 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012834
Kailang Yanga361d842007-06-05 12:30:55 +020012835 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12836
Takashi Iwai22971e32009-02-10 11:56:44 +010012837 has_beep = 0;
12838 for (i = 0; i < spec->num_mixers; i++) {
12839 if (spec->mixers[i] == alc268_beep_mixer) {
12840 has_beep = 1;
12841 break;
12842 }
12843 }
12844
12845 if (has_beep) {
12846 err = snd_hda_attach_beep_device(codec, 0x1);
12847 if (err < 0) {
12848 alc_free(codec);
12849 return err;
12850 }
12851 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12852 /* override the amp caps for beep generator */
12853 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012854 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12855 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12856 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12857 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012858 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012859
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012860 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012861 /* check whether NID 0x07 is valid */
12862 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012863 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012864
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012865 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012866 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012867 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012868 if (spec->auto_mic ||
12869 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012870 spec->adc_nids = alc268_adc_nids_alt;
12871 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012872 if (spec->auto_mic)
12873 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012874 if (spec->auto_mic || spec->input_mux->num_items == 1)
12875 add_mixer(spec, alc268_capture_nosrc_mixer);
12876 else
12877 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012878 } else {
12879 spec->adc_nids = alc268_adc_nids;
12880 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012881 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012882 }
Takashi Iwai85860c02008-02-19 15:00:15 +010012883 /* set default input source */
12884 for (i = 0; i < spec->num_adc_nids; i++)
12885 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12886 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012887 i < spec->num_mux_defs ?
12888 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012889 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012890 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012891
12892 spec->vmaster_nid = 0x02;
12893
Kailang Yanga361d842007-06-05 12:30:55 +020012894 codec->patch_ops = alc_patch_ops;
12895 if (board_config == ALC268_AUTO)
12896 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012897
Takashi Iwaidaead532008-11-28 12:55:36 +010012898 codec->proc_widget_hook = print_realtek_coef;
12899
Kailang Yanga361d842007-06-05 12:30:55 +020012900 return 0;
12901}
12902
12903/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012904 * ALC269 channel source setting (2 channel)
12905 */
12906#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12907
12908#define alc269_dac_nids alc260_dac_nids
12909
12910static hda_nid_t alc269_adc_nids[1] = {
12911 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012912 0x08,
12913};
12914
Takashi Iwaie01bf502008-08-21 16:25:07 +020012915static hda_nid_t alc269_capsrc_nids[1] = {
12916 0x23,
12917};
12918
12919/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12920 * not a mux!
12921 */
12922
Kailang Yangf6a92242007-12-13 16:52:54 +010012923#define alc269_modes alc260_modes
12924#define alc269_capture_source alc880_lg_lw_capture_source
12925
12926static struct snd_kcontrol_new alc269_base_mixer[] = {
12927 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12928 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12929 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12930 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12932 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12933 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12934 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12936 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12938 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12939 { } /* end */
12940};
12941
Kailang Yang60db6b52008-08-26 13:13:00 +020012942static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12943 /* output mixer control */
12944 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12945 {
12946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12947 .name = "Master Playback Switch",
12948 .info = snd_hda_mixer_amp_switch_info,
12949 .get = snd_hda_mixer_amp_switch_get,
12950 .put = alc268_acer_master_sw_put,
12951 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12952 },
12953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12956 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12957 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12958 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012959 { }
12960};
12961
Tony Vroon64154832008-11-06 15:08:49 +000012962static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12963 /* output mixer control */
12964 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12965 {
12966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12967 .name = "Master Playback Switch",
12968 .info = snd_hda_mixer_amp_switch_info,
12969 .get = snd_hda_mixer_amp_switch_get,
12970 .put = alc268_acer_master_sw_put,
12971 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12972 },
12973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12975 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12976 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12977 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12978 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12979 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12980 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12981 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012982 { }
12983};
12984
Kailang Yangf53281e2008-07-18 12:36:43 +020012985static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012986 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012987 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012989 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012990 { } /* end */
12991};
12992
Kailang Yangf6a92242007-12-13 16:52:54 +010012993/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012994static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12995 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12996 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12998 { } /* end */
12999};
13000
13001/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013002#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013003
Kailang Yang60db6b52008-08-26 13:13:00 +020013004static struct hda_verb alc269_quanta_fl1_verbs[] = {
13005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13006 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13010 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13011 { }
13012};
13013
Tony Vroon64154832008-11-06 15:08:49 +000013014static struct hda_verb alc269_lifebook_verbs[] = {
13015 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13016 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13017 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13018 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13019 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13021 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13022 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13023 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13024 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13025 { }
13026};
13027
Kailang Yang60db6b52008-08-26 13:13:00 +020013028/* toggle speaker-output according to the hp-jack state */
13029static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13030{
13031 unsigned int present;
13032 unsigned char bits;
13033
13034 present = snd_hda_codec_read(codec, 0x15, 0,
13035 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13036 bits = present ? AMP_IN_MUTE(0) : 0;
13037 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13038 AMP_IN_MUTE(0), bits);
13039 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13040 AMP_IN_MUTE(0), bits);
13041
13042 snd_hda_codec_write(codec, 0x20, 0,
13043 AC_VERB_SET_COEF_INDEX, 0x0c);
13044 snd_hda_codec_write(codec, 0x20, 0,
13045 AC_VERB_SET_PROC_COEF, 0x680);
13046
13047 snd_hda_codec_write(codec, 0x20, 0,
13048 AC_VERB_SET_COEF_INDEX, 0x0c);
13049 snd_hda_codec_write(codec, 0x20, 0,
13050 AC_VERB_SET_PROC_COEF, 0x480);
13051}
13052
Tony Vroon64154832008-11-06 15:08:49 +000013053/* toggle speaker-output according to the hp-jacks state */
13054static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13055{
13056 unsigned int present;
13057 unsigned char bits;
13058
13059 /* Check laptop headphone socket */
13060 present = snd_hda_codec_read(codec, 0x15, 0,
13061 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13062
13063 /* Check port replicator headphone socket */
13064 present |= snd_hda_codec_read(codec, 0x1a, 0,
13065 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13066
13067 bits = present ? AMP_IN_MUTE(0) : 0;
13068 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13069 AMP_IN_MUTE(0), bits);
13070 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13071 AMP_IN_MUTE(0), bits);
13072
13073 snd_hda_codec_write(codec, 0x20, 0,
13074 AC_VERB_SET_COEF_INDEX, 0x0c);
13075 snd_hda_codec_write(codec, 0x20, 0,
13076 AC_VERB_SET_PROC_COEF, 0x680);
13077
13078 snd_hda_codec_write(codec, 0x20, 0,
13079 AC_VERB_SET_COEF_INDEX, 0x0c);
13080 snd_hda_codec_write(codec, 0x20, 0,
13081 AC_VERB_SET_PROC_COEF, 0x480);
13082}
13083
Tony Vroon64154832008-11-06 15:08:49 +000013084static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13085{
13086 unsigned int present_laptop;
13087 unsigned int present_dock;
13088
13089 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13090 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13091
13092 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13093 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13094
13095 /* Laptop mic port overrides dock mic port, design decision */
13096 if (present_dock)
13097 snd_hda_codec_write(codec, 0x23, 0,
13098 AC_VERB_SET_CONNECT_SEL, 0x3);
13099 if (present_laptop)
13100 snd_hda_codec_write(codec, 0x23, 0,
13101 AC_VERB_SET_CONNECT_SEL, 0x0);
13102 if (!present_dock && !present_laptop)
13103 snd_hda_codec_write(codec, 0x23, 0,
13104 AC_VERB_SET_CONNECT_SEL, 0x1);
13105}
13106
Kailang Yang60db6b52008-08-26 13:13:00 +020013107static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13108 unsigned int res)
13109{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013110 switch (res >> 26) {
13111 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013112 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013113 break;
13114 case ALC880_MIC_EVENT:
13115 alc_mic_automute(codec);
13116 break;
13117 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013118}
13119
Tony Vroon64154832008-11-06 15:08:49 +000013120static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13121 unsigned int res)
13122{
13123 if ((res >> 26) == ALC880_HP_EVENT)
13124 alc269_lifebook_speaker_automute(codec);
13125 if ((res >> 26) == ALC880_MIC_EVENT)
13126 alc269_lifebook_mic_autoswitch(codec);
13127}
13128
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013129static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13130{
13131 struct alc_spec *spec = codec->spec;
13132 spec->ext_mic.pin = 0x18;
13133 spec->ext_mic.mux_idx = 0;
13134 spec->int_mic.pin = 0x19;
13135 spec->int_mic.mux_idx = 1;
13136 spec->auto_mic = 1;
13137}
13138
Kailang Yang60db6b52008-08-26 13:13:00 +020013139static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13140{
13141 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013142 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013143}
13144
Tony Vroon64154832008-11-06 15:08:49 +000013145static void alc269_lifebook_init_hook(struct hda_codec *codec)
13146{
13147 alc269_lifebook_speaker_automute(codec);
13148 alc269_lifebook_mic_autoswitch(codec);
13149}
13150
Kailang Yang60db6b52008-08-26 13:13:00 +020013151static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13152 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13153 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13154 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13156 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13157 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13159 {}
13160};
13161
13162static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13163 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13164 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13165 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13167 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13168 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13169 {}
13170};
13171
13172/* toggle speaker-output according to the hp-jack state */
13173static void alc269_speaker_automute(struct hda_codec *codec)
13174{
13175 unsigned int present;
13176 unsigned char bits;
13177
13178 present = snd_hda_codec_read(codec, 0x15, 0,
13179 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13180 bits = present ? AMP_IN_MUTE(0) : 0;
13181 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13182 AMP_IN_MUTE(0), bits);
13183 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13184 AMP_IN_MUTE(0), bits);
13185}
13186
Kailang Yang60db6b52008-08-26 13:13:00 +020013187/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013188static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013189 unsigned int res)
13190{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013191 switch (res >> 26) {
13192 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013193 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013194 break;
13195 case ALC880_MIC_EVENT:
13196 alc_mic_automute(codec);
13197 break;
13198 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013199}
13200
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013201static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13202{
13203 struct alc_spec *spec = codec->spec;
13204 spec->ext_mic.pin = 0x18;
13205 spec->ext_mic.mux_idx = 0;
13206 spec->int_mic.pin = 0x12;
13207 spec->int_mic.mux_idx = 5;
13208 spec->auto_mic = 1;
13209}
13210
13211static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13212{
13213 struct alc_spec *spec = codec->spec;
13214 spec->ext_mic.pin = 0x18;
13215 spec->ext_mic.mux_idx = 0;
13216 spec->int_mic.pin = 0x19;
13217 spec->int_mic.mux_idx = 1;
13218 spec->auto_mic = 1;
13219}
13220
13221static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013222{
13223 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013224 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013225}
13226
Kailang Yangf6a92242007-12-13 16:52:54 +010013227/*
13228 * generic initialization of ADC, input mixers and output mixers
13229 */
13230static struct hda_verb alc269_init_verbs[] = {
13231 /*
13232 * Unmute ADC0 and set the default input to mic-in
13233 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013235
13236 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13237 * analog-loopback mixer widget
13238 * Note: PASD motherboards uses the Line In 2 as the input for
13239 * front panel mic (mic 2)
13240 */
13241 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13247
13248 /*
13249 * Set up output mixers (0x0c - 0x0e)
13250 */
13251 /* set vol=0 to output mixers */
13252 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13253 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13254
13255 /* set up input amps for analog loopback */
13256 /* Amp Indices: DAC = 0, mixer = 1 */
13257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13260 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13263
13264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13266 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13271
13272 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13276 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13277 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13279
13280 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13281 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13282
13283 /* FIXME: use matrix-type input source selection */
13284 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13285 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13290
13291 /* set EAPD */
13292 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13293 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13294 { }
13295};
13296
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013297#define alc269_auto_create_multi_out_ctls \
13298 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013299#define alc269_auto_create_input_ctls \
13300 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013301
13302#ifdef CONFIG_SND_HDA_POWER_SAVE
13303#define alc269_loopbacks alc880_loopbacks
13304#endif
13305
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013306/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013307#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13308#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13309#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13310#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13311
Takashi Iwaif03d3112009-03-05 14:18:16 +010013312static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13313 .substreams = 1,
13314 .channels_min = 2,
13315 .channels_max = 8,
13316 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13317 /* NID is set in alc_build_pcms */
13318 .ops = {
13319 .open = alc880_playback_pcm_open,
13320 .prepare = alc880_playback_pcm_prepare,
13321 .cleanup = alc880_playback_pcm_cleanup
13322 },
13323};
13324
13325static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13326 .substreams = 1,
13327 .channels_min = 2,
13328 .channels_max = 2,
13329 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13330 /* NID is set in alc_build_pcms */
13331};
13332
Kailang Yangf6a92242007-12-13 16:52:54 +010013333/*
13334 * BIOS auto configuration
13335 */
13336static int alc269_parse_auto_config(struct hda_codec *codec)
13337{
13338 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013339 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013340 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13341
13342 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13343 alc269_ignore);
13344 if (err < 0)
13345 return err;
13346
13347 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13348 if (err < 0)
13349 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013350 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013351 if (err < 0)
13352 return err;
13353
13354 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13355
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013356 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013357 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13358
Takashi Iwai603c4012008-07-30 15:01:44 +020013359 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013360 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013361
Takashi Iwaid88897e2008-10-31 15:01:37 +010013362 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013363 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013364 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013365 /* set default input source */
13366 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13367 0, AC_VERB_SET_CONNECT_SEL,
13368 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013369
13370 err = alc_auto_add_mic_boost(codec);
13371 if (err < 0)
13372 return err;
13373
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013374 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013375 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013376
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013377 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13378
Kailang Yangf6a92242007-12-13 16:52:54 +010013379 return 1;
13380}
13381
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013382#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13383#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013384#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13385
13386
13387/* init callback for auto-configuration model -- overriding the default init */
13388static void alc269_auto_init(struct hda_codec *codec)
13389{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013390 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013391 alc269_auto_init_multi_out(codec);
13392 alc269_auto_init_hp_out(codec);
13393 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013394 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013395 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013396}
13397
13398/*
13399 * configuration and preset
13400 */
13401static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013402 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013403 [ALC269_QUANTA_FL1] = "quanta",
13404 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013405 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013406 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013407 [ALC269_LIFEBOOK] = "lifebook",
13408 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013409};
13410
13411static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013412 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013413 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13414 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013415 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13416 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13417 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13418 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13419 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13420 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013421 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13422 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013423 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13424 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013425 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013426 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013427 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013428 {}
13429};
13430
13431static struct alc_config_preset alc269_presets[] = {
13432 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013433 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013434 .init_verbs = { alc269_init_verbs },
13435 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13436 .dac_nids = alc269_dac_nids,
13437 .hp_nid = 0x03,
13438 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13439 .channel_mode = alc269_modes,
13440 .input_mux = &alc269_capture_source,
13441 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013442 [ALC269_QUANTA_FL1] = {
13443 .mixers = { alc269_quanta_fl1_mixer },
13444 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13445 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13446 .dac_nids = alc269_dac_nids,
13447 .hp_nid = 0x03,
13448 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13449 .channel_mode = alc269_modes,
13450 .input_mux = &alc269_capture_source,
13451 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013452 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013453 .init_hook = alc269_quanta_fl1_init_hook,
13454 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013455 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013456 .mixers = { alc269_eeepc_mixer },
13457 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013458 .init_verbs = { alc269_init_verbs,
13459 alc269_eeepc_amic_init_verbs },
13460 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13461 .dac_nids = alc269_dac_nids,
13462 .hp_nid = 0x03,
13463 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13464 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013465 .unsol_event = alc269_eeepc_unsol_event,
13466 .setup = alc269_eeepc_amic_setup,
13467 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013468 },
13469 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013470 .mixers = { alc269_eeepc_mixer },
13471 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013472 .init_verbs = { alc269_init_verbs,
13473 alc269_eeepc_dmic_init_verbs },
13474 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13475 .dac_nids = alc269_dac_nids,
13476 .hp_nid = 0x03,
13477 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13478 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013479 .unsol_event = alc269_eeepc_unsol_event,
13480 .setup = alc269_eeepc_dmic_setup,
13481 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013482 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013483 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013484 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013485 .cap_mixer = alc269_epc_capture_mixer,
13486 .init_verbs = { alc269_init_verbs,
13487 alc269_eeepc_dmic_init_verbs },
13488 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13489 .dac_nids = alc269_dac_nids,
13490 .hp_nid = 0x03,
13491 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13492 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013493 .unsol_event = alc269_eeepc_unsol_event,
13494 .setup = alc269_eeepc_dmic_setup,
13495 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013496 },
Tony Vroon64154832008-11-06 15:08:49 +000013497 [ALC269_LIFEBOOK] = {
13498 .mixers = { alc269_lifebook_mixer },
13499 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13500 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13501 .dac_nids = alc269_dac_nids,
13502 .hp_nid = 0x03,
13503 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13504 .channel_mode = alc269_modes,
13505 .input_mux = &alc269_capture_source,
13506 .unsol_event = alc269_lifebook_unsol_event,
13507 .init_hook = alc269_lifebook_init_hook,
13508 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013509};
13510
13511static int patch_alc269(struct hda_codec *codec)
13512{
13513 struct alc_spec *spec;
13514 int board_config;
13515 int err;
13516
13517 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13518 if (spec == NULL)
13519 return -ENOMEM;
13520
13521 codec->spec = spec;
13522
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013523 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13524
Kailang Yangf6a92242007-12-13 16:52:54 +010013525 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13526 alc269_models,
13527 alc269_cfg_tbl);
13528
13529 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013530 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13531 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013532 board_config = ALC269_AUTO;
13533 }
13534
13535 if (board_config == ALC269_AUTO) {
13536 /* automatic parse from the BIOS config */
13537 err = alc269_parse_auto_config(codec);
13538 if (err < 0) {
13539 alc_free(codec);
13540 return err;
13541 } else if (!err) {
13542 printk(KERN_INFO
13543 "hda_codec: Cannot set up configuration "
13544 "from BIOS. Using base mode...\n");
13545 board_config = ALC269_BASIC;
13546 }
13547 }
13548
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013549 err = snd_hda_attach_beep_device(codec, 0x1);
13550 if (err < 0) {
13551 alc_free(codec);
13552 return err;
13553 }
13554
Kailang Yangf6a92242007-12-13 16:52:54 +010013555 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013556 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013557
Takashi Iwaif03d3112009-03-05 14:18:16 +010013558 if (codec->subsystem_id == 0x17aa3bf8) {
13559 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13560 * fix the sample rate of analog I/O to 44.1kHz
13561 */
13562 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13563 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13564 } else {
13565 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13566 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13567 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013568 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13569 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13570
13571 spec->adc_nids = alc269_adc_nids;
13572 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013573 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013574 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013575 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013576 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013577
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013578 spec->vmaster_nid = 0x02;
13579
Kailang Yangf6a92242007-12-13 16:52:54 +010013580 codec->patch_ops = alc_patch_ops;
13581 if (board_config == ALC269_AUTO)
13582 spec->init_hook = alc269_auto_init;
13583#ifdef CONFIG_SND_HDA_POWER_SAVE
13584 if (!spec->loopback.amplist)
13585 spec->loopback.amplist = alc269_loopbacks;
13586#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013587 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013588
13589 return 0;
13590}
13591
13592/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013593 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13594 */
13595
13596/*
13597 * set the path ways for 2 channel output
13598 * need to set the codec line out and mic 1 pin widgets to inputs
13599 */
13600static struct hda_verb alc861_threestack_ch2_init[] = {
13601 /* set pin widget 1Ah (line in) for input */
13602 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013603 /* set pin widget 18h (mic1/2) for input, for mic also enable
13604 * the vref
13605 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013606 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13607
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013608 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13609#if 0
13610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13611 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13612#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013613 { } /* end */
13614};
13615/*
13616 * 6ch mode
13617 * need to set the codec line out and mic 1 pin widgets to outputs
13618 */
13619static struct hda_verb alc861_threestack_ch6_init[] = {
13620 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13621 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13622 /* set pin widget 18h (mic1) for output (CLFE)*/
13623 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13624
13625 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013626 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013627
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013628 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13629#if 0
13630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13631 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13632#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013633 { } /* end */
13634};
13635
13636static struct hda_channel_mode alc861_threestack_modes[2] = {
13637 { 2, alc861_threestack_ch2_init },
13638 { 6, alc861_threestack_ch6_init },
13639};
Takashi Iwai22309c32006-08-09 16:57:28 +020013640/* Set mic1 as input and unmute the mixer */
13641static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13642 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13643 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13644 { } /* end */
13645};
13646/* Set mic1 as output and mute mixer */
13647static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13648 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13649 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13650 { } /* end */
13651};
13652
13653static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13654 { 2, alc861_uniwill_m31_ch2_init },
13655 { 4, alc861_uniwill_m31_ch4_init },
13656};
Kailang Yangdf694da2005-12-05 19:42:22 +010013657
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013658/* Set mic1 and line-in as input and unmute the mixer */
13659static struct hda_verb alc861_asus_ch2_init[] = {
13660 /* set pin widget 1Ah (line in) for input */
13661 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013662 /* set pin widget 18h (mic1/2) for input, for mic also enable
13663 * the vref
13664 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013665 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13666
13667 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13668#if 0
13669 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13670 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13671#endif
13672 { } /* end */
13673};
13674/* Set mic1 nad line-in as output and mute mixer */
13675static struct hda_verb alc861_asus_ch6_init[] = {
13676 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13677 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13678 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13679 /* set pin widget 18h (mic1) for output (CLFE)*/
13680 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13681 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13682 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13683 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13684
13685 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13686#if 0
13687 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13688 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13689#endif
13690 { } /* end */
13691};
13692
13693static struct hda_channel_mode alc861_asus_modes[2] = {
13694 { 2, alc861_asus_ch2_init },
13695 { 6, alc861_asus_ch6_init },
13696};
13697
Kailang Yangdf694da2005-12-05 19:42:22 +010013698/* patch-ALC861 */
13699
13700static struct snd_kcontrol_new alc861_base_mixer[] = {
13701 /* output mixer control */
13702 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13703 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13704 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13705 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13706 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13707
13708 /*Input mixer control */
13709 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13710 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13711 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13712 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13713 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13714 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13715 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13716 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13717 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013719
Kailang Yangdf694da2005-12-05 19:42:22 +010013720 { } /* end */
13721};
13722
13723static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13724 /* output mixer control */
13725 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13726 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13727 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13728 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13729 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13730
13731 /* Input mixer control */
13732 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13733 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13734 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13735 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13736 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13737 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13739 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13740 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13741 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013742
Kailang Yangdf694da2005-12-05 19:42:22 +010013743 {
13744 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13745 .name = "Channel Mode",
13746 .info = alc_ch_mode_info,
13747 .get = alc_ch_mode_get,
13748 .put = alc_ch_mode_put,
13749 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13750 },
13751 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013752};
13753
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013754static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013755 /* output mixer control */
13756 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13757 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13758 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013759
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013760 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013761};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013762
Takashi Iwai22309c32006-08-09 16:57:28 +020013763static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13764 /* output mixer control */
13765 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13766 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13767 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13768 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13769 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13770
13771 /* Input mixer control */
13772 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13773 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13774 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13775 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13776 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13777 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13779 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013782
Takashi Iwai22309c32006-08-09 16:57:28 +020013783 {
13784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13785 .name = "Channel Mode",
13786 .info = alc_ch_mode_info,
13787 .get = alc_ch_mode_get,
13788 .put = alc_ch_mode_put,
13789 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13790 },
13791 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013792};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013793
13794static struct snd_kcontrol_new alc861_asus_mixer[] = {
13795 /* output mixer control */
13796 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13797 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13798 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13799 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13800 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13801
13802 /* Input mixer control */
13803 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13804 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13805 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13806 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13807 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13808 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13810 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13813
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013814 {
13815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13816 .name = "Channel Mode",
13817 .info = alc_ch_mode_info,
13818 .get = alc_ch_mode_get,
13819 .put = alc_ch_mode_put,
13820 .private_value = ARRAY_SIZE(alc861_asus_modes),
13821 },
13822 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013823};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013824
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013825/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013826static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013827 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13828 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013829 { }
13830};
13831
Kailang Yangdf694da2005-12-05 19:42:22 +010013832/*
13833 * generic initialization of ADC, input mixers and output mixers
13834 */
13835static struct hda_verb alc861_base_init_verbs[] = {
13836 /*
13837 * Unmute ADC0 and set the default input to mic-in
13838 */
13839 /* port-A for surround (rear panel) */
13840 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13841 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13842 /* port-B for mic-in (rear panel) with vref */
13843 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13844 /* port-C for line-in (rear panel) */
13845 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13846 /* port-D for Front */
13847 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13848 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13849 /* port-E for HP out (front panel) */
13850 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13851 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013852 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013853 /* port-F for mic-in (front panel) with vref */
13854 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13855 /* port-G for CLFE (rear panel) */
13856 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13857 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13858 /* port-H for side (rear panel) */
13859 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13860 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13861 /* CD-in */
13862 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13863 /* route front mic to ADC1*/
13864 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013866
Kailang Yangdf694da2005-12-05 19:42:22 +010013867 /* Unmute DAC0~3 & spdif out*/
13868 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13869 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13870 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13871 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013873
Kailang Yangdf694da2005-12-05 19:42:22 +010013874 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13875 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13876 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13877 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13878 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013879
Kailang Yangdf694da2005-12-05 19:42:22 +010013880 /* Unmute Stereo Mixer 15 */
13881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013885
13886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13892 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013894 /* hp used DAC 3 (Front) */
13895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13897
13898 { }
13899};
13900
13901static struct hda_verb alc861_threestack_init_verbs[] = {
13902 /*
13903 * Unmute ADC0 and set the default input to mic-in
13904 */
13905 /* port-A for surround (rear panel) */
13906 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13907 /* port-B for mic-in (rear panel) with vref */
13908 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13909 /* port-C for line-in (rear panel) */
13910 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13911 /* port-D for Front */
13912 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13913 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13914 /* port-E for HP out (front panel) */
13915 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13916 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013917 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013918 /* port-F for mic-in (front panel) with vref */
13919 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13920 /* port-G for CLFE (rear panel) */
13921 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13922 /* port-H for side (rear panel) */
13923 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13924 /* CD-in */
13925 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13926 /* route front mic to ADC1*/
13927 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13929 /* Unmute DAC0~3 & spdif out*/
13930 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13931 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13932 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13933 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013935
Kailang Yangdf694da2005-12-05 19:42:22 +010013936 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13937 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13938 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13939 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13940 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013941
Kailang Yangdf694da2005-12-05 19:42:22 +010013942 /* Unmute Stereo Mixer 15 */
13943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013947
13948 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13949 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13950 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13951 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13952 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13953 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13955 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013956 /* hp used DAC 3 (Front) */
13957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013958 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13959 { }
13960};
Takashi Iwai22309c32006-08-09 16:57:28 +020013961
13962static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13963 /*
13964 * Unmute ADC0 and set the default input to mic-in
13965 */
13966 /* port-A for surround (rear panel) */
13967 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13968 /* port-B for mic-in (rear panel) with vref */
13969 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13970 /* port-C for line-in (rear panel) */
13971 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13972 /* port-D for Front */
13973 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13974 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13975 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013976 /* this has to be set to VREF80 */
13977 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013978 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013979 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013980 /* port-F for mic-in (front panel) with vref */
13981 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13982 /* port-G for CLFE (rear panel) */
13983 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13984 /* port-H for side (rear panel) */
13985 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13986 /* CD-in */
13987 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13988 /* route front mic to ADC1*/
13989 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13991 /* Unmute DAC0~3 & spdif out*/
13992 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13993 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13994 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13995 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013997
Takashi Iwai22309c32006-08-09 16:57:28 +020013998 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13999 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14001 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14002 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014003
Takashi Iwai22309c32006-08-09 16:57:28 +020014004 /* Unmute Stereo Mixer 15 */
14005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014008 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014009
14010 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14011 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14012 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14014 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14016 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14017 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014018 /* hp used DAC 3 (Front) */
14019 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14021 { }
14022};
14023
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014024static struct hda_verb alc861_asus_init_verbs[] = {
14025 /*
14026 * Unmute ADC0 and set the default input to mic-in
14027 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014028 /* port-A for surround (rear panel)
14029 * according to codec#0 this is the HP jack
14030 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014031 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14032 /* route front PCM to HP */
14033 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14034 /* port-B for mic-in (rear panel) with vref */
14035 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14036 /* port-C for line-in (rear panel) */
14037 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14038 /* port-D for Front */
14039 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14040 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14041 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014042 /* this has to be set to VREF80 */
14043 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014044 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014045 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014046 /* port-F for mic-in (front panel) with vref */
14047 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14048 /* port-G for CLFE (rear panel) */
14049 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14050 /* port-H for side (rear panel) */
14051 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14052 /* CD-in */
14053 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14054 /* route front mic to ADC1*/
14055 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14057 /* Unmute DAC0~3 & spdif out*/
14058 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14059 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14060 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14061 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14063 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14064 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14065 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14066 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14067 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014068
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014069 /* Unmute Stereo Mixer 15 */
14070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014074
14075 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14078 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14080 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14082 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014083 /* hp used DAC 3 (Front) */
14084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014085 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14086 { }
14087};
14088
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014089/* additional init verbs for ASUS laptops */
14090static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14091 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14092 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14093 { }
14094};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014095
Kailang Yangdf694da2005-12-05 19:42:22 +010014096/*
14097 * generic initialization of ADC, input mixers and output mixers
14098 */
14099static struct hda_verb alc861_auto_init_verbs[] = {
14100 /*
14101 * Unmute ADC0 and set the default input to mic-in
14102 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014103 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014105
Kailang Yangdf694da2005-12-05 19:42:22 +010014106 /* Unmute DAC0~3 & spdif out*/
14107 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14108 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14109 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14110 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014112
Kailang Yangdf694da2005-12-05 19:42:22 +010014113 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14114 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14115 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14116 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14117 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014118
Kailang Yangdf694da2005-12-05 19:42:22 +010014119 /* Unmute Stereo Mixer 15 */
14120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14121 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14124
Takashi Iwai1c209302009-07-22 15:17:45 +020014125 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14126 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14127 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14128 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14129 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14131 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014133
14134 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014138 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014142
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014143 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014144
14145 { }
14146};
14147
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014148static struct hda_verb alc861_toshiba_init_verbs[] = {
14149 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014150
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014151 { }
14152};
14153
14154/* toggle speaker-output according to the hp-jack state */
14155static void alc861_toshiba_automute(struct hda_codec *codec)
14156{
14157 unsigned int present;
14158
14159 present = snd_hda_codec_read(codec, 0x0f, 0,
14160 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014161 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14162 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14163 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14164 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014165}
14166
14167static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14168 unsigned int res)
14169{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014170 if ((res >> 26) == ALC880_HP_EVENT)
14171 alc861_toshiba_automute(codec);
14172}
14173
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014174/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014175#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14176#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14177#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14178#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14179
14180
14181#define ALC861_DIGOUT_NID 0x07
14182
14183static struct hda_channel_mode alc861_8ch_modes[1] = {
14184 { 8, NULL }
14185};
14186
14187static hda_nid_t alc861_dac_nids[4] = {
14188 /* front, surround, clfe, side */
14189 0x03, 0x06, 0x05, 0x04
14190};
14191
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014192static hda_nid_t alc660_dac_nids[3] = {
14193 /* front, clfe, surround */
14194 0x03, 0x05, 0x06
14195};
14196
Kailang Yangdf694da2005-12-05 19:42:22 +010014197static hda_nid_t alc861_adc_nids[1] = {
14198 /* ADC0-2 */
14199 0x08,
14200};
14201
14202static struct hda_input_mux alc861_capture_source = {
14203 .num_items = 5,
14204 .items = {
14205 { "Mic", 0x0 },
14206 { "Front Mic", 0x3 },
14207 { "Line", 0x1 },
14208 { "CD", 0x4 },
14209 { "Mixer", 0x5 },
14210 },
14211};
14212
Takashi Iwai1c209302009-07-22 15:17:45 +020014213static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14214{
14215 struct alc_spec *spec = codec->spec;
14216 hda_nid_t mix, srcs[5];
14217 int i, j, num;
14218
14219 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14220 return 0;
14221 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14222 if (num < 0)
14223 return 0;
14224 for (i = 0; i < num; i++) {
14225 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014226 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014227 if (type != AC_WID_AUD_OUT)
14228 continue;
14229 for (j = 0; j < spec->multiout.num_dacs; j++)
14230 if (spec->multiout.dac_nids[j] == srcs[i])
14231 break;
14232 if (j >= spec->multiout.num_dacs)
14233 return srcs[i];
14234 }
14235 return 0;
14236}
14237
Kailang Yangdf694da2005-12-05 19:42:22 +010014238/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014239static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014240 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014241{
Takashi Iwai1c209302009-07-22 15:17:45 +020014242 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014243 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014244 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014245
14246 spec->multiout.dac_nids = spec->private_dac_nids;
14247 for (i = 0; i < cfg->line_outs; i++) {
14248 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014249 dac = alc861_look_for_dac(codec, nid);
14250 if (!dac)
14251 continue;
14252 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014253 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014254 return 0;
14255}
14256
Takashi Iwai1c209302009-07-22 15:17:45 +020014257static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14258 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014259{
14260 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014261 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14262 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14263 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14264}
14265
14266/* add playback controls from the parsed DAC table */
14267static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14268 const struct auto_pin_cfg *cfg)
14269{
14270 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014271 static const char *chname[4] = {
14272 "Front", "Surround", NULL /*CLFE*/, "Side"
14273 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014274 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014275 int i, err;
14276
14277 if (cfg->line_outs == 1) {
14278 const char *pfx = NULL;
14279 if (!cfg->hp_outs)
14280 pfx = "Master";
14281 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14282 pfx = "Speaker";
14283 if (pfx) {
14284 nid = spec->multiout.dac_nids[0];
14285 return alc861_create_out_sw(codec, pfx, nid, 3);
14286 }
14287 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014288
14289 for (i = 0; i < cfg->line_outs; i++) {
14290 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014291 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014292 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014293 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014294 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014295 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014296 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014297 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014298 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014299 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014300 return err;
14301 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014302 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014303 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014304 return err;
14305 }
14306 }
14307 return 0;
14308}
14309
Takashi Iwai1c209302009-07-22 15:17:45 +020014310static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014311{
Takashi Iwai1c209302009-07-22 15:17:45 +020014312 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014313 int err;
14314 hda_nid_t nid;
14315
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014316 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014317 return 0;
14318
14319 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014320 nid = alc861_look_for_dac(codec, pin);
14321 if (nid) {
14322 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14323 if (err < 0)
14324 return err;
14325 spec->multiout.hp_nid = nid;
14326 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014327 }
14328 return 0;
14329}
14330
14331/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014332static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014333 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014334{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014335 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014336}
14337
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014338static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14339 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014340 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014341{
Takashi Iwai1c209302009-07-22 15:17:45 +020014342 hda_nid_t mix, srcs[5];
14343 int i, num;
14344
Jacek Luczak564c5be2008-05-03 18:41:23 +020014345 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14346 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014347 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014348 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014349 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14350 return;
14351 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14352 if (num < 0)
14353 return;
14354 for (i = 0; i < num; i++) {
14355 unsigned int mute;
14356 if (srcs[i] == dac || srcs[i] == 0x15)
14357 mute = AMP_IN_UNMUTE(i);
14358 else
14359 mute = AMP_IN_MUTE(i);
14360 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14361 mute);
14362 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014363}
14364
14365static void alc861_auto_init_multi_out(struct hda_codec *codec)
14366{
14367 struct alc_spec *spec = codec->spec;
14368 int i;
14369
14370 for (i = 0; i < spec->autocfg.line_outs; i++) {
14371 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014372 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014373 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014374 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014375 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014376 }
14377}
14378
14379static void alc861_auto_init_hp_out(struct hda_codec *codec)
14380{
14381 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014382
Takashi Iwai15870f02009-10-05 08:25:13 +020014383 if (spec->autocfg.hp_outs)
14384 alc861_auto_set_output_and_unmute(codec,
14385 spec->autocfg.hp_pins[0],
14386 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014387 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014388 if (spec->autocfg.speaker_outs)
14389 alc861_auto_set_output_and_unmute(codec,
14390 spec->autocfg.speaker_pins[0],
14391 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014392 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014393}
14394
14395static void alc861_auto_init_analog_input(struct hda_codec *codec)
14396{
14397 struct alc_spec *spec = codec->spec;
14398 int i;
14399
14400 for (i = 0; i < AUTO_PIN_LAST; i++) {
14401 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014402 if (nid >= 0x0c && nid <= 0x11)
14403 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014404 }
14405}
14406
14407/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014408/* return 1 if successful, 0 if the proper config is not found,
14409 * or a negative error code
14410 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014411static int alc861_parse_auto_config(struct hda_codec *codec)
14412{
14413 struct alc_spec *spec = codec->spec;
14414 int err;
14415 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14416
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014417 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14418 alc861_ignore);
14419 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014420 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014421 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014422 return 0; /* can't find valid BIOS pin config */
14423
Takashi Iwai1c209302009-07-22 15:17:45 +020014424 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014425 if (err < 0)
14426 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014427 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014428 if (err < 0)
14429 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014430 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014431 if (err < 0)
14432 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014433 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014434 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014435 return err;
14436
14437 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14438
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014439 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014440 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14441
Takashi Iwai603c4012008-07-30 15:01:44 +020014442 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014443 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014444
Takashi Iwaid88897e2008-10-31 15:01:37 +010014445 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014446
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014447 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014448 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014449
14450 spec->adc_nids = alc861_adc_nids;
14451 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014452 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014453
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014454 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14455
Kailang Yangdf694da2005-12-05 19:42:22 +010014456 return 1;
14457}
14458
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014459/* additional initialization for auto-configuration model */
14460static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014461{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014462 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014463 alc861_auto_init_multi_out(codec);
14464 alc861_auto_init_hp_out(codec);
14465 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014466 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014467 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014468}
14469
Takashi Iwaicb53c622007-08-10 17:21:45 +020014470#ifdef CONFIG_SND_HDA_POWER_SAVE
14471static struct hda_amp_list alc861_loopbacks[] = {
14472 { 0x15, HDA_INPUT, 0 },
14473 { 0x15, HDA_INPUT, 1 },
14474 { 0x15, HDA_INPUT, 2 },
14475 { 0x15, HDA_INPUT, 3 },
14476 { } /* end */
14477};
14478#endif
14479
Kailang Yangdf694da2005-12-05 19:42:22 +010014480
14481/*
14482 * configuration and preset
14483 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014484static const char *alc861_models[ALC861_MODEL_LAST] = {
14485 [ALC861_3ST] = "3stack",
14486 [ALC660_3ST] = "3stack-660",
14487 [ALC861_3ST_DIG] = "3stack-dig",
14488 [ALC861_6ST_DIG] = "6stack-dig",
14489 [ALC861_UNIWILL_M31] = "uniwill-m31",
14490 [ALC861_TOSHIBA] = "toshiba",
14491 [ALC861_ASUS] = "asus",
14492 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14493 [ALC861_AUTO] = "auto",
14494};
14495
14496static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014497 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014498 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14499 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14500 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014501 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014502 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014503 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014504 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14505 * Any other models that need this preset?
14506 */
14507 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014508 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14509 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014510 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14511 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14512 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14513 /* FIXME: the below seems conflict */
14514 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14515 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14516 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014517 {}
14518};
14519
14520static struct alc_config_preset alc861_presets[] = {
14521 [ALC861_3ST] = {
14522 .mixers = { alc861_3ST_mixer },
14523 .init_verbs = { alc861_threestack_init_verbs },
14524 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14525 .dac_nids = alc861_dac_nids,
14526 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14527 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014528 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014529 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14530 .adc_nids = alc861_adc_nids,
14531 .input_mux = &alc861_capture_source,
14532 },
14533 [ALC861_3ST_DIG] = {
14534 .mixers = { alc861_base_mixer },
14535 .init_verbs = { alc861_threestack_init_verbs },
14536 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14537 .dac_nids = alc861_dac_nids,
14538 .dig_out_nid = ALC861_DIGOUT_NID,
14539 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14540 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014541 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014542 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14543 .adc_nids = alc861_adc_nids,
14544 .input_mux = &alc861_capture_source,
14545 },
14546 [ALC861_6ST_DIG] = {
14547 .mixers = { alc861_base_mixer },
14548 .init_verbs = { alc861_base_init_verbs },
14549 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14550 .dac_nids = alc861_dac_nids,
14551 .dig_out_nid = ALC861_DIGOUT_NID,
14552 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14553 .channel_mode = alc861_8ch_modes,
14554 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14555 .adc_nids = alc861_adc_nids,
14556 .input_mux = &alc861_capture_source,
14557 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014558 [ALC660_3ST] = {
14559 .mixers = { alc861_3ST_mixer },
14560 .init_verbs = { alc861_threestack_init_verbs },
14561 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14562 .dac_nids = alc660_dac_nids,
14563 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14564 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014565 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014566 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14567 .adc_nids = alc861_adc_nids,
14568 .input_mux = &alc861_capture_source,
14569 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014570 [ALC861_UNIWILL_M31] = {
14571 .mixers = { alc861_uniwill_m31_mixer },
14572 .init_verbs = { alc861_uniwill_m31_init_verbs },
14573 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14574 .dac_nids = alc861_dac_nids,
14575 .dig_out_nid = ALC861_DIGOUT_NID,
14576 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14577 .channel_mode = alc861_uniwill_m31_modes,
14578 .need_dac_fix = 1,
14579 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14580 .adc_nids = alc861_adc_nids,
14581 .input_mux = &alc861_capture_source,
14582 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014583 [ALC861_TOSHIBA] = {
14584 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014585 .init_verbs = { alc861_base_init_verbs,
14586 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014587 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14588 .dac_nids = alc861_dac_nids,
14589 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14590 .channel_mode = alc883_3ST_2ch_modes,
14591 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14592 .adc_nids = alc861_adc_nids,
14593 .input_mux = &alc861_capture_source,
14594 .unsol_event = alc861_toshiba_unsol_event,
14595 .init_hook = alc861_toshiba_automute,
14596 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014597 [ALC861_ASUS] = {
14598 .mixers = { alc861_asus_mixer },
14599 .init_verbs = { alc861_asus_init_verbs },
14600 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14601 .dac_nids = alc861_dac_nids,
14602 .dig_out_nid = ALC861_DIGOUT_NID,
14603 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14604 .channel_mode = alc861_asus_modes,
14605 .need_dac_fix = 1,
14606 .hp_nid = 0x06,
14607 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14608 .adc_nids = alc861_adc_nids,
14609 .input_mux = &alc861_capture_source,
14610 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014611 [ALC861_ASUS_LAPTOP] = {
14612 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14613 .init_verbs = { alc861_asus_init_verbs,
14614 alc861_asus_laptop_init_verbs },
14615 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14616 .dac_nids = alc861_dac_nids,
14617 .dig_out_nid = ALC861_DIGOUT_NID,
14618 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14619 .channel_mode = alc883_3ST_2ch_modes,
14620 .need_dac_fix = 1,
14621 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14622 .adc_nids = alc861_adc_nids,
14623 .input_mux = &alc861_capture_source,
14624 },
14625};
Kailang Yangdf694da2005-12-05 19:42:22 +010014626
14627
14628static int patch_alc861(struct hda_codec *codec)
14629{
14630 struct alc_spec *spec;
14631 int board_config;
14632 int err;
14633
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014634 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014635 if (spec == NULL)
14636 return -ENOMEM;
14637
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014638 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014639
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014640 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14641 alc861_models,
14642 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014643
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014644 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014645 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14646 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014647 board_config = ALC861_AUTO;
14648 }
14649
14650 if (board_config == ALC861_AUTO) {
14651 /* automatic parse from the BIOS config */
14652 err = alc861_parse_auto_config(codec);
14653 if (err < 0) {
14654 alc_free(codec);
14655 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014656 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014657 printk(KERN_INFO
14658 "hda_codec: Cannot set up configuration "
14659 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014660 board_config = ALC861_3ST_DIG;
14661 }
14662 }
14663
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014664 err = snd_hda_attach_beep_device(codec, 0x23);
14665 if (err < 0) {
14666 alc_free(codec);
14667 return err;
14668 }
14669
Kailang Yangdf694da2005-12-05 19:42:22 +010014670 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014671 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014672
Kailang Yangdf694da2005-12-05 19:42:22 +010014673 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14674 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14675
Kailang Yangdf694da2005-12-05 19:42:22 +010014676 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14677 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14678
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014679 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14680
Takashi Iwai2134ea42008-01-10 16:53:55 +010014681 spec->vmaster_nid = 0x03;
14682
Kailang Yangdf694da2005-12-05 19:42:22 +010014683 codec->patch_ops = alc_patch_ops;
14684 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014685 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014686#ifdef CONFIG_SND_HDA_POWER_SAVE
14687 if (!spec->loopback.amplist)
14688 spec->loopback.amplist = alc861_loopbacks;
14689#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014690 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014691
Kailang Yangdf694da2005-12-05 19:42:22 +010014692 return 0;
14693}
14694
14695/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014696 * ALC861-VD support
14697 *
14698 * Based on ALC882
14699 *
14700 * In addition, an independent DAC
14701 */
14702#define ALC861VD_DIGOUT_NID 0x06
14703
14704static hda_nid_t alc861vd_dac_nids[4] = {
14705 /* front, surr, clfe, side surr */
14706 0x02, 0x03, 0x04, 0x05
14707};
14708
14709/* dac_nids for ALC660vd are in a different order - according to
14710 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014711 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014712 * of ALC660vd codecs, but for now there is only 3stack mixer
14713 * - and it is the same as in 861vd.
14714 * adc_nids in ALC660vd are (is) the same as in 861vd
14715 */
14716static hda_nid_t alc660vd_dac_nids[3] = {
14717 /* front, rear, clfe, rear_surr */
14718 0x02, 0x04, 0x03
14719};
14720
14721static hda_nid_t alc861vd_adc_nids[1] = {
14722 /* ADC0 */
14723 0x09,
14724};
14725
Takashi Iwaie1406342008-02-11 18:32:32 +010014726static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14727
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014728/* input MUX */
14729/* FIXME: should be a matrix-type input source selection */
14730static struct hda_input_mux alc861vd_capture_source = {
14731 .num_items = 4,
14732 .items = {
14733 { "Mic", 0x0 },
14734 { "Front Mic", 0x1 },
14735 { "Line", 0x2 },
14736 { "CD", 0x4 },
14737 },
14738};
14739
Kailang Yang272a5272007-05-14 11:00:38 +020014740static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014741 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014742 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014743 { "Ext Mic", 0x0 },
14744 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014745 },
14746};
14747
Kailang Yangd1a991a2007-08-15 16:21:59 +020014748static struct hda_input_mux alc861vd_hp_capture_source = {
14749 .num_items = 2,
14750 .items = {
14751 { "Front Mic", 0x0 },
14752 { "ATAPI Mic", 0x1 },
14753 },
14754};
14755
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014756/*
14757 * 2ch mode
14758 */
14759static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14760 { 2, NULL }
14761};
14762
14763/*
14764 * 6ch mode
14765 */
14766static struct hda_verb alc861vd_6stack_ch6_init[] = {
14767 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14768 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14769 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14770 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14771 { } /* end */
14772};
14773
14774/*
14775 * 8ch mode
14776 */
14777static struct hda_verb alc861vd_6stack_ch8_init[] = {
14778 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14779 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14780 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14781 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14782 { } /* end */
14783};
14784
14785static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14786 { 6, alc861vd_6stack_ch6_init },
14787 { 8, alc861vd_6stack_ch8_init },
14788};
14789
14790static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14791 {
14792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14793 .name = "Channel Mode",
14794 .info = alc_ch_mode_info,
14795 .get = alc_ch_mode_get,
14796 .put = alc_ch_mode_put,
14797 },
14798 { } /* end */
14799};
14800
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014801/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14802 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14803 */
14804static struct snd_kcontrol_new alc861vd_6st_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_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14809 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14810
14811 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14812 HDA_OUTPUT),
14813 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14814 HDA_OUTPUT),
14815 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14816 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14817
14818 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14819 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14820
14821 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14822
14823 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14826
14827 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14828 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14829 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14830
14831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14833
14834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14836
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014837 { } /* end */
14838};
14839
14840static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14841 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14842 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14843
14844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14845
14846 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14849
14850 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14853
14854 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14855 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14856
14857 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14858 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14859
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014860 { } /* end */
14861};
14862
Kailang Yangbdd148a2007-05-08 15:19:08 +020014863static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14864 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14865 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14866 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14867
14868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14869
14870 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14873
14874 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14876 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14877
14878 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14879 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14880
14881 { } /* end */
14882};
14883
Tobin Davisb419f342008-03-07 11:57:51 +010014884/* Pin assignment: Speaker=0x14, HP = 0x15,
14885 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014886 */
14887static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014888 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14889 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014890 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14891 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014892 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14893 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14894 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14895 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14896 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14897 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014898 { } /* end */
14899};
14900
Kailang Yangd1a991a2007-08-15 16:21:59 +020014901/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14902 * Front Mic=0x18, ATAPI Mic = 0x19,
14903 */
14904static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14905 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14906 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14908 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14909 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14910 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14911 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14912 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014913
Kailang Yangd1a991a2007-08-15 16:21:59 +020014914 { } /* end */
14915};
14916
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014917/*
14918 * generic initialization of ADC, input mixers and output mixers
14919 */
14920static struct hda_verb alc861vd_volume_init_verbs[] = {
14921 /*
14922 * Unmute ADC0 and set the default input to mic-in
14923 */
14924 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14925 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14926
14927 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14928 * the analog-loopback mixer widget
14929 */
14930 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014936
14937 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014942
14943 /*
14944 * Set up output mixers (0x02 - 0x05)
14945 */
14946 /* set vol=0 to output mixers */
14947 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14948 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14949 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14950 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14951
14952 /* set up input amps for analog loopback */
14953 /* Amp Indices: DAC = 0, mixer = 1 */
14954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14957 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14958 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14959 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14960 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14961 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14962
14963 { }
14964};
14965
14966/*
14967 * 3-stack pin configuration:
14968 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14969 */
14970static struct hda_verb alc861vd_3stack_init_verbs[] = {
14971 /*
14972 * Set pin mode and muting
14973 */
14974 /* set front pin widgets 0x14 for output */
14975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14976 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14977 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14978
14979 /* Mic (rear) pin: input vref at 80% */
14980 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14981 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14982 /* Front Mic pin: input vref at 80% */
14983 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14984 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14985 /* Line In pin: input */
14986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14987 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14988 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14990 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14991 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14992 /* CD pin widget for input */
14993 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14994
14995 { }
14996};
14997
14998/*
14999 * 6-stack pin configuration:
15000 */
15001static struct hda_verb alc861vd_6stack_init_verbs[] = {
15002 /*
15003 * Set pin mode and muting
15004 */
15005 /* set front pin widgets 0x14 for output */
15006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15008 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15009
15010 /* Rear Pin: output 1 (0x0d) */
15011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15014 /* CLFE Pin: output 2 (0x0e) */
15015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15017 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15018 /* Side Pin: output 3 (0x0f) */
15019 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15020 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15021 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15022
15023 /* Mic (rear) pin: input vref at 80% */
15024 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15025 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15026 /* Front Mic pin: input vref at 80% */
15027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15029 /* Line In pin: input */
15030 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15031 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15032 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15033 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15034 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15035 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15036 /* CD pin widget for input */
15037 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15038
15039 { }
15040};
15041
Kailang Yangbdd148a2007-05-08 15:19:08 +020015042static struct hda_verb alc861vd_eapd_verbs[] = {
15043 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15044 { }
15045};
15046
Kailang Yangf9423e72008-05-27 12:32:25 +020015047static struct hda_verb alc660vd_eapd_verbs[] = {
15048 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15049 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15050 { }
15051};
15052
Kailang Yangbdd148a2007-05-08 15:19:08 +020015053static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15057 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015058 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015059 {}
15060};
15061
Kailang Yangbdd148a2007-05-08 15:19:08 +020015062static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15063{
15064 unsigned int present;
15065 unsigned char bits;
15066
15067 present = snd_hda_codec_read(codec, 0x18, 0,
15068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015069 bits = present ? HDA_AMP_MUTE : 0;
15070 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15071 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015072}
15073
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015074static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015075{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015076 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015077 spec->autocfg.hp_pins[0] = 0x1b;
15078 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015079}
15080
15081static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15082{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015083 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015084 alc861vd_lenovo_mic_automute(codec);
15085}
15086
15087static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15088 unsigned int res)
15089{
15090 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015091 case ALC880_MIC_EVENT:
15092 alc861vd_lenovo_mic_automute(codec);
15093 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015094 default:
15095 alc_automute_amp_unsol_event(codec, res);
15096 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015097 }
15098}
15099
Kailang Yang272a5272007-05-14 11:00:38 +020015100static struct hda_verb alc861vd_dallas_verbs[] = {
15101 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15102 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15103 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15104 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15105
15106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15113 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015114
Kailang Yang272a5272007-05-14 11:00:38 +020015115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15116 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15119 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15120 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15121 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15122 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15123
15124 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15125 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15126 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15127 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15128 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15130 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15131 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15132
15133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15137
15138 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015139 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015140 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15141
15142 { } /* end */
15143};
15144
15145/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015146static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015147{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015148 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015149
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015150 spec->autocfg.hp_pins[0] = 0x15;
15151 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015152}
15153
Takashi Iwaicb53c622007-08-10 17:21:45 +020015154#ifdef CONFIG_SND_HDA_POWER_SAVE
15155#define alc861vd_loopbacks alc880_loopbacks
15156#endif
15157
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015158/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015159#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15160#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15161#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15162#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15163
15164/*
15165 * configuration and preset
15166 */
15167static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15168 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015169 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015170 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015171 [ALC861VD_3ST] = "3stack",
15172 [ALC861VD_3ST_DIG] = "3stack-digout",
15173 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015174 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015175 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015176 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015177 [ALC861VD_AUTO] = "auto",
15178};
15179
15180static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015181 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15182 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015183 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015184 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015185 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015186 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015187 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015188 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015189 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015190 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015191 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015192 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015193 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015194 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015195 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015196 {}
15197};
15198
15199static struct alc_config_preset alc861vd_presets[] = {
15200 [ALC660VD_3ST] = {
15201 .mixers = { alc861vd_3st_mixer },
15202 .init_verbs = { alc861vd_volume_init_verbs,
15203 alc861vd_3stack_init_verbs },
15204 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15205 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015206 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15207 .channel_mode = alc861vd_3stack_2ch_modes,
15208 .input_mux = &alc861vd_capture_source,
15209 },
Mike Crash6963f842007-06-25 12:12:51 +020015210 [ALC660VD_3ST_DIG] = {
15211 .mixers = { alc861vd_3st_mixer },
15212 .init_verbs = { alc861vd_volume_init_verbs,
15213 alc861vd_3stack_init_verbs },
15214 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15215 .dac_nids = alc660vd_dac_nids,
15216 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015217 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15218 .channel_mode = alc861vd_3stack_2ch_modes,
15219 .input_mux = &alc861vd_capture_source,
15220 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015221 [ALC861VD_3ST] = {
15222 .mixers = { alc861vd_3st_mixer },
15223 .init_verbs = { alc861vd_volume_init_verbs,
15224 alc861vd_3stack_init_verbs },
15225 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15226 .dac_nids = alc861vd_dac_nids,
15227 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15228 .channel_mode = alc861vd_3stack_2ch_modes,
15229 .input_mux = &alc861vd_capture_source,
15230 },
15231 [ALC861VD_3ST_DIG] = {
15232 .mixers = { alc861vd_3st_mixer },
15233 .init_verbs = { alc861vd_volume_init_verbs,
15234 alc861vd_3stack_init_verbs },
15235 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15236 .dac_nids = alc861vd_dac_nids,
15237 .dig_out_nid = ALC861VD_DIGOUT_NID,
15238 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15239 .channel_mode = alc861vd_3stack_2ch_modes,
15240 .input_mux = &alc861vd_capture_source,
15241 },
15242 [ALC861VD_6ST_DIG] = {
15243 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15244 .init_verbs = { alc861vd_volume_init_verbs,
15245 alc861vd_6stack_init_verbs },
15246 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15247 .dac_nids = alc861vd_dac_nids,
15248 .dig_out_nid = ALC861VD_DIGOUT_NID,
15249 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15250 .channel_mode = alc861vd_6stack_modes,
15251 .input_mux = &alc861vd_capture_source,
15252 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015253 [ALC861VD_LENOVO] = {
15254 .mixers = { alc861vd_lenovo_mixer },
15255 .init_verbs = { alc861vd_volume_init_verbs,
15256 alc861vd_3stack_init_verbs,
15257 alc861vd_eapd_verbs,
15258 alc861vd_lenovo_unsol_verbs },
15259 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15260 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015261 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15262 .channel_mode = alc861vd_3stack_2ch_modes,
15263 .input_mux = &alc861vd_capture_source,
15264 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015265 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015266 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015267 },
Kailang Yang272a5272007-05-14 11:00:38 +020015268 [ALC861VD_DALLAS] = {
15269 .mixers = { alc861vd_dallas_mixer },
15270 .init_verbs = { alc861vd_dallas_verbs },
15271 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15272 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015273 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15274 .channel_mode = alc861vd_3stack_2ch_modes,
15275 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015276 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015277 .setup = alc861vd_dallas_setup,
15278 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015279 },
15280 [ALC861VD_HP] = {
15281 .mixers = { alc861vd_hp_mixer },
15282 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15283 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15284 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015285 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015286 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15287 .channel_mode = alc861vd_3stack_2ch_modes,
15288 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015289 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015290 .setup = alc861vd_dallas_setup,
15291 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015292 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015293 [ALC660VD_ASUS_V1S] = {
15294 .mixers = { alc861vd_lenovo_mixer },
15295 .init_verbs = { alc861vd_volume_init_verbs,
15296 alc861vd_3stack_init_verbs,
15297 alc861vd_eapd_verbs,
15298 alc861vd_lenovo_unsol_verbs },
15299 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15300 .dac_nids = alc660vd_dac_nids,
15301 .dig_out_nid = ALC861VD_DIGOUT_NID,
15302 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15303 .channel_mode = alc861vd_3stack_2ch_modes,
15304 .input_mux = &alc861vd_capture_source,
15305 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015306 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015307 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015308 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015309};
15310
15311/*
15312 * BIOS auto configuration
15313 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015314static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15315 const struct auto_pin_cfg *cfg)
15316{
15317 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15318}
15319
15320
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015321static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15322 hda_nid_t nid, int pin_type, int dac_idx)
15323{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015324 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015325}
15326
15327static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15328{
15329 struct alc_spec *spec = codec->spec;
15330 int i;
15331
15332 for (i = 0; i <= HDA_SIDE; i++) {
15333 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015334 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015335 if (nid)
15336 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015337 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015338 }
15339}
15340
15341
15342static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15343{
15344 struct alc_spec *spec = codec->spec;
15345 hda_nid_t pin;
15346
15347 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015348 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015349 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015350 pin = spec->autocfg.speaker_pins[0];
15351 if (pin)
15352 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015353}
15354
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015355#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15356
15357static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15358{
15359 struct alc_spec *spec = codec->spec;
15360 int i;
15361
15362 for (i = 0; i < AUTO_PIN_LAST; i++) {
15363 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015364 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015365 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015366 if (nid != ALC861VD_PIN_CD_NID &&
15367 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015368 snd_hda_codec_write(codec, nid, 0,
15369 AC_VERB_SET_AMP_GAIN_MUTE,
15370 AMP_OUT_MUTE);
15371 }
15372 }
15373}
15374
Takashi Iwaif511b012008-08-15 16:46:42 +020015375#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15376
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015377#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15378#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15379
15380/* add playback controls from the parsed DAC table */
15381/* Based on ALC880 version. But ALC861VD has separate,
15382 * different NIDs for mute/unmute switch and volume control */
15383static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15384 const struct auto_pin_cfg *cfg)
15385{
15386 char name[32];
15387 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15388 hda_nid_t nid_v, nid_s;
15389 int i, err;
15390
15391 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015392 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015393 continue;
15394 nid_v = alc861vd_idx_to_mixer_vol(
15395 alc880_dac_to_idx(
15396 spec->multiout.dac_nids[i]));
15397 nid_s = alc861vd_idx_to_mixer_switch(
15398 alc880_dac_to_idx(
15399 spec->multiout.dac_nids[i]));
15400
15401 if (i == 2) {
15402 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015403 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15404 "Center Playback Volume",
15405 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15406 HDA_OUTPUT));
15407 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015408 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015409 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15410 "LFE Playback Volume",
15411 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15412 HDA_OUTPUT));
15413 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015414 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015415 err = add_control(spec, ALC_CTL_BIND_MUTE,
15416 "Center Playback Switch",
15417 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15418 HDA_INPUT));
15419 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015420 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015421 err = add_control(spec, ALC_CTL_BIND_MUTE,
15422 "LFE Playback Switch",
15423 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15424 HDA_INPUT));
15425 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015426 return err;
15427 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015428 const char *pfx;
15429 if (cfg->line_outs == 1 &&
15430 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15431 if (!cfg->hp_pins)
15432 pfx = "Speaker";
15433 else
15434 pfx = "PCM";
15435 } else
15436 pfx = chname[i];
15437 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015438 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15439 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15440 HDA_OUTPUT));
15441 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015442 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015443 if (cfg->line_outs == 1 &&
15444 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15445 pfx = "Speaker";
15446 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015447 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015448 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015449 HDA_INPUT));
15450 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015451 return err;
15452 }
15453 }
15454 return 0;
15455}
15456
15457/* add playback controls for speaker and HP outputs */
15458/* Based on ALC880 version. But ALC861VD has separate,
15459 * different NIDs for mute/unmute switch and volume control */
15460static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15461 hda_nid_t pin, const char *pfx)
15462{
15463 hda_nid_t nid_v, nid_s;
15464 int err;
15465 char name[32];
15466
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015467 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015468 return 0;
15469
15470 if (alc880_is_fixed_pin(pin)) {
15471 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15472 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015473 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015474 spec->multiout.hp_nid = nid_v;
15475 else
15476 spec->multiout.extra_out_nid[0] = nid_v;
15477 /* control HP volume/switch on the output mixer amp */
15478 nid_v = alc861vd_idx_to_mixer_vol(
15479 alc880_fixed_pin_idx(pin));
15480 nid_s = alc861vd_idx_to_mixer_switch(
15481 alc880_fixed_pin_idx(pin));
15482
15483 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015484 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15485 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15486 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015487 return err;
15488 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015489 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15490 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15491 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015492 return err;
15493 } else if (alc880_is_multi_pin(pin)) {
15494 /* set manual connection */
15495 /* we have only a switch on HP-out PIN */
15496 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015497 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15498 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15499 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015500 return err;
15501 }
15502 return 0;
15503}
15504
15505/* parse the BIOS configuration and set up the alc_spec
15506 * return 1 if successful, 0 if the proper config is not found,
15507 * or a negative error code
15508 * Based on ALC880 version - had to change it to override
15509 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15510static int alc861vd_parse_auto_config(struct hda_codec *codec)
15511{
15512 struct alc_spec *spec = codec->spec;
15513 int err;
15514 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15515
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015516 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15517 alc861vd_ignore);
15518 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015519 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015520 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015521 return 0; /* can't find valid BIOS pin config */
15522
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015523 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15524 if (err < 0)
15525 return err;
15526 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15527 if (err < 0)
15528 return err;
15529 err = alc861vd_auto_create_extra_out(spec,
15530 spec->autocfg.speaker_pins[0],
15531 "Speaker");
15532 if (err < 0)
15533 return err;
15534 err = alc861vd_auto_create_extra_out(spec,
15535 spec->autocfg.hp_pins[0],
15536 "Headphone");
15537 if (err < 0)
15538 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015539 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015540 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015541 return err;
15542
15543 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15544
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015545 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015546 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15547
Takashi Iwai603c4012008-07-30 15:01:44 +020015548 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015549 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015550
Takashi Iwaid88897e2008-10-31 15:01:37 +010015551 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015552
15553 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015554 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015555
Takashi Iwai776e1842007-08-29 15:07:11 +020015556 err = alc_auto_add_mic_boost(codec);
15557 if (err < 0)
15558 return err;
15559
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015560 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15561
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015562 return 1;
15563}
15564
15565/* additional initialization for auto-configuration model */
15566static void alc861vd_auto_init(struct hda_codec *codec)
15567{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015568 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015569 alc861vd_auto_init_multi_out(codec);
15570 alc861vd_auto_init_hp_out(codec);
15571 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015572 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015573 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015574 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015575}
15576
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015577enum {
15578 ALC660VD_FIX_ASUS_GPIO1
15579};
15580
15581/* reset GPIO1 */
15582static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15583 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15584 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15585 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15586 { }
15587};
15588
15589static const struct alc_fixup alc861vd_fixups[] = {
15590 [ALC660VD_FIX_ASUS_GPIO1] = {
15591 .verbs = alc660vd_fix_asus_gpio1_verbs,
15592 },
15593};
15594
15595static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15596 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15597 {}
15598};
15599
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015600static int patch_alc861vd(struct hda_codec *codec)
15601{
15602 struct alc_spec *spec;
15603 int err, board_config;
15604
15605 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15606 if (spec == NULL)
15607 return -ENOMEM;
15608
15609 codec->spec = spec;
15610
15611 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15612 alc861vd_models,
15613 alc861vd_cfg_tbl);
15614
15615 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015616 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15617 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015618 board_config = ALC861VD_AUTO;
15619 }
15620
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015621 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15622
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015623 if (board_config == ALC861VD_AUTO) {
15624 /* automatic parse from the BIOS config */
15625 err = alc861vd_parse_auto_config(codec);
15626 if (err < 0) {
15627 alc_free(codec);
15628 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015629 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015630 printk(KERN_INFO
15631 "hda_codec: Cannot set up configuration "
15632 "from BIOS. Using base mode...\n");
15633 board_config = ALC861VD_3ST;
15634 }
15635 }
15636
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015637 err = snd_hda_attach_beep_device(codec, 0x23);
15638 if (err < 0) {
15639 alc_free(codec);
15640 return err;
15641 }
15642
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015643 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015644 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015645
Kailang Yang2f893282008-05-27 12:14:47 +020015646 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015647 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015648 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015649 }
15650
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015651 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15652 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15653
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015654 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15655 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15656
Takashi Iwaidd704692009-08-11 08:45:11 +020015657 if (!spec->adc_nids) {
15658 spec->adc_nids = alc861vd_adc_nids;
15659 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15660 }
15661 if (!spec->capsrc_nids)
15662 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015663
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015664 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015665 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015666
Takashi Iwai2134ea42008-01-10 16:53:55 +010015667 spec->vmaster_nid = 0x02;
15668
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015669 codec->patch_ops = alc_patch_ops;
15670
15671 if (board_config == ALC861VD_AUTO)
15672 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015673#ifdef CONFIG_SND_HDA_POWER_SAVE
15674 if (!spec->loopback.amplist)
15675 spec->loopback.amplist = alc861vd_loopbacks;
15676#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015677 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015678
15679 return 0;
15680}
15681
15682/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015683 * ALC662 support
15684 *
15685 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15686 * configuration. Each pin widget can choose any input DACs and a mixer.
15687 * Each ADC is connected from a mixer of all inputs. This makes possible
15688 * 6-channel independent captures.
15689 *
15690 * In addition, an independent DAC for the multi-playback (not used in this
15691 * driver yet).
15692 */
15693#define ALC662_DIGOUT_NID 0x06
15694#define ALC662_DIGIN_NID 0x0a
15695
15696static hda_nid_t alc662_dac_nids[4] = {
15697 /* front, rear, clfe, rear_surr */
15698 0x02, 0x03, 0x04
15699};
15700
Kailang Yang622e84c2009-04-21 07:39:04 +020015701static hda_nid_t alc272_dac_nids[2] = {
15702 0x02, 0x03
15703};
15704
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015705static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015706 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015707 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015708};
Takashi Iwaie1406342008-02-11 18:32:32 +010015709
Kailang Yang622e84c2009-04-21 07:39:04 +020015710static hda_nid_t alc272_adc_nids[1] = {
15711 /* ADC1-2 */
15712 0x08,
15713};
15714
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015715static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015716static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15717
Takashi Iwaie1406342008-02-11 18:32:32 +010015718
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015719/* input MUX */
15720/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015721static struct hda_input_mux alc662_capture_source = {
15722 .num_items = 4,
15723 .items = {
15724 { "Mic", 0x0 },
15725 { "Front Mic", 0x1 },
15726 { "Line", 0x2 },
15727 { "CD", 0x4 },
15728 },
15729};
15730
15731static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15732 .num_items = 2,
15733 .items = {
15734 { "Mic", 0x1 },
15735 { "Line", 0x2 },
15736 },
15737};
Kailang Yang291702f2007-10-16 14:28:03 +020015738
Kailang Yang6dda9f42008-05-27 12:05:31 +020015739static struct hda_input_mux alc663_capture_source = {
15740 .num_items = 3,
15741 .items = {
15742 { "Mic", 0x0 },
15743 { "Front Mic", 0x1 },
15744 { "Line", 0x2 },
15745 },
15746};
15747
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015748#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015749static struct hda_input_mux alc272_nc10_capture_source = {
15750 .num_items = 16,
15751 .items = {
15752 { "Autoselect Mic", 0x0 },
15753 { "Internal Mic", 0x1 },
15754 { "In-0x02", 0x2 },
15755 { "In-0x03", 0x3 },
15756 { "In-0x04", 0x4 },
15757 { "In-0x05", 0x5 },
15758 { "In-0x06", 0x6 },
15759 { "In-0x07", 0x7 },
15760 { "In-0x08", 0x8 },
15761 { "In-0x09", 0x9 },
15762 { "In-0x0a", 0x0a },
15763 { "In-0x0b", 0x0b },
15764 { "In-0x0c", 0x0c },
15765 { "In-0x0d", 0x0d },
15766 { "In-0x0e", 0x0e },
15767 { "In-0x0f", 0x0f },
15768 },
15769};
15770#endif
15771
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015772/*
15773 * 2ch mode
15774 */
15775static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15776 { 2, NULL }
15777};
15778
15779/*
15780 * 2ch mode
15781 */
15782static struct hda_verb alc662_3ST_ch2_init[] = {
15783 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15784 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15785 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15786 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15787 { } /* end */
15788};
15789
15790/*
15791 * 6ch mode
15792 */
15793static struct hda_verb alc662_3ST_ch6_init[] = {
15794 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15795 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15796 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15797 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15798 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15799 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15800 { } /* end */
15801};
15802
15803static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15804 { 2, alc662_3ST_ch2_init },
15805 { 6, alc662_3ST_ch6_init },
15806};
15807
15808/*
15809 * 2ch mode
15810 */
15811static struct hda_verb alc662_sixstack_ch6_init[] = {
15812 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15813 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15814 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15815 { } /* end */
15816};
15817
15818/*
15819 * 6ch mode
15820 */
15821static struct hda_verb alc662_sixstack_ch8_init[] = {
15822 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15823 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15824 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15825 { } /* end */
15826};
15827
15828static struct hda_channel_mode alc662_5stack_modes[2] = {
15829 { 2, alc662_sixstack_ch6_init },
15830 { 6, alc662_sixstack_ch8_init },
15831};
15832
15833/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15834 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15835 */
15836
15837static struct snd_kcontrol_new alc662_base_mixer[] = {
15838 /* output mixer control */
15839 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015840 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015841 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015842 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015843 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15844 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015845 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15846 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015847 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15848
15849 /*Input mixer control */
15850 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15851 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15852 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15853 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15854 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15855 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15856 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15857 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015858 { } /* end */
15859};
15860
15861static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15862 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015863 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015864 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15867 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15868 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15870 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15871 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15872 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015873 { } /* end */
15874};
15875
15876static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15877 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015878 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015879 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015880 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015881 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15882 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015883 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15884 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015885 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15886 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15887 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15888 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15889 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15893 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015894 { } /* end */
15895};
15896
15897static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15898 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15899 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015900 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15901 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15903 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15904 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015907 { } /* end */
15908};
15909
Kailang Yang291702f2007-10-16 14:28:03 +020015910static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015911 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15912 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015913
15914 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15915 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15916 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15917
15918 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15919 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15920 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15921 { } /* end */
15922};
15923
Kailang Yang8c427222008-01-10 13:03:59 +010015924static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015925 ALC262_HIPPO_MASTER_SWITCH,
15926 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015927 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015928 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15929 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015930 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15935 { } /* end */
15936};
15937
Kailang Yangf1d4e282008-08-26 14:03:29 +020015938static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15939 .ops = &snd_hda_bind_vol,
15940 .values = {
15941 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15942 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15943 0
15944 },
15945};
15946
15947static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15948 .ops = &snd_hda_bind_sw,
15949 .values = {
15950 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15951 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15952 0
15953 },
15954};
15955
Kailang Yang6dda9f42008-05-27 12:05:31 +020015956static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015957 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15958 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15961 { } /* end */
15962};
15963
15964static struct hda_bind_ctls alc663_asus_tree_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(0x15, 3, 0, HDA_OUTPUT),
15969 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15970 0
15971 },
15972};
15973
15974static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15975 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15976 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15977 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15979 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15980 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15981
15982 { } /* end */
15983};
15984
15985static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15986 .ops = &snd_hda_bind_sw,
15987 .values = {
15988 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15989 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15990 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15991 0
15992 },
15993};
15994
15995static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15996 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15997 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16000 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16001 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16002 { } /* end */
16003};
16004
16005static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016006 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16007 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16011 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16012 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16013 { } /* end */
16014};
16015
16016static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16017 .ops = &snd_hda_bind_vol,
16018 .values = {
16019 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16020 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16021 0
16022 },
16023};
16024
16025static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16026 .ops = &snd_hda_bind_sw,
16027 .values = {
16028 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16029 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16030 0
16031 },
16032};
16033
16034static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16035 HDA_BIND_VOL("Master Playback Volume",
16036 &alc663_asus_two_bind_master_vol),
16037 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16038 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16040 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16041 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016042 { } /* end */
16043};
16044
16045static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16046 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16047 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16048 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016052 { } /* end */
16053};
16054
16055static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16056 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16057 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16058 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16059 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16061
16062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16064 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16065 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16066 { } /* end */
16067};
16068
16069static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16070 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16071 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16072 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16073
16074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16076 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16077 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16078 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16079 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16080 { } /* end */
16081};
16082
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016083static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16084 {
16085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16086 .name = "Channel Mode",
16087 .info = alc_ch_mode_info,
16088 .get = alc_ch_mode_get,
16089 .put = alc_ch_mode_put,
16090 },
16091 { } /* end */
16092};
16093
16094static struct hda_verb alc662_init_verbs[] = {
16095 /* ADC: mute amp left and right */
16096 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16097 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16098 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16099
Takashi Iwaicb53c622007-08-10 17:21:45 +020016100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016105
Kailang Yangb60dd392007-09-20 12:50:29 +020016106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016112
16113 /* Front Pin: output 0 (0x0c) */
16114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16115 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16116
16117 /* Rear Pin: output 1 (0x0d) */
16118 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16120
16121 /* CLFE Pin: output 2 (0x0e) */
16122 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16123 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16124
16125 /* Mic (rear) pin: input vref at 80% */
16126 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16127 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16128 /* Front Mic pin: input vref at 80% */
16129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16130 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16131 /* Line In pin: input */
16132 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16133 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16134 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16137 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16138 /* CD pin widget for input */
16139 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16140
16141 /* FIXME: use matrix-type input source selection */
16142 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16143 /* Input mixer */
16144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016146
16147 /* always trun on EAPD */
16148 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16149 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16150
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016151 { }
16152};
16153
16154static struct hda_verb alc662_sue_init_verbs[] = {
16155 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16156 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016157 {}
16158};
16159
16160static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16161 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16162 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16163 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016164};
16165
Kailang Yang8c427222008-01-10 13:03:59 +010016166/* Set Unsolicited Event*/
16167static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16168 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16169 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16170 {}
16171};
16172
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016173/*
16174 * generic initialization of ADC, input mixers and output mixers
16175 */
16176static struct hda_verb alc662_auto_init_verbs[] = {
16177 /*
16178 * Unmute ADC and set the default input to mic-in
16179 */
16180 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16181 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16182
16183 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16184 * mixer widget
16185 * Note: PASD motherboards uses the Line In 2 as the input for front
16186 * panel mic (mic 2)
16187 */
16188 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016194
16195 /*
16196 * Set up output mixers (0x0c - 0x0f)
16197 */
16198 /* set vol=0 to output mixers */
16199 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16200 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16201 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16202
16203 /* set up input amps for analog loopback */
16204 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16207 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016211
16212
16213 /* FIXME: use matrix-type input source selection */
16214 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16215 /* Input mixer */
16216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016218 { }
16219};
16220
Takashi Iwai24fb9172008-09-02 14:48:20 +020016221/* additional verbs for ALC663 */
16222static struct hda_verb alc663_auto_init_verbs[] = {
16223 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16224 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16225 { }
16226};
16227
Kailang Yang6dda9f42008-05-27 12:05:31 +020016228static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16230 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016231 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16232 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016233 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16235 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016236 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16237 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16238 {}
16239};
16240
Kailang Yangf1d4e282008-08-26 14:03:29 +020016241static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16242 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16243 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16244 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16245 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16248 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16249 {}
16250};
16251
16252static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16253 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16255 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16256 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16259 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16260 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16261 {}
16262};
16263
16264static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16266 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16267 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16270 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16271 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16272 {}
16273};
16274
16275static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16276 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16277 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16278 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16279 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16282 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16285 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16286 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16287 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16288 {}
16289};
16290
16291static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16293 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16294 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16295 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16301 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16302 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16303 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16304 {}
16305};
16306
Kailang Yang6dda9f42008-05-27 12:05:31 +020016307static struct hda_verb alc663_g71v_init_verbs[] = {
16308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16309 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16310 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16311
16312 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16313 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16314 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16315
16316 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16317 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16318 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16319 {}
16320};
16321
16322static struct hda_verb alc663_g50v_init_verbs[] = {
16323 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16324 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16325 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16326
16327 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16328 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16329 {}
16330};
16331
Kailang Yangf1d4e282008-08-26 14:03:29 +020016332static struct hda_verb alc662_ecs_init_verbs[] = {
16333 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16335 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16337 {}
16338};
16339
Kailang Yang622e84c2009-04-21 07:39:04 +020016340static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16341 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16342 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16345 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16346 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16347 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16350 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16351 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16352 {}
16353};
16354
16355static struct hda_verb alc272_dell_init_verbs[] = {
16356 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16357 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16359 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16360 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16361 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16362 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16365 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16366 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16367 {}
16368};
16369
Kailang Yangf1d4e282008-08-26 14:03:29 +020016370static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16371 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16372 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16373 { } /* end */
16374};
16375
Kailang Yang622e84c2009-04-21 07:39:04 +020016376static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16377 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16378 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16379 { } /* end */
16380};
16381
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016382static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16383{
16384 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016385 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016386
16387 present = snd_hda_codec_read(codec, 0x14, 0,
16388 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016389 bits = present ? HDA_AMP_MUTE : 0;
16390 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16391 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016392}
16393
16394static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16395{
16396 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016397 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016398
16399 present = snd_hda_codec_read(codec, 0x1b, 0,
16400 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016401 bits = present ? HDA_AMP_MUTE : 0;
16402 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16403 HDA_AMP_MUTE, bits);
16404 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16405 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016406}
16407
16408static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16409 unsigned int res)
16410{
16411 if ((res >> 26) == ALC880_HP_EVENT)
16412 alc662_lenovo_101e_all_automute(codec);
16413 if ((res >> 26) == ALC880_FRONT_EVENT)
16414 alc662_lenovo_101e_ispeaker_automute(codec);
16415}
16416
Kailang Yang291702f2007-10-16 14:28:03 +020016417/* unsolicited event for HP jack sensing */
16418static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16419 unsigned int res)
16420{
Kailang Yang291702f2007-10-16 14:28:03 +020016421 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016422 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016423 else
16424 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016425}
16426
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016427static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016428{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016429 struct alc_spec *spec = codec->spec;
16430
16431 alc262_hippo1_setup(codec);
16432 spec->ext_mic.pin = 0x18;
16433 spec->ext_mic.mux_idx = 0;
16434 spec->int_mic.pin = 0x19;
16435 spec->int_mic.mux_idx = 1;
16436 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016437}
16438
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016439static void alc662_eeepc_inithook(struct hda_codec *codec)
16440{
16441 alc262_hippo_automute(codec);
16442 alc_mic_automute(codec);
16443}
16444
16445static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016446{
Takashi Iwai42171c12009-05-08 14:11:43 +020016447 struct alc_spec *spec = codec->spec;
16448
16449 spec->autocfg.hp_pins[0] = 0x14;
16450 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016451}
16452
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016453#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16454
Kailang Yang6dda9f42008-05-27 12:05:31 +020016455static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16456{
16457 unsigned int present;
16458 unsigned char bits;
16459
16460 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016461 AC_VERB_GET_PIN_SENSE, 0)
16462 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016463 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016464 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16465 AMP_IN_MUTE(0), bits);
16466 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16467 AMP_IN_MUTE(0), bits);
16468}
16469
16470static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16471{
16472 unsigned int present;
16473 unsigned char bits;
16474
16475 present = snd_hda_codec_read(codec, 0x21, 0,
16476 AC_VERB_GET_PIN_SENSE, 0)
16477 & AC_PINSENSE_PRESENCE;
16478 bits = present ? HDA_AMP_MUTE : 0;
16479 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16480 AMP_IN_MUTE(0), bits);
16481 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16482 AMP_IN_MUTE(0), bits);
16483 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16484 AMP_IN_MUTE(0), bits);
16485 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16486 AMP_IN_MUTE(0), bits);
16487}
16488
16489static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16490{
16491 unsigned int present;
16492 unsigned char bits;
16493
16494 present = snd_hda_codec_read(codec, 0x15, 0,
16495 AC_VERB_GET_PIN_SENSE, 0)
16496 & AC_PINSENSE_PRESENCE;
16497 bits = present ? HDA_AMP_MUTE : 0;
16498 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16499 AMP_IN_MUTE(0), bits);
16500 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16501 AMP_IN_MUTE(0), bits);
16502 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16503 AMP_IN_MUTE(0), bits);
16504 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16505 AMP_IN_MUTE(0), bits);
16506}
16507
16508static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16509{
16510 unsigned int present;
16511 unsigned char bits;
16512
16513 present = snd_hda_codec_read(codec, 0x1b, 0,
16514 AC_VERB_GET_PIN_SENSE, 0)
16515 & AC_PINSENSE_PRESENCE;
16516 bits = present ? 0 : PIN_OUT;
16517 snd_hda_codec_write(codec, 0x14, 0,
16518 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16519}
16520
16521static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16522{
16523 unsigned int present1, present2;
16524
16525 present1 = snd_hda_codec_read(codec, 0x21, 0,
16526 AC_VERB_GET_PIN_SENSE, 0)
16527 & AC_PINSENSE_PRESENCE;
16528 present2 = snd_hda_codec_read(codec, 0x15, 0,
16529 AC_VERB_GET_PIN_SENSE, 0)
16530 & AC_PINSENSE_PRESENCE;
16531
16532 if (present1 || present2) {
16533 snd_hda_codec_write_cache(codec, 0x14, 0,
16534 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16535 } else {
16536 snd_hda_codec_write_cache(codec, 0x14, 0,
16537 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16538 }
16539}
16540
16541static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16542{
16543 unsigned int present1, present2;
16544
16545 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16546 AC_VERB_GET_PIN_SENSE, 0)
16547 & AC_PINSENSE_PRESENCE;
16548 present2 = snd_hda_codec_read(codec, 0x15, 0,
16549 AC_VERB_GET_PIN_SENSE, 0)
16550 & AC_PINSENSE_PRESENCE;
16551
16552 if (present1 || present2) {
16553 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16554 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16555 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16556 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16557 } else {
16558 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16559 AMP_IN_MUTE(0), 0);
16560 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16561 AMP_IN_MUTE(0), 0);
16562 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016563}
16564
Kailang Yang6dda9f42008-05-27 12:05:31 +020016565static void alc663_m51va_unsol_event(struct hda_codec *codec,
16566 unsigned int res)
16567{
16568 switch (res >> 26) {
16569 case ALC880_HP_EVENT:
16570 alc663_m51va_speaker_automute(codec);
16571 break;
16572 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016573 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016574 break;
16575 }
16576}
16577
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016578static void alc663_m51va_setup(struct hda_codec *codec)
16579{
16580 struct alc_spec *spec = codec->spec;
16581 spec->ext_mic.pin = 0x18;
16582 spec->ext_mic.mux_idx = 0;
16583 spec->int_mic.pin = 0x12;
16584 spec->int_mic.mux_idx = 1;
16585 spec->auto_mic = 1;
16586}
16587
Kailang Yang6dda9f42008-05-27 12:05:31 +020016588static void alc663_m51va_inithook(struct hda_codec *codec)
16589{
16590 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016591 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016592}
16593
Kailang Yangf1d4e282008-08-26 14:03:29 +020016594/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016595#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16596#define alc663_mode1_setup alc663_m51va_setup
16597#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016598
Kailang Yangf1d4e282008-08-26 14:03:29 +020016599/* ***************** Mode2 ******************************/
16600static void alc662_mode2_unsol_event(struct hda_codec *codec,
16601 unsigned int res)
16602{
16603 switch (res >> 26) {
16604 case ALC880_HP_EVENT:
16605 alc662_f5z_speaker_automute(codec);
16606 break;
16607 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016608 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016609 break;
16610 }
16611}
16612
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016613#define alc662_mode2_setup alc663_m51va_setup
16614
Kailang Yangf1d4e282008-08-26 14:03:29 +020016615static void alc662_mode2_inithook(struct hda_codec *codec)
16616{
16617 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016618 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016619}
16620/* ***************** Mode3 ******************************/
16621static void alc663_mode3_unsol_event(struct hda_codec *codec,
16622 unsigned int res)
16623{
16624 switch (res >> 26) {
16625 case ALC880_HP_EVENT:
16626 alc663_two_hp_m1_speaker_automute(codec);
16627 break;
16628 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016629 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016630 break;
16631 }
16632}
16633
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016634#define alc663_mode3_setup alc663_m51va_setup
16635
Kailang Yangf1d4e282008-08-26 14:03:29 +020016636static void alc663_mode3_inithook(struct hda_codec *codec)
16637{
16638 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016639 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016640}
16641/* ***************** Mode4 ******************************/
16642static void alc663_mode4_unsol_event(struct hda_codec *codec,
16643 unsigned int res)
16644{
16645 switch (res >> 26) {
16646 case ALC880_HP_EVENT:
16647 alc663_21jd_two_speaker_automute(codec);
16648 break;
16649 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016650 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016651 break;
16652 }
16653}
16654
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016655#define alc663_mode4_setup alc663_m51va_setup
16656
Kailang Yangf1d4e282008-08-26 14:03:29 +020016657static void alc663_mode4_inithook(struct hda_codec *codec)
16658{
16659 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016660 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016661}
16662/* ***************** Mode5 ******************************/
16663static void alc663_mode5_unsol_event(struct hda_codec *codec,
16664 unsigned int res)
16665{
16666 switch (res >> 26) {
16667 case ALC880_HP_EVENT:
16668 alc663_15jd_two_speaker_automute(codec);
16669 break;
16670 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016671 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016672 break;
16673 }
16674}
16675
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016676#define alc663_mode5_setup alc663_m51va_setup
16677
Kailang Yangf1d4e282008-08-26 14:03:29 +020016678static void alc663_mode5_inithook(struct hda_codec *codec)
16679{
16680 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016681 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016682}
16683/* ***************** Mode6 ******************************/
16684static void alc663_mode6_unsol_event(struct hda_codec *codec,
16685 unsigned int res)
16686{
16687 switch (res >> 26) {
16688 case ALC880_HP_EVENT:
16689 alc663_two_hp_m2_speaker_automute(codec);
16690 break;
16691 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016692 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016693 break;
16694 }
16695}
16696
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016697#define alc663_mode6_setup alc663_m51va_setup
16698
Kailang Yangf1d4e282008-08-26 14:03:29 +020016699static void alc663_mode6_inithook(struct hda_codec *codec)
16700{
16701 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016702 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016703}
16704
Kailang Yang6dda9f42008-05-27 12:05:31 +020016705static void alc663_g71v_hp_automute(struct hda_codec *codec)
16706{
16707 unsigned int present;
16708 unsigned char bits;
16709
16710 present = snd_hda_codec_read(codec, 0x21, 0,
16711 AC_VERB_GET_PIN_SENSE, 0)
16712 & AC_PINSENSE_PRESENCE;
16713 bits = present ? HDA_AMP_MUTE : 0;
16714 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16715 HDA_AMP_MUTE, bits);
16716 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16717 HDA_AMP_MUTE, bits);
16718}
16719
16720static void alc663_g71v_front_automute(struct hda_codec *codec)
16721{
16722 unsigned int present;
16723 unsigned char bits;
16724
16725 present = snd_hda_codec_read(codec, 0x15, 0,
16726 AC_VERB_GET_PIN_SENSE, 0)
16727 & AC_PINSENSE_PRESENCE;
16728 bits = present ? HDA_AMP_MUTE : 0;
16729 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16730 HDA_AMP_MUTE, bits);
16731}
16732
16733static void alc663_g71v_unsol_event(struct hda_codec *codec,
16734 unsigned int res)
16735{
16736 switch (res >> 26) {
16737 case ALC880_HP_EVENT:
16738 alc663_g71v_hp_automute(codec);
16739 break;
16740 case ALC880_FRONT_EVENT:
16741 alc663_g71v_front_automute(codec);
16742 break;
16743 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016744 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016745 break;
16746 }
16747}
16748
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016749#define alc663_g71v_setup alc663_m51va_setup
16750
Kailang Yang6dda9f42008-05-27 12:05:31 +020016751static void alc663_g71v_inithook(struct hda_codec *codec)
16752{
16753 alc663_g71v_front_automute(codec);
16754 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016755 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016756}
16757
16758static void alc663_g50v_unsol_event(struct hda_codec *codec,
16759 unsigned int res)
16760{
16761 switch (res >> 26) {
16762 case ALC880_HP_EVENT:
16763 alc663_m51va_speaker_automute(codec);
16764 break;
16765 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016766 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016767 break;
16768 }
16769}
16770
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016771#define alc663_g50v_setup alc663_m51va_setup
16772
Kailang Yang6dda9f42008-05-27 12:05:31 +020016773static void alc663_g50v_inithook(struct hda_codec *codec)
16774{
16775 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016776 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016777}
16778
Kailang Yangf1d4e282008-08-26 14:03:29 +020016779static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16780 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016781 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016782
16783 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16784 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16785 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16786
16787 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16788 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16789 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16790 { } /* end */
16791};
16792
Chris Pockelé9541ba12009-05-12 08:08:53 +020016793static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16794 /* Master Playback automatically created from Speaker and Headphone */
16795 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16796 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16797 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16799
16800 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16801 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16802 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16803
16804 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16805 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16806 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16807 { } /* end */
16808};
16809
Takashi Iwaicb53c622007-08-10 17:21:45 +020016810#ifdef CONFIG_SND_HDA_POWER_SAVE
16811#define alc662_loopbacks alc880_loopbacks
16812#endif
16813
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016814
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016815/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016816#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16817#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16818#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16819#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16820
16821/*
16822 * configuration and preset
16823 */
16824static const char *alc662_models[ALC662_MODEL_LAST] = {
16825 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16826 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16827 [ALC662_3ST_6ch] = "3stack-6ch",
16828 [ALC662_5ST_DIG] = "6stack-dig",
16829 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016830 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016831 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016832 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016833 [ALC663_ASUS_M51VA] = "m51va",
16834 [ALC663_ASUS_G71V] = "g71v",
16835 [ALC663_ASUS_H13] = "h13",
16836 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016837 [ALC663_ASUS_MODE1] = "asus-mode1",
16838 [ALC662_ASUS_MODE2] = "asus-mode2",
16839 [ALC663_ASUS_MODE3] = "asus-mode3",
16840 [ALC663_ASUS_MODE4] = "asus-mode4",
16841 [ALC663_ASUS_MODE5] = "asus-mode5",
16842 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016843 [ALC272_DELL] = "dell",
16844 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016845 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016846 [ALC662_AUTO] = "auto",
16847};
16848
16849static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016850 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016851 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16852 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016853 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16854 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16855 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16856 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16857 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16858 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16859 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16860 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16861 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16862 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16863 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16864 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016865 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16866 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16867 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016868 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16869 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16870 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16871 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016872 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016873 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16874 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016875 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016876 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16877 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16878 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016879 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16880 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16881 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016882 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16883 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16884 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016885 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016886 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16887 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016888 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016889 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016890 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016891 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16892 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16893 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016894 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016895 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16896 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016897 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016898 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016899 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016900 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016901 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16902 ALC662_3ST_6ch_DIG),
Manoj Iyer3db6c032009-09-22 18:33:29 -050016903 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016904 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016905 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16906 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016907 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016908 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016909 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016910 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016911 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016912 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16913 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016914 {}
16915};
16916
16917static struct alc_config_preset alc662_presets[] = {
16918 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016919 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016920 .init_verbs = { alc662_init_verbs },
16921 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16922 .dac_nids = alc662_dac_nids,
16923 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016924 .dig_in_nid = ALC662_DIGIN_NID,
16925 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16926 .channel_mode = alc662_3ST_2ch_modes,
16927 .input_mux = &alc662_capture_source,
16928 },
16929 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016930 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016931 .init_verbs = { alc662_init_verbs },
16932 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16933 .dac_nids = alc662_dac_nids,
16934 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016935 .dig_in_nid = ALC662_DIGIN_NID,
16936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16937 .channel_mode = alc662_3ST_6ch_modes,
16938 .need_dac_fix = 1,
16939 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016940 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016941 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016942 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016943 .init_verbs = { alc662_init_verbs },
16944 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16945 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016946 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16947 .channel_mode = alc662_3ST_6ch_modes,
16948 .need_dac_fix = 1,
16949 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016950 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016951 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016952 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016953 .init_verbs = { alc662_init_verbs },
16954 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16955 .dac_nids = alc662_dac_nids,
16956 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016957 .dig_in_nid = ALC662_DIGIN_NID,
16958 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16959 .channel_mode = alc662_5stack_modes,
16960 .input_mux = &alc662_capture_source,
16961 },
16962 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016963 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016964 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16965 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16966 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16968 .channel_mode = alc662_3ST_2ch_modes,
16969 .input_mux = &alc662_lenovo_101e_capture_source,
16970 .unsol_event = alc662_lenovo_101e_unsol_event,
16971 .init_hook = alc662_lenovo_101e_all_automute,
16972 },
Kailang Yang291702f2007-10-16 14:28:03 +020016973 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016974 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016975 .init_verbs = { alc662_init_verbs,
16976 alc662_eeepc_sue_init_verbs },
16977 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16978 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016979 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16980 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016981 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016982 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016983 .init_hook = alc662_eeepc_inithook,
16984 },
Kailang Yang8c427222008-01-10 13:03:59 +010016985 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016986 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016987 alc662_chmode_mixer },
16988 .init_verbs = { alc662_init_verbs,
16989 alc662_eeepc_ep20_sue_init_verbs },
16990 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16991 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016992 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16993 .channel_mode = alc662_3ST_6ch_modes,
16994 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016995 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016996 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016997 .init_hook = alc662_eeepc_ep20_inithook,
16998 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016999 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017000 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017001 .init_verbs = { alc662_init_verbs,
17002 alc662_ecs_init_verbs },
17003 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17004 .dac_nids = alc662_dac_nids,
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 = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017008 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017009 .init_hook = alc662_eeepc_inithook,
17010 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017011 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017012 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017013 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17014 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17015 .dac_nids = alc662_dac_nids,
17016 .dig_out_nid = ALC662_DIGOUT_NID,
17017 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17018 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017019 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017020 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017021 .init_hook = alc663_m51va_inithook,
17022 },
17023 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017024 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017025 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17026 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17027 .dac_nids = alc662_dac_nids,
17028 .dig_out_nid = ALC662_DIGOUT_NID,
17029 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17030 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017031 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017032 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017033 .init_hook = alc663_g71v_inithook,
17034 },
17035 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017036 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017037 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17038 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17039 .dac_nids = alc662_dac_nids,
17040 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17041 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017042 .unsol_event = alc663_m51va_unsol_event,
17043 .init_hook = alc663_m51va_inithook,
17044 },
17045 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017046 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017047 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17048 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17049 .dac_nids = alc662_dac_nids,
17050 .dig_out_nid = ALC662_DIGOUT_NID,
17051 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17052 .channel_mode = alc662_3ST_6ch_modes,
17053 .input_mux = &alc663_capture_source,
17054 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017055 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017056 .init_hook = alc663_g50v_inithook,
17057 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017058 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017059 .mixers = { alc663_m51va_mixer },
17060 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017061 .init_verbs = { alc662_init_verbs,
17062 alc663_21jd_amic_init_verbs },
17063 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17064 .hp_nid = 0x03,
17065 .dac_nids = alc662_dac_nids,
17066 .dig_out_nid = ALC662_DIGOUT_NID,
17067 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17068 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017069 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017070 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017071 .init_hook = alc663_mode1_inithook,
17072 },
17073 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017074 .mixers = { alc662_1bjd_mixer },
17075 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017076 .init_verbs = { alc662_init_verbs,
17077 alc662_1bjd_amic_init_verbs },
17078 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17079 .dac_nids = alc662_dac_nids,
17080 .dig_out_nid = ALC662_DIGOUT_NID,
17081 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17082 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017083 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017084 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017085 .init_hook = alc662_mode2_inithook,
17086 },
17087 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017088 .mixers = { alc663_two_hp_m1_mixer },
17089 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017090 .init_verbs = { alc662_init_verbs,
17091 alc663_two_hp_amic_m1_init_verbs },
17092 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17093 .hp_nid = 0x03,
17094 .dac_nids = alc662_dac_nids,
17095 .dig_out_nid = ALC662_DIGOUT_NID,
17096 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17097 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017098 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017099 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017100 .init_hook = alc663_mode3_inithook,
17101 },
17102 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017103 .mixers = { alc663_asus_21jd_clfe_mixer },
17104 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017105 .init_verbs = { alc662_init_verbs,
17106 alc663_21jd_amic_init_verbs},
17107 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17108 .hp_nid = 0x03,
17109 .dac_nids = alc662_dac_nids,
17110 .dig_out_nid = ALC662_DIGOUT_NID,
17111 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17112 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017113 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017114 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017115 .init_hook = alc663_mode4_inithook,
17116 },
17117 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017118 .mixers = { alc663_asus_15jd_clfe_mixer },
17119 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017120 .init_verbs = { alc662_init_verbs,
17121 alc663_15jd_amic_init_verbs },
17122 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17123 .hp_nid = 0x03,
17124 .dac_nids = alc662_dac_nids,
17125 .dig_out_nid = ALC662_DIGOUT_NID,
17126 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17127 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017128 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017129 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017130 .init_hook = alc663_mode5_inithook,
17131 },
17132 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017133 .mixers = { alc663_two_hp_m2_mixer },
17134 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017135 .init_verbs = { alc662_init_verbs,
17136 alc663_two_hp_amic_m2_init_verbs },
17137 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17138 .hp_nid = 0x03,
17139 .dac_nids = alc662_dac_nids,
17140 .dig_out_nid = ALC662_DIGOUT_NID,
17141 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17142 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017143 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017144 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017145 .init_hook = alc663_mode6_inithook,
17146 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017147 [ALC272_DELL] = {
17148 .mixers = { alc663_m51va_mixer },
17149 .cap_mixer = alc272_auto_capture_mixer,
17150 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17151 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17152 .dac_nids = alc662_dac_nids,
17153 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17154 .adc_nids = alc272_adc_nids,
17155 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17156 .capsrc_nids = alc272_capsrc_nids,
17157 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017158 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017159 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017160 .init_hook = alc663_m51va_inithook,
17161 },
17162 [ALC272_DELL_ZM1] = {
17163 .mixers = { alc663_m51va_mixer },
17164 .cap_mixer = alc662_auto_capture_mixer,
17165 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17166 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17167 .dac_nids = alc662_dac_nids,
17168 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17169 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017170 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017171 .capsrc_nids = alc662_capsrc_nids,
17172 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017173 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017174 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017175 .init_hook = alc663_m51va_inithook,
17176 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017177 [ALC272_SAMSUNG_NC10] = {
17178 .mixers = { alc272_nc10_mixer },
17179 .init_verbs = { alc662_init_verbs,
17180 alc663_21jd_amic_init_verbs },
17181 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17182 .dac_nids = alc272_dac_nids,
17183 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17184 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017185 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017186 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017187 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017188 .init_hook = alc663_mode4_inithook,
17189 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017190};
17191
17192
17193/*
17194 * BIOS auto configuration
17195 */
17196
Takashi Iwai7085ec12009-10-02 09:03:58 +020017197/* convert from MIX nid to DAC */
17198static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17199{
17200 if (nid == 0x0f)
17201 return 0x02;
17202 else if (nid >= 0x0c && nid <= 0x0e)
17203 return nid - 0x0c + 0x02;
17204 else
17205 return 0;
17206}
17207
17208/* get MIX nid connected to the given pin targeted to DAC */
17209static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17210 hda_nid_t dac)
17211{
17212 hda_nid_t mix[4];
17213 int i, num;
17214
17215 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17216 for (i = 0; i < num; i++) {
17217 if (alc662_mix_to_dac(mix[i]) == dac)
17218 return mix[i];
17219 }
17220 return 0;
17221}
17222
17223/* look for an empty DAC slot */
17224static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17225{
17226 struct alc_spec *spec = codec->spec;
17227 hda_nid_t srcs[5];
17228 int i, j, num;
17229
17230 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17231 if (num < 0)
17232 return 0;
17233 for (i = 0; i < num; i++) {
17234 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17235 if (!nid)
17236 continue;
17237 for (j = 0; j < spec->multiout.num_dacs; j++)
17238 if (spec->multiout.dac_nids[j] == nid)
17239 break;
17240 if (j >= spec->multiout.num_dacs)
17241 return nid;
17242 }
17243 return 0;
17244}
17245
17246/* fill in the dac_nids table from the parsed pin configuration */
17247static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17248 const struct auto_pin_cfg *cfg)
17249{
17250 struct alc_spec *spec = codec->spec;
17251 int i;
17252 hda_nid_t dac;
17253
17254 spec->multiout.dac_nids = spec->private_dac_nids;
17255 for (i = 0; i < cfg->line_outs; i++) {
17256 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17257 if (!dac)
17258 continue;
17259 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17260 }
17261 return 0;
17262}
17263
17264static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
17265 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017266{
17267 char name[32];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017268 sprintf(name, "%s Playback Volume", pfx);
17269 return add_control(spec, ALC_CTL_WIDGET_VOL, name,
17270 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17271}
17272
17273static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
17274 hda_nid_t nid, unsigned int chs)
17275{
17276 char name[32];
17277 sprintf(name, "%s Playback Switch", pfx);
17278 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17279 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17280}
17281
17282#define alc662_add_stereo_vol(spec, pfx, nid) \
17283 alc662_add_vol_ctl(spec, pfx, nid, 3)
17284#define alc662_add_stereo_sw(spec, pfx, nid) \
17285 alc662_add_sw_ctl(spec, pfx, nid, 3)
17286
17287/* add playback controls from the parsed DAC table */
17288static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17289 const struct auto_pin_cfg *cfg)
17290{
17291 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017292 static const char *chname[4] = {
17293 "Front", "Surround", NULL /*CLFE*/, "Side"
17294 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017295 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017296 int i, err;
17297
17298 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017299 nid = spec->multiout.dac_nids[i];
17300 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017301 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017302 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17303 if (!mix)
17304 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017305 if (i == 2) {
17306 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017307 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017308 if (err < 0)
17309 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017310 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017311 if (err < 0)
17312 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017313 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017314 if (err < 0)
17315 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017316 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017317 if (err < 0)
17318 return err;
17319 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017320 const char *pfx;
17321 if (cfg->line_outs == 1 &&
17322 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017323 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017324 pfx = "Speaker";
17325 else
17326 pfx = "PCM";
17327 } else
17328 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017329 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017330 if (err < 0)
17331 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017332 if (cfg->line_outs == 1 &&
17333 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17334 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017335 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017336 if (err < 0)
17337 return err;
17338 }
17339 }
17340 return 0;
17341}
17342
17343/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017344/* return DAC nid if any new DAC is assigned */
17345static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017346 const char *pfx)
17347{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017348 struct alc_spec *spec = codec->spec;
17349 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017351
17352 if (!pin)
17353 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017354 nid = alc662_look_for_dac(codec, pin);
17355 if (!nid) {
17356 char name[32];
17357 /* the corresponding DAC is already occupied */
17358 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17359 return 0; /* no way */
17360 /* create a switch only */
Takashi Iwai24fb9172008-09-02 14:48:20 +020017361 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai7085ec12009-10-02 09:03:58 +020017362 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17363 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17364 }
17365
17366 mix = alc662_dac_to_mix(codec, pin, nid);
17367 if (!mix)
17368 return 0;
17369 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17370 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017371 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017372 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17373 if (err < 0)
17374 return err;
17375 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017376}
17377
17378/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017379#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017380 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017381
17382static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17383 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017384 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017385{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017386 int i, num;
17387 hda_nid_t srcs[4];
17388
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017389 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017390 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017391 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17392 if (num <= 1)
17393 return;
17394 for (i = 0; i < num; i++) {
17395 if (alc662_mix_to_dac(srcs[i]) != dac)
17396 continue;
17397 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17398 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017399 }
17400}
17401
17402static void alc662_auto_init_multi_out(struct hda_codec *codec)
17403{
17404 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017405 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017406 int i;
17407
17408 for (i = 0; i <= HDA_SIDE; i++) {
17409 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17410 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017411 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017412 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017413 }
17414}
17415
17416static void alc662_auto_init_hp_out(struct hda_codec *codec)
17417{
17418 struct alc_spec *spec = codec->spec;
17419 hda_nid_t pin;
17420
17421 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017422 if (pin)
17423 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17424 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017425 pin = spec->autocfg.speaker_pins[0];
17426 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017427 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17428 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017429}
17430
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017431#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17432
17433static void alc662_auto_init_analog_input(struct hda_codec *codec)
17434{
17435 struct alc_spec *spec = codec->spec;
17436 int i;
17437
17438 for (i = 0; i < AUTO_PIN_LAST; i++) {
17439 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017440 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017441 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017442 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017443 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017444 snd_hda_codec_write(codec, nid, 0,
17445 AC_VERB_SET_AMP_GAIN_MUTE,
17446 AMP_OUT_MUTE);
17447 }
17448 }
17449}
17450
Takashi Iwaif511b012008-08-15 16:46:42 +020017451#define alc662_auto_init_input_src alc882_auto_init_input_src
17452
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017453static int alc662_parse_auto_config(struct hda_codec *codec)
17454{
17455 struct alc_spec *spec = codec->spec;
17456 int err;
17457 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17458
17459 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17460 alc662_ignore);
17461 if (err < 0)
17462 return err;
17463 if (!spec->autocfg.line_outs)
17464 return 0; /* can't find valid BIOS pin config */
17465
Takashi Iwai7085ec12009-10-02 09:03:58 +020017466 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017467 if (err < 0)
17468 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017469 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017470 if (err < 0)
17471 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017472 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017473 spec->autocfg.speaker_pins[0],
17474 "Speaker");
17475 if (err < 0)
17476 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017477 if (err)
17478 spec->multiout.extra_out_nid[0] = err;
17479 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017480 "Headphone");
17481 if (err < 0)
17482 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017483 if (err)
17484 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017485 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017486 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017487 return err;
17488
17489 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17490
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017491 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017492 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17493
Takashi Iwai603c4012008-07-30 15:01:44 +020017494 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017495 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017496
17497 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017498 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017499
Takashi Iwaid88897e2008-10-31 15:01:37 +010017500 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017501 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017502 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017503
17504 err = alc_auto_add_mic_boost(codec);
17505 if (err < 0)
17506 return err;
17507
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017508 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17509
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017510 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017511}
17512
17513/* additional initialization for auto-configuration model */
17514static void alc662_auto_init(struct hda_codec *codec)
17515{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017516 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017517 alc662_auto_init_multi_out(codec);
17518 alc662_auto_init_hp_out(codec);
17519 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017520 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017521 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017522 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017523}
17524
17525static int patch_alc662(struct hda_codec *codec)
17526{
17527 struct alc_spec *spec;
17528 int err, board_config;
17529
17530 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17531 if (!spec)
17532 return -ENOMEM;
17533
17534 codec->spec = spec;
17535
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017536 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17537
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017538 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17539 alc662_models,
17540 alc662_cfg_tbl);
17541 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017542 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17543 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017544 board_config = ALC662_AUTO;
17545 }
17546
17547 if (board_config == ALC662_AUTO) {
17548 /* automatic parse from the BIOS config */
17549 err = alc662_parse_auto_config(codec);
17550 if (err < 0) {
17551 alc_free(codec);
17552 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017553 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017554 printk(KERN_INFO
17555 "hda_codec: Cannot set up configuration "
17556 "from BIOS. Using base mode...\n");
17557 board_config = ALC662_3ST_2ch_DIG;
17558 }
17559 }
17560
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017561 err = snd_hda_attach_beep_device(codec, 0x1);
17562 if (err < 0) {
17563 alc_free(codec);
17564 return err;
17565 }
17566
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017567 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017568 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017569
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017570 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17571 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17572
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017573 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17574 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17575
Takashi Iwaidd704692009-08-11 08:45:11 +020017576 if (!spec->adc_nids) {
17577 spec->adc_nids = alc662_adc_nids;
17578 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17579 }
17580 if (!spec->capsrc_nids)
17581 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017582
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017583 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017584 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017585 if (codec->vendor_id == 0x10ec0662)
17586 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17587 else
17588 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017589
Takashi Iwai2134ea42008-01-10 16:53:55 +010017590 spec->vmaster_nid = 0x02;
17591
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017592 codec->patch_ops = alc_patch_ops;
17593 if (board_config == ALC662_AUTO)
17594 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017595#ifdef CONFIG_SND_HDA_POWER_SAVE
17596 if (!spec->loopback.amplist)
17597 spec->loopback.amplist = alc662_loopbacks;
17598#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017599 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017600
17601 return 0;
17602}
17603
17604/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017605 * patch entries
17606 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017607static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017608 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017609 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017610 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017611 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017612 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017613 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017614 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017615 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017616 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17617 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17618 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017619 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017620 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017621 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17622 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017623 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017624 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017625 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017626 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017627 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017628 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017629 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017630 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017631 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017632 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017633 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017634 .patch = patch_alc882 },
17635 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17636 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017637 {} /* terminator */
17638};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017639
17640MODULE_ALIAS("snd-hda-codec-id:10ec*");
17641
17642MODULE_LICENSE("GPL");
17643MODULE_DESCRIPTION("Realtek HD-audio codec");
17644
17645static struct hda_codec_preset_list realtek_list = {
17646 .preset = snd_hda_preset_realtek,
17647 .owner = THIS_MODULE,
17648};
17649
17650static int __init patch_realtek_init(void)
17651{
17652 return snd_hda_add_codec_preset(&realtek_list);
17653}
17654
17655static void __exit patch_realtek_exit(void)
17656{
17657 snd_hda_delete_codec_preset(&realtek_list);
17658}
17659
17660module_init(patch_realtek_init)
17661module_exit(patch_realtek_exit)