blob: 33c6fafd358f1b5befcc79cdb33c1e7f79fc3f28 [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
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
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 Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010074 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010076 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020077 ALC260_WILL,
78 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010079#ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020083 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Kailang Yangdf694da2005-12-05 19:42:22 +010086/* ALC262 models */
87enum {
88 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020089 ALC262_HIPPO,
90 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010091 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020092 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010093 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020095 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020096 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020097 ALC262_BENQ_T31,
Kailang Yangdf694da2005-12-05 19:42:22 +010098 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */
100};
101
Kailang Yanga361d842007-06-05 12:30:55 +0200102/* ALC268 models */
103enum {
104 ALC268_3ST,
105 ALC268_AUTO,
106 ALC268_MODEL_LAST /* last tag */
107};
108
Kailang Yangdf694da2005-12-05 19:42:22 +0100109/* ALC861 models */
110enum {
111 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200112 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100113 ALC861_3ST_DIG,
114 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200115 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200116 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200117 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100118 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100119 ALC861_AUTO,
120 ALC861_MODEL_LAST,
121};
122
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100123/* ALC861-VD models */
124enum {
125 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200126 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100127 ALC861VD_3ST,
128 ALC861VD_3ST_DIG,
129 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200130 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200131 ALC861VD_DALLAS,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100132 ALC861VD_AUTO,
133 ALC861VD_MODEL_LAST,
134};
135
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200136/* ALC662 models */
137enum {
138 ALC662_3ST_2ch_DIG,
139 ALC662_3ST_6ch_DIG,
140 ALC662_3ST_6ch,
141 ALC662_5ST_DIG,
142 ALC662_LENOVO_101E,
143 ALC662_AUTO,
144 ALC662_MODEL_LAST,
145};
146
Kailang Yangdf694da2005-12-05 19:42:22 +0100147/* ALC882 models */
148enum {
149 ALC882_3ST_DIG,
150 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200151 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200152 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200153 ALC882_TARGA,
154 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100155 ALC885_MACPRO,
Kailang Yang272a5272007-05-14 11:00:38 +0200156 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100157 ALC882_MODEL_LAST,
158};
159
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200160/* ALC883 models */
161enum {
162 ALC883_3ST_2ch_DIG,
163 ALC883_3ST_6ch_DIG,
164 ALC883_3ST_6ch,
165 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200166 ALC883_TARGA_DIG,
167 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200168 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200169 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200170 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100171 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200172 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200173 ALC883_LENOVO_NB0763,
174 ALC888_LENOVO_MS7195_DIG,
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +0200175 ALC888_HP_NETTLE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200176 ALC883_AUTO,
177 ALC883_MODEL_LAST,
178};
179
Kailang Yangdf694da2005-12-05 19:42:22 +0100180/* for GPIO Poll */
181#define GPIO_MASK 0x03
182
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183struct alc_spec {
184 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100185 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 unsigned int num_mixers;
187
Kailang Yangdf694da2005-12-05 19:42:22 +0100188 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200189 * don't forget NULL
190 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200191 */
192 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
Takashi Iwai16ded522005-06-10 19:58:24 +0200194 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 struct hda_pcm_stream *stream_analog_playback;
196 struct hda_pcm_stream *stream_analog_capture;
197
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200198 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 struct hda_pcm_stream *stream_digital_playback;
200 struct hda_pcm_stream *stream_digital_capture;
201
202 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200203 struct hda_multi_out multiout; /* playback set-up
204 * max_channels, dacs must be set
205 * dig_out_nid and hp_nid are optional
206 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208 /* capture */
209 unsigned int num_adc_nids;
210 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200211 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
213 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200214 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 const struct hda_input_mux *input_mux;
216 unsigned int cur_mux[3];
217
218 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100219 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200221 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100224 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200225
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200226 /* dynamic controls, init_verbs and input_mux */
227 struct auto_pin_cfg autocfg;
228 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100229 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200230 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100231 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100232
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100233 /* hooks */
234 void (*init_hook)(struct hda_codec *codec);
235 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
236
Takashi Iwai834be882006-03-01 14:16:17 +0100237 /* for pin sensing */
238 unsigned int sense_updated: 1;
239 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100240};
241
242/*
243 * configuration template - to be copied to the spec instance
244 */
245struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200246 struct snd_kcontrol_new *mixers[5]; /* should be identical size
247 * with spec
248 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100249 const struct hda_verb *init_verbs[5];
250 unsigned int num_dacs;
251 hda_nid_t *dac_nids;
252 hda_nid_t dig_out_nid; /* optional */
253 hda_nid_t hp_nid; /* optional */
254 unsigned int num_adc_nids;
255 hda_nid_t *adc_nids;
256 hda_nid_t dig_in_nid;
257 unsigned int num_channel_mode;
258 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200259 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200260 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100261 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100262 void (*unsol_event)(struct hda_codec *, unsigned int);
263 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264};
265
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
267/*
268 * input MUX handling
269 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200270static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
271 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272{
273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
274 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200275 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
276 if (mux_idx >= spec->num_mux_defs)
277 mux_idx = 0;
278 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279}
280
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200281static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
282 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283{
284 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
285 struct alc_spec *spec = codec->spec;
286 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
287
288 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
289 return 0;
290}
291
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200292static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
293 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294{
295 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
296 struct alc_spec *spec = codec->spec;
297 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200298 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
299 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200300 spec->adc_nids[adc_idx],
301 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302}
303
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305/*
306 * channel mode setting
307 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200308static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
309 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310{
311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
312 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100313 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
314 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315}
316
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200317static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
318 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319{
320 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
321 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100322 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200323 spec->num_channel_mode,
324 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325}
326
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200327static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
328 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329{
330 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
331 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200332 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
333 spec->num_channel_mode,
334 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200335 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200336 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
337 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338}
339
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100341 * Control the mode of pin widget settings via the mixer. "pc" is used
342 * instead of "%" to avoid consequences of accidently treating the % as
343 * being part of a format specifier. Maximum allowed length of a value is
344 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100345 *
346 * Note: some retasking pin complexes seem to ignore requests for input
347 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
348 * are requested. Therefore order this list so that this behaviour will not
349 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200350 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
351 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200352 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100353static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100354 "Mic 50pc bias", "Mic 80pc bias",
355 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356};
357static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100358 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100359};
360/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200361 * in the pin being assumed to be exclusively an input or an output pin. In
362 * addition, "input" pins may or may not process the mic bias option
363 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
364 * accept requests for bias as of chip versions up to March 2006) and/or
365 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100366 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200367#define ALC_PIN_DIR_IN 0x00
368#define ALC_PIN_DIR_OUT 0x01
369#define ALC_PIN_DIR_INOUT 0x02
370#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
371#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100372
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200373/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374 * For each direction the minimum and maximum values are given.
375 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200376static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100377 { 0, 2 }, /* ALC_PIN_DIR_IN */
378 { 3, 4 }, /* ALC_PIN_DIR_OUT */
379 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200380 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
381 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100382};
383#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
384#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
385#define alc_pin_mode_n_items(_dir) \
386 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
387
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200388static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
389 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200390{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100391 unsigned int item_num = uinfo->value.enumerated.item;
392 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
393
394 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200395 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100396 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
397
398 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
399 item_num = alc_pin_mode_min(dir);
400 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200401 return 0;
402}
403
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200404static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
405 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200406{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100407 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
409 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100410 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200411 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200412 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
413 AC_VERB_GET_PIN_WIDGET_CONTROL,
414 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200415
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416 /* Find enumerated value for current pinctl setting */
417 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200418 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100419 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100421 return 0;
422}
423
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200424static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100426{
427 signed int change;
428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
429 hda_nid_t nid = kcontrol->private_value & 0xffff;
430 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
431 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200432 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
433 AC_VERB_GET_PIN_WIDGET_CONTROL,
434 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200436 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437 val = alc_pin_mode_min(dir);
438
439 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100440 if (change) {
441 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200442 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100444
445 /* Also enable the retasking pin's input/output as required
446 * for the requested pin mode. Enum values of 2 or less are
447 * input modes.
448 *
449 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200450 * reduces noise slightly (particularly on input) so we'll
451 * do it. However, having both input and output buffers
452 * enabled simultaneously doesn't seem to be problematic if
453 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100454 */
455 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456 snd_hda_codec_write(codec, nid, 0,
457 AC_VERB_SET_AMP_GAIN_MUTE,
458 AMP_OUT_MUTE);
459 snd_hda_codec_write(codec, nid, 0,
460 AC_VERB_SET_AMP_GAIN_MUTE,
461 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100462 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200463 snd_hda_codec_write(codec, nid, 0,
464 AC_VERB_SET_AMP_GAIN_MUTE,
465 AMP_IN_MUTE(0));
466 snd_hda_codec_write(codec, nid, 0,
467 AC_VERB_SET_AMP_GAIN_MUTE,
468 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100469 }
470 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200471 return change;
472}
473
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200475 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476 .info = alc_pin_mode_info, \
477 .get = alc_pin_mode_get, \
478 .put = alc_pin_mode_put, \
479 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100480
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100481/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
482 * together using a mask with more than one bit set. This control is
483 * currently used only by the ALC260 test model. At this stage they are not
484 * needed for any "production" models.
485 */
486#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100489{
490 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
491 uinfo->count = 1;
492 uinfo->value.integer.min = 0;
493 uinfo->value.integer.max = 1;
494 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200495}
496
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200497static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
498 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100499{
500 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
501 hda_nid_t nid = kcontrol->private_value & 0xffff;
502 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
503 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200504 unsigned int val = snd_hda_codec_read(codec, nid, 0,
505 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100506
507 *valp = (val & mask) != 0;
508 return 0;
509}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200510static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
511 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100512{
513 signed int change;
514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
515 hda_nid_t nid = kcontrol->private_value & 0xffff;
516 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
517 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200518 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
519 AC_VERB_GET_GPIO_DATA,
520 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100521
522 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
524 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100525 gpio_data &= ~mask;
526 else
527 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200528 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100529
530 return change;
531}
532#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
533 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
534 .info = alc_gpio_data_info, \
535 .get = alc_gpio_data_get, \
536 .put = alc_gpio_data_put, \
537 .private_value = nid | (mask<<16) }
538#endif /* CONFIG_SND_DEBUG */
539
Jonathan Woithe92621f12006-02-28 11:47:47 +0100540/* A switch control to allow the enabling of the digital IO pins on the
541 * ALC260. This is incredibly simplistic; the intention of this control is
542 * to provide something in the test model allowing digital outputs to be
543 * identified if present. If models are found which can utilise these
544 * outputs a more complete mixer control can be devised for those models if
545 * necessary.
546 */
547#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200548static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100550{
551 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
552 uinfo->count = 1;
553 uinfo->value.integer.min = 0;
554 uinfo->value.integer.max = 1;
555 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200556}
557
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100560{
561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 hda_nid_t nid = kcontrol->private_value & 0xffff;
563 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
564 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200565 unsigned int val = snd_hda_codec_read(codec, nid, 0,
566 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100567
568 *valp = (val & mask) != 0;
569 return 0;
570}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
572 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100573{
574 signed int change;
575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
576 hda_nid_t nid = kcontrol->private_value & 0xffff;
577 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
578 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
580 AC_VERB_GET_DIGI_CONVERT,
581 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100582
583 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200584 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100585 if (val==0)
586 ctrl_data &= ~mask;
587 else
588 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200589 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
590 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100591
592 return change;
593}
594#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
595 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
596 .info = alc_spdif_ctrl_info, \
597 .get = alc_spdif_ctrl_get, \
598 .put = alc_spdif_ctrl_put, \
599 .private_value = nid | (mask<<16) }
600#endif /* CONFIG_SND_DEBUG */
601
Kailang Yangdf694da2005-12-05 19:42:22 +0100602/*
603 * set up from the preset table
604 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605static void setup_preset(struct alc_spec *spec,
606 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100607{
608 int i;
609
610 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
611 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200612 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
613 i++)
614 spec->init_verbs[spec->num_init_verbs++] =
615 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100616
617 spec->channel_mode = preset->channel_mode;
618 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200619 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100620
621 spec->multiout.max_channels = spec->channel_mode[0].channels;
622
623 spec->multiout.num_dacs = preset->num_dacs;
624 spec->multiout.dac_nids = preset->dac_nids;
625 spec->multiout.dig_out_nid = preset->dig_out_nid;
626 spec->multiout.hp_nid = preset->hp_nid;
627
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200628 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200629 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200630 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100631 spec->input_mux = preset->input_mux;
632
633 spec->num_adc_nids = preset->num_adc_nids;
634 spec->adc_nids = preset->adc_nids;
635 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100636
637 spec->unsol_event = preset->unsol_event;
638 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100639}
640
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200641/* Enable GPIO mask and set output */
642static struct hda_verb alc_gpio1_init_verbs[] = {
643 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
644 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
645 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
646 { }
647};
648
649static struct hda_verb alc_gpio2_init_verbs[] = {
650 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
651 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
652 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
653 { }
654};
655
Kailang Yangbdd148a2007-05-08 15:19:08 +0200656static struct hda_verb alc_gpio3_init_verbs[] = {
657 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
658 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
659 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
660 { }
661};
662
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200663/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
664 * 31 ~ 16 : Manufacture ID
665 * 15 ~ 8 : SKU ID
666 * 7 ~ 0 : Assembly ID
667 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
668 */
669static void alc_subsystem_id(struct hda_codec *codec,
670 unsigned int porta, unsigned int porte,
671 unsigned int portd)
672{
673 unsigned int ass, tmp;
674
675 ass = codec->subsystem_id;
676 if (!(ass & 1))
677 return;
678
679 /* Override */
680 tmp = (ass & 0x38) >> 3; /* external Amp control */
681 switch (tmp) {
682 case 1:
683 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
684 break;
685 case 3:
686 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
687 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200688 case 7:
689 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
690 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200691 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200692 switch (codec->vendor_id) {
693 case 0x10ec0862:
694 case 0x10ec0660:
695 case 0x10ec0662:
696 case 0x10ec0267:
697 case 0x10ec0268:
698 snd_hda_codec_write(codec, 0x14, 0,
699 AC_VERB_SET_EAPD_BTLENABLE, 2);
700 snd_hda_codec_write(codec, 0x15, 0,
701 AC_VERB_SET_EAPD_BTLENABLE, 2);
702 return;
703 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200704 case 6:
705 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
706 hda_nid_t port = 0;
707 tmp = (ass & 0x1800) >> 11;
708 switch (tmp) {
709 case 0: port = porta; break;
710 case 1: port = porte; break;
711 case 2: port = portd; break;
712 }
713 if (port)
714 snd_hda_codec_write(codec, port, 0,
715 AC_VERB_SET_EAPD_BTLENABLE,
716 2);
717 }
718 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
719 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
720 (tmp == 5 ? 0x3040 : 0x3050));
721 break;
722 }
723}
724
Takashi Iwai41e41f12005-06-08 14:48:49 +0200725/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200726 * ALC880 3-stack model
727 *
728 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200729 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
730 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 */
732
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200733static hda_nid_t alc880_dac_nids[4] = {
734 /* front, rear, clfe, rear_surr */
735 0x02, 0x05, 0x04, 0x03
736};
737
738static hda_nid_t alc880_adc_nids[3] = {
739 /* ADC0-2 */
740 0x07, 0x08, 0x09,
741};
742
743/* The datasheet says the node 0x07 is connected from inputs,
744 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100745 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200747static hda_nid_t alc880_adc_nids_alt[2] = {
748 /* ADC1-2 */
749 0x08, 0x09,
750};
751
752#define ALC880_DIGOUT_NID 0x06
753#define ALC880_DIGIN_NID 0x0a
754
755static struct hda_input_mux alc880_capture_source = {
756 .num_items = 4,
757 .items = {
758 { "Mic", 0x0 },
759 { "Front Mic", 0x3 },
760 { "Line", 0x2 },
761 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200763};
764
765/* channel source setting (2/6 channel selection for 3-stack) */
766/* 2ch mode */
767static struct hda_verb alc880_threestack_ch2_init[] = {
768 /* set line-in to input, mute it */
769 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
770 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
771 /* set mic-in to input vref 80%, mute it */
772 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
773 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 { } /* end */
775};
776
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200777/* 6ch mode */
778static struct hda_verb alc880_threestack_ch6_init[] = {
779 /* set line-in to output, unmute it */
780 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
781 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
782 /* set mic-in to output, unmute it */
783 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
784 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
785 { } /* end */
786};
787
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100788static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200789 { 2, alc880_threestack_ch2_init },
790 { 6, alc880_threestack_ch6_init },
791};
792
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100793static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100795 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200796 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100797 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200798 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
799 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100800 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
801 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
803 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
808 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
809 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
810 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
811 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200813 {
814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
815 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100816 .info = alc_ch_mode_info,
817 .get = alc_ch_mode_get,
818 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200819 },
820 { } /* end */
821};
822
823/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100824static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200825 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
826 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
827 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
828 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
829 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
830 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
831 {
832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
833 /* The multiple "Capture Source" controls confuse alsamixer
834 * So call somewhat different..
835 * FIXME: the controls appear in the "playback" view!
836 */
837 /* .name = "Capture Source", */
838 .name = "Input Source",
839 .count = 3,
840 .info = alc_mux_enum_info,
841 .get = alc_mux_enum_get,
842 .put = alc_mux_enum_put,
843 },
844 { } /* end */
845};
846
847/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100848static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200849 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
850 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
851 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
852 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 {
854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
855 /* The multiple "Capture Source" controls confuse alsamixer
856 * So call somewhat different..
857 * FIXME: the controls appear in the "playback" view!
858 */
859 /* .name = "Capture Source", */
860 .name = "Input Source",
861 .count = 2,
862 .info = alc_mux_enum_info,
863 .get = alc_mux_enum_get,
864 .put = alc_mux_enum_put,
865 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 { } /* end */
867};
868
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200869
870
871/*
872 * ALC880 5-stack model
873 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200874 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
875 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200876 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
877 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
878 */
879
880/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100881static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200882 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100883 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 { } /* end */
885};
886
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200887/* channel source setting (6/8 channel selection for 5-stack) */
888/* 6ch mode */
889static struct hda_verb alc880_fivestack_ch6_init[] = {
890 /* set line-in to input, mute it */
891 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
892 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200893 { } /* end */
894};
895
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200896/* 8ch mode */
897static struct hda_verb alc880_fivestack_ch8_init[] = {
898 /* set line-in to output, unmute it */
899 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
900 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
901 { } /* end */
902};
903
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100904static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200905 { 6, alc880_fivestack_ch6_init },
906 { 8, alc880_fivestack_ch8_init },
907};
908
909
910/*
911 * ALC880 6-stack model
912 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200913 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
914 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200915 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
916 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
917 */
918
919static hda_nid_t alc880_6st_dac_nids[4] = {
920 /* front, rear, clfe, rear_surr */
921 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200922};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200923
924static struct hda_input_mux alc880_6stack_capture_source = {
925 .num_items = 4,
926 .items = {
927 { "Mic", 0x0 },
928 { "Front Mic", 0x1 },
929 { "Line", 0x2 },
930 { "CD", 0x4 },
931 },
932};
933
934/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100935static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200936 { 8, NULL },
937};
938
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100939static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200940 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100941 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200942 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100943 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200944 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
945 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100946 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
947 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200948 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100949 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
957 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
958 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
959 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200960 {
961 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
962 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100963 .info = alc_ch_mode_info,
964 .get = alc_ch_mode_get,
965 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200966 },
967 { } /* end */
968};
969
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200970
971/*
972 * ALC880 W810 model
973 *
974 * W810 has rear IO for:
975 * Front (DAC 02)
976 * Surround (DAC 03)
977 * Center/LFE (DAC 04)
978 * Digital out (06)
979 *
980 * The system also has a pair of internal speakers, and a headphone jack.
981 * These are both connected to Line2 on the codec, hence to DAC 02.
982 *
983 * There is a variable resistor to control the speaker or headphone
984 * volume. This is a hardware-only device without a software API.
985 *
986 * Plugging headphones in will disable the internal speakers. This is
987 * implemented in hardware, not via the driver using jack sense. In
988 * a similar fashion, plugging into the rear socket marked "front" will
989 * disable both the speakers and headphones.
990 *
991 * For input, there's a microphone jack, and an "audio in" jack.
992 * These may not do anything useful with this driver yet, because I
993 * haven't setup any initialization verbs for these yet...
994 */
995
996static hda_nid_t alc880_w810_dac_nids[3] = {
997 /* front, rear/surround, clfe */
998 0x02, 0x03, 0x04
999};
1000
1001/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001002static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001003 { 6, NULL }
1004};
1005
1006/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001007static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001008 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001009 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001010 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001011 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001012 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1013 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001014 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1015 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1017 { } /* end */
1018};
1019
1020
1021/*
1022 * Z710V model
1023 *
1024 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001025 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1026 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001027 */
1028
1029static hda_nid_t alc880_z71v_dac_nids[1] = {
1030 0x02
1031};
1032#define ALC880_Z71V_HP_DAC 0x03
1033
1034/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001035static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001036 { 2, NULL }
1037};
1038
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001039static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001040 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001041 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001042 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001043 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001044 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1045 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1048 { } /* end */
1049};
1050
1051
1052/* FIXME! */
1053/*
1054 * ALC880 F1734 model
1055 *
1056 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1057 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1058 */
1059
1060static hda_nid_t alc880_f1734_dac_nids[1] = {
1061 0x03
1062};
1063#define ALC880_F1734_HP_DAC 0x02
1064
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001065static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001066 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001067 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001068 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001069 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001074 { } /* end */
1075};
1076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001077
1078/* FIXME! */
1079/*
1080 * ALC880 ASUS model
1081 *
1082 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1083 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1084 * Mic = 0x18, Line = 0x1a
1085 */
1086
1087#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1088#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1089
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001090static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001093 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001094 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001095 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1096 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001097 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1098 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001099 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1100 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1104 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001105 {
1106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1107 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001108 .info = alc_ch_mode_info,
1109 .get = alc_ch_mode_get,
1110 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001111 },
1112 { } /* end */
1113};
1114
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001115/* FIXME! */
1116/*
1117 * ALC880 ASUS W1V model
1118 *
1119 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1120 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1121 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1122 */
1123
1124/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001125static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001126 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1127 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001128 { } /* end */
1129};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001130
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001131/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001132static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001133 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1134 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1135 { } /* end */
1136};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001137
Kailang Yangdf694da2005-12-05 19:42:22 +01001138/* TCL S700 */
1139static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1140 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1142 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1144 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1147 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1148 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1149 {
1150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1151 /* The multiple "Capture Source" controls confuse alsamixer
1152 * So call somewhat different..
1153 * FIXME: the controls appear in the "playback" view!
1154 */
1155 /* .name = "Capture Source", */
1156 .name = "Input Source",
1157 .count = 1,
1158 .info = alc_mux_enum_info,
1159 .get = alc_mux_enum_get,
1160 .put = alc_mux_enum_put,
1161 },
1162 { } /* end */
1163};
1164
Kailang Yangccc656c2006-10-17 12:32:26 +02001165/* Uniwill */
1166static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1167 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1168 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1169 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1170 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1171 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1172 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1173 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1174 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1175 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1176 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1178 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1181 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1182 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1183 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1184 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1185 {
1186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1187 .name = "Channel Mode",
1188 .info = alc_ch_mode_info,
1189 .get = alc_ch_mode_get,
1190 .put = alc_ch_mode_put,
1191 },
1192 { } /* end */
1193};
1194
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001195static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1196 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1197 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1198 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1199 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1200 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1201 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1203 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1205 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1206 { } /* end */
1207};
1208
Kailang Yangccc656c2006-10-17 12:32:26 +02001209static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1210 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1211 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1212 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1213 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1216 { } /* end */
1217};
1218
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001220 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 */
1222static int alc_build_controls(struct hda_codec *codec)
1223{
1224 struct alc_spec *spec = codec->spec;
1225 int err;
1226 int i;
1227
1228 for (i = 0; i < spec->num_mixers; i++) {
1229 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1230 if (err < 0)
1231 return err;
1232 }
1233
1234 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001235 err = snd_hda_create_spdif_out_ctls(codec,
1236 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237 if (err < 0)
1238 return err;
1239 }
1240 if (spec->dig_in_nid) {
1241 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1242 if (err < 0)
1243 return err;
1244 }
1245 return 0;
1246}
1247
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001248
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249/*
1250 * initialize the codec volumes, etc
1251 */
1252
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001253/*
1254 * generic initialization of ADC, input mixers and output mixers
1255 */
1256static struct hda_verb alc880_volume_init_verbs[] = {
1257 /*
1258 * Unmute ADC0-2 and set the default input to mic-in
1259 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001260 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001262 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001264 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001267 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1268 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001269 * Note: PASD motherboards uses the Line In 2 as the input for front
1270 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001272 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001279 /*
1280 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001282 /* set vol=0 to output mixers */
1283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1286 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1287 /* set up input amps for analog loopback */
1288 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001291 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1292 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1296 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297
1298 { }
1299};
1300
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001301/*
1302 * 3-stack pin configuration:
1303 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1304 */
1305static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1306 /*
1307 * preset connection lists of input pins
1308 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1309 */
1310 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1311 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1312 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1313
1314 /*
1315 * Set pin mode and muting
1316 */
1317 /* set front pin widgets 0x14 for output */
1318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1319 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1320 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1321 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1322 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1323 /* Mic2 (as headphone out) for HP output */
1324 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1325 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1326 /* Line In pin widget for input */
1327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1328 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1329 /* Line2 (as front mic) pin widget for input and vref at 80% */
1330 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1331 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1332 /* CD pin widget for input */
1333 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1334
1335 { }
1336};
1337
1338/*
1339 * 5-stack pin configuration:
1340 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1341 * line-in/side = 0x1a, f-mic = 0x1b
1342 */
1343static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1344 /*
1345 * preset connection lists of input pins
1346 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1347 */
1348 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1349 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1350
1351 /*
1352 * Set pin mode and muting
1353 */
1354 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1357 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1358 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001359 /* unmute pins for output (no gain on this amp) */
1360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1362 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1363 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1364
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001366 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001367 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1368 /* Mic2 (as headphone out) for HP output */
1369 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001370 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001371 /* Line In pin widget for input */
1372 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1373 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1374 /* Line2 (as front mic) pin widget for input and vref at 80% */
1375 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1376 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1377 /* CD pin widget for input */
1378 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379
1380 { }
1381};
1382
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001383/*
1384 * W810 pin configuration:
1385 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1386 */
1387static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 /* hphone/speaker input selector: front DAC */
1389 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1390
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001391 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1393 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1394 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1396 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397
1398 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001399 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 { }
1402};
1403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001404/*
1405 * Z71V pin configuration:
1406 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1407 */
1408static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001409 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001410 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001411 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001413
Takashi Iwai16ded522005-06-10 19:58:24 +02001414 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001415 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001416 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001417 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001418
1419 { }
1420};
1421
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001422/*
1423 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001424 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1425 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001426 */
1427static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1428 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1429
Takashi Iwai16ded522005-06-10 19:58:24 +02001430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001431 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001432 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001433 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001434 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001435 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001436 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001437 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1438
Takashi Iwai16ded522005-06-10 19:58:24 +02001439 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001440 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001441 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001442 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001443 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001444 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001445 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001446 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001447 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1448
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001449 { }
1450};
Takashi Iwai16ded522005-06-10 19:58:24 +02001451
Kailang Yangccc656c2006-10-17 12:32:26 +02001452/*
1453 * Uniwill pin configuration:
1454 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1455 * line = 0x1a
1456 */
1457static struct hda_verb alc880_uniwill_init_verbs[] = {
1458 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1459
1460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1463 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1465 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1474
1475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1476 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1478 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1479 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1480 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1481 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1482 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1483 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1484
1485 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1486 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1487
1488 { }
1489};
1490
1491/*
1492* Uniwill P53
1493* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1494 */
1495static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1496 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1497
1498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1503 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1509 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1510
1511 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1515 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1516 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1517
1518 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1519 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1520
1521 { }
1522};
1523
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001524static struct hda_verb alc880_beep_init_verbs[] = {
1525 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1526 { }
1527};
1528
Kailang Yangccc656c2006-10-17 12:32:26 +02001529/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001530static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001531{
1532 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001533 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001534
1535 present = snd_hda_codec_read(codec, 0x14, 0,
1536 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001537 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001538 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001539 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001540 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001541 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001542 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001543 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001544 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001545 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001546}
1547
1548/* auto-toggle front mic */
1549static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1550{
1551 unsigned int present;
1552 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001553
1554 present = snd_hda_codec_read(codec, 0x18, 0,
1555 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001556 bits = present ? 0x80 : 0;
1557 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1558 0x80, bits);
1559 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1560 0x80, bits);
1561}
1562
1563static void alc880_uniwill_automute(struct hda_codec *codec)
1564{
1565 alc880_uniwill_hp_automute(codec);
1566 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001567}
1568
1569static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1570 unsigned int res)
1571{
1572 /* Looks like the unsol event is incompatible with the standard
1573 * definition. 4bit tag is placed at 28 bit!
1574 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001575 switch (res >> 28) {
1576 case ALC880_HP_EVENT:
1577 alc880_uniwill_hp_automute(codec);
1578 break;
1579 case ALC880_MIC_EVENT:
1580 alc880_uniwill_mic_automute(codec);
1581 break;
1582 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001583}
1584
1585static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1586{
1587 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001588 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001589
1590 present = snd_hda_codec_read(codec, 0x14, 0,
1591 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001592 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001593 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001594 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001595 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001596 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001597}
1598
1599static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1600{
1601 unsigned int present;
1602
1603 present = snd_hda_codec_read(codec, 0x21, 0,
1604 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1605
1606 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1607 0x7f, present);
1608 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1609 0x7f, present);
1610
1611 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1612 0x7f, present);
1613 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1614 0x7f, present);
1615
1616}
1617static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1618 unsigned int res)
1619{
1620 /* Looks like the unsol event is incompatible with the standard
1621 * definition. 4bit tag is placed at 28 bit!
1622 */
1623 if ((res >> 28) == ALC880_HP_EVENT)
1624 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001625 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001626 alc880_uniwill_p53_dcvol_automute(codec);
1627}
1628
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001629/* FIXME! */
1630/*
1631 * F1734 pin configuration:
1632 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1633 */
1634static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1635 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1636 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1637 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1638 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1639
1640 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1641 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1644
1645 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1647 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1648 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1649 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1650 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1651 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1652 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1653 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001654
1655 { }
1656};
1657
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658/* FIXME! */
1659/*
1660 * ASUS pin configuration:
1661 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1662 */
1663static struct hda_verb alc880_pin_asus_init_verbs[] = {
1664 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1665 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1666 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1667 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1668
1669 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1670 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1671 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1673 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1675 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1676 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1677
1678 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1679 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1680 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1682 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1684 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1685 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1686 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1687
1688 { }
1689};
1690
1691/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001692#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1693#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001694
Kailang Yangdf694da2005-12-05 19:42:22 +01001695/* Clevo m520g init */
1696static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1697 /* headphone output */
1698 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1699 /* line-out */
1700 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1702 /* Line-in */
1703 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1704 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 /* CD */
1706 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1707 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1708 /* Mic1 (rear panel) */
1709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1710 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1711 /* Mic2 (front panel) */
1712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1713 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1714 /* headphone */
1715 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1716 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1717 /* change to EAPD mode */
1718 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1719 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1720
1721 { }
1722};
1723
1724static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001725 /* change to EAPD mode */
1726 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1727 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1728
Kailang Yangdf694da2005-12-05 19:42:22 +01001729 /* Headphone output */
1730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1731 /* Front output*/
1732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1733 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1734
1735 /* Line In pin widget for input */
1736 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1737 /* CD pin widget for input */
1738 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1739 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1741
1742 /* change to EAPD mode */
1743 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1744 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1745
1746 { }
1747};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001748
1749/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001750 * LG m1 express dual
1751 *
1752 * Pin assignment:
1753 * Rear Line-In/Out (blue): 0x14
1754 * Build-in Mic-In: 0x15
1755 * Speaker-out: 0x17
1756 * HP-Out (green): 0x1b
1757 * Mic-In/Out (red): 0x19
1758 * SPDIF-Out: 0x1e
1759 */
1760
1761/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1762static hda_nid_t alc880_lg_dac_nids[3] = {
1763 0x05, 0x02, 0x03
1764};
1765
1766/* seems analog CD is not working */
1767static struct hda_input_mux alc880_lg_capture_source = {
1768 .num_items = 3,
1769 .items = {
1770 { "Mic", 0x1 },
1771 { "Line", 0x5 },
1772 { "Internal Mic", 0x6 },
1773 },
1774};
1775
1776/* 2,4,6 channel modes */
1777static struct hda_verb alc880_lg_ch2_init[] = {
1778 /* set line-in and mic-in to input */
1779 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1780 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1781 { }
1782};
1783
1784static struct hda_verb alc880_lg_ch4_init[] = {
1785 /* set line-in to out and mic-in to input */
1786 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1787 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1788 { }
1789};
1790
1791static struct hda_verb alc880_lg_ch6_init[] = {
1792 /* set line-in and mic-in to output */
1793 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1794 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1795 { }
1796};
1797
1798static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1799 { 2, alc880_lg_ch2_init },
1800 { 4, alc880_lg_ch4_init },
1801 { 6, alc880_lg_ch6_init },
1802};
1803
1804static struct snd_kcontrol_new alc880_lg_mixer[] = {
1805 /* FIXME: it's not really "master" but front channels */
1806 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1807 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1808 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1809 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1810 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1811 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1812 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1813 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1818 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1819 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1820 {
1821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1822 .name = "Channel Mode",
1823 .info = alc_ch_mode_info,
1824 .get = alc_ch_mode_get,
1825 .put = alc_ch_mode_put,
1826 },
1827 { } /* end */
1828};
1829
1830static struct hda_verb alc880_lg_init_verbs[] = {
1831 /* set capture source to mic-in */
1832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1833 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1834 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1835 /* mute all amp mixer inputs */
1836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1839 /* line-in to input */
1840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1842 /* built-in mic */
1843 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1845 /* speaker-out */
1846 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1848 /* mic-in to input */
1849 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1850 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1852 /* HP-out */
1853 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1854 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1855 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1856 /* jack sense */
1857 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1858 { }
1859};
1860
1861/* toggle speaker-output according to the hp-jack state */
1862static void alc880_lg_automute(struct hda_codec *codec)
1863{
1864 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001865 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001866
1867 present = snd_hda_codec_read(codec, 0x1b, 0,
1868 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001869 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001870 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001871 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001872 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001873 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001874}
1875
1876static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1877{
1878 /* Looks like the unsol event is incompatible with the standard
1879 * definition. 4bit tag is placed at 28 bit!
1880 */
1881 if ((res >> 28) == 0x01)
1882 alc880_lg_automute(codec);
1883}
1884
1885/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001886 * LG LW20
1887 *
1888 * Pin assignment:
1889 * Speaker-out: 0x14
1890 * Mic-In: 0x18
1891 * Built-in Mic-In: 0x19 (?)
1892 * HP-Out: 0x1b
1893 * SPDIF-Out: 0x1e
1894 */
1895
1896/* seems analog CD is not working */
1897static struct hda_input_mux alc880_lg_lw_capture_source = {
1898 .num_items = 2,
1899 .items = {
1900 { "Mic", 0x0 },
1901 { "Internal Mic", 0x1 },
1902 },
1903};
1904
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001905#define alc880_lg_lw_modes alc880_threestack_modes
1906
Takashi Iwaid6815182006-03-23 16:06:23 +01001907static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001908 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1909 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1910 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1911 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1912 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1913 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1914 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1915 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1916 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1917 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001918 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1920 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1921 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001922 {
1923 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1924 .name = "Channel Mode",
1925 .info = alc_ch_mode_info,
1926 .get = alc_ch_mode_get,
1927 .put = alc_ch_mode_put,
1928 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001929 { } /* end */
1930};
1931
1932static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001933 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1934 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1935 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1936
Takashi Iwaid6815182006-03-23 16:06:23 +01001937 /* set capture source to mic-in */
1938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1939 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1940 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1942 /* speaker-out */
1943 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1944 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1945 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001946 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1947 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1948 /* mic-in to input */
1949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1951 /* built-in mic */
1952 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1953 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1954 /* jack sense */
1955 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1956 { }
1957};
1958
1959/* toggle speaker-output according to the hp-jack state */
1960static void alc880_lg_lw_automute(struct hda_codec *codec)
1961{
1962 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001963 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001964
1965 present = snd_hda_codec_read(codec, 0x1b, 0,
1966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001967 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001968 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001969 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001970 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001971 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001972}
1973
1974static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1975{
1976 /* Looks like the unsol event is incompatible with the standard
1977 * definition. 4bit tag is placed at 28 bit!
1978 */
1979 if ((res >> 28) == 0x01)
1980 alc880_lg_lw_automute(codec);
1981}
1982
1983/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001984 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001985 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001986
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987static int alc_init(struct hda_codec *codec)
1988{
1989 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001990 unsigned int i;
1991
1992 for (i = 0; i < spec->num_init_verbs; i++)
1993 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001994
1995 if (spec->init_hook)
1996 spec->init_hook(codec);
1997
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998 return 0;
1999}
2000
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002001static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2002{
2003 struct alc_spec *spec = codec->spec;
2004
2005 if (spec->unsol_event)
2006 spec->unsol_event(codec, res);
2007}
2008
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009#ifdef CONFIG_PM
2010/*
2011 * resume
2012 */
2013static int alc_resume(struct hda_codec *codec)
2014{
2015 struct alc_spec *spec = codec->spec;
2016 int i;
2017
2018 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002019 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002021 if (spec->multiout.dig_out_nid)
2022 snd_hda_resume_spdif_out(codec);
2023 if (spec->dig_in_nid)
2024 snd_hda_resume_spdif_in(codec);
2025
2026 return 0;
2027}
2028#endif
2029
2030/*
2031 * Analog playback callbacks
2032 */
2033static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2034 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002035 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036{
2037 struct alc_spec *spec = codec->spec;
2038 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2039}
2040
2041static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2042 struct hda_codec *codec,
2043 unsigned int stream_tag,
2044 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002045 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046{
2047 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002048 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2049 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050}
2051
2052static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2053 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002054 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055{
2056 struct alc_spec *spec = codec->spec;
2057 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2058}
2059
2060/*
2061 * Digital out
2062 */
2063static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2064 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002065 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066{
2067 struct alc_spec *spec = codec->spec;
2068 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2069}
2070
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002071static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2072 struct hda_codec *codec,
2073 unsigned int stream_tag,
2074 unsigned int format,
2075 struct snd_pcm_substream *substream)
2076{
2077 struct alc_spec *spec = codec->spec;
2078 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2079 stream_tag, format, substream);
2080}
2081
Linus Torvalds1da177e2005-04-16 15:20:36 -07002082static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2083 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002084 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085{
2086 struct alc_spec *spec = codec->spec;
2087 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2088}
2089
2090/*
2091 * Analog capture
2092 */
2093static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2094 struct hda_codec *codec,
2095 unsigned int stream_tag,
2096 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002097 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098{
2099 struct alc_spec *spec = codec->spec;
2100
2101 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2102 stream_tag, 0, format);
2103 return 0;
2104}
2105
2106static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2107 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002108 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109{
2110 struct alc_spec *spec = codec->spec;
2111
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002112 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2113 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114 return 0;
2115}
2116
2117
2118/*
2119 */
2120static struct hda_pcm_stream alc880_pcm_analog_playback = {
2121 .substreams = 1,
2122 .channels_min = 2,
2123 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002124 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125 .ops = {
2126 .open = alc880_playback_pcm_open,
2127 .prepare = alc880_playback_pcm_prepare,
2128 .cleanup = alc880_playback_pcm_cleanup
2129 },
2130};
2131
2132static struct hda_pcm_stream alc880_pcm_analog_capture = {
2133 .substreams = 2,
2134 .channels_min = 2,
2135 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002136 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 .ops = {
2138 .prepare = alc880_capture_pcm_prepare,
2139 .cleanup = alc880_capture_pcm_cleanup
2140 },
2141};
2142
2143static struct hda_pcm_stream alc880_pcm_digital_playback = {
2144 .substreams = 1,
2145 .channels_min = 2,
2146 .channels_max = 2,
2147 /* NID is set in alc_build_pcms */
2148 .ops = {
2149 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002150 .close = alc880_dig_playback_pcm_close,
2151 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002152 },
2153};
2154
2155static struct hda_pcm_stream alc880_pcm_digital_capture = {
2156 .substreams = 1,
2157 .channels_min = 2,
2158 .channels_max = 2,
2159 /* NID is set in alc_build_pcms */
2160};
2161
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002162/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2163static struct hda_pcm_stream alc_pcm_null_playback = {
2164 .substreams = 0,
2165 .channels_min = 0,
2166 .channels_max = 0,
2167};
2168
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169static int alc_build_pcms(struct hda_codec *codec)
2170{
2171 struct alc_spec *spec = codec->spec;
2172 struct hda_pcm *info = spec->pcm_rec;
2173 int i;
2174
2175 codec->num_pcms = 1;
2176 codec->pcm_info = info;
2177
2178 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002179 if (spec->stream_analog_playback) {
2180 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2181 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2182 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2183 }
2184 if (spec->stream_analog_capture) {
2185 snd_assert(spec->adc_nids, return -EINVAL);
2186 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2187 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2188 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189
Takashi Iwai4a471b72005-12-07 13:56:29 +01002190 if (spec->channel_mode) {
2191 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2192 for (i = 0; i < spec->num_channel_mode; i++) {
2193 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2194 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2195 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002196 }
2197 }
2198
Takashi Iwaie08a0072006-09-07 17:52:14 +02002199 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002201 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002202 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002204 if (spec->multiout.dig_out_nid &&
2205 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2207 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2208 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002209 if (spec->dig_in_nid &&
2210 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2212 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2213 }
2214 }
2215
Takashi Iwaie08a0072006-09-07 17:52:14 +02002216 /* If the use of more than one ADC is requested for the current
2217 * model, configure a second analog capture-only PCM.
2218 */
2219 /* Additional Analaog capture for index #2 */
2220 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2221 spec->adc_nids) {
2222 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002223 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002224 info->name = spec->stream_name_analog;
2225 /* No playback stream for second PCM */
2226 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2227 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2228 if (spec->stream_analog_capture) {
2229 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2230 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2231 }
2232 }
2233
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234 return 0;
2235}
2236
2237static void alc_free(struct hda_codec *codec)
2238{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239 struct alc_spec *spec = codec->spec;
2240 unsigned int i;
2241
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002242 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243 return;
2244
2245 if (spec->kctl_alloc) {
2246 for (i = 0; i < spec->num_kctl_used; i++)
2247 kfree(spec->kctl_alloc[i].name);
2248 kfree(spec->kctl_alloc);
2249 }
2250 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251}
2252
2253/*
2254 */
2255static struct hda_codec_ops alc_patch_ops = {
2256 .build_controls = alc_build_controls,
2257 .build_pcms = alc_build_pcms,
2258 .init = alc_init,
2259 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002260 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261#ifdef CONFIG_PM
2262 .resume = alc_resume,
2263#endif
2264};
2265
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002266
2267/*
2268 * Test configuration for debugging
2269 *
2270 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2271 * enum controls.
2272 */
2273#ifdef CONFIG_SND_DEBUG
2274static hda_nid_t alc880_test_dac_nids[4] = {
2275 0x02, 0x03, 0x04, 0x05
2276};
2277
2278static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002279 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002280 .items = {
2281 { "In-1", 0x0 },
2282 { "In-2", 0x1 },
2283 { "In-3", 0x2 },
2284 { "In-4", 0x3 },
2285 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002286 { "Front", 0x5 },
2287 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002288 },
2289};
2290
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002291static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002292 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002293 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002294 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002295 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002296};
2297
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002298static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2299 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002300{
2301 static char *texts[] = {
2302 "N/A", "Line Out", "HP Out",
2303 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2304 };
2305 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2306 uinfo->count = 1;
2307 uinfo->value.enumerated.items = 8;
2308 if (uinfo->value.enumerated.item >= 8)
2309 uinfo->value.enumerated.item = 7;
2310 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2311 return 0;
2312}
2313
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002314static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2315 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002316{
2317 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2318 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2319 unsigned int pin_ctl, item = 0;
2320
2321 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2322 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2323 if (pin_ctl & AC_PINCTL_OUT_EN) {
2324 if (pin_ctl & AC_PINCTL_HP_EN)
2325 item = 2;
2326 else
2327 item = 1;
2328 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2329 switch (pin_ctl & AC_PINCTL_VREFEN) {
2330 case AC_PINCTL_VREF_HIZ: item = 3; break;
2331 case AC_PINCTL_VREF_50: item = 4; break;
2332 case AC_PINCTL_VREF_GRD: item = 5; break;
2333 case AC_PINCTL_VREF_80: item = 6; break;
2334 case AC_PINCTL_VREF_100: item = 7; break;
2335 }
2336 }
2337 ucontrol->value.enumerated.item[0] = item;
2338 return 0;
2339}
2340
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002341static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2342 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002343{
2344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2345 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2346 static unsigned int ctls[] = {
2347 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2348 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2349 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2350 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2351 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2352 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2353 };
2354 unsigned int old_ctl, new_ctl;
2355
2356 old_ctl = snd_hda_codec_read(codec, nid, 0,
2357 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2358 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2359 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002360 snd_hda_codec_write(codec, nid, 0,
2361 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002362 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002363 (ucontrol->value.enumerated.item[0] >= 3 ?
2364 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002365 return 1;
2366 }
2367 return 0;
2368}
2369
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002370static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2371 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002372{
2373 static char *texts[] = {
2374 "Front", "Surround", "CLFE", "Side"
2375 };
2376 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2377 uinfo->count = 1;
2378 uinfo->value.enumerated.items = 4;
2379 if (uinfo->value.enumerated.item >= 4)
2380 uinfo->value.enumerated.item = 3;
2381 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2382 return 0;
2383}
2384
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002385static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2386 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002387{
2388 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2389 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2390 unsigned int sel;
2391
2392 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2393 ucontrol->value.enumerated.item[0] = sel & 3;
2394 return 0;
2395}
2396
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002397static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2398 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002399{
2400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2401 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2402 unsigned int sel;
2403
2404 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2405 if (ucontrol->value.enumerated.item[0] != sel) {
2406 sel = ucontrol->value.enumerated.item[0] & 3;
2407 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2408 return 1;
2409 }
2410 return 0;
2411}
2412
2413#define PIN_CTL_TEST(xname,nid) { \
2414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2415 .name = xname, \
2416 .info = alc_test_pin_ctl_info, \
2417 .get = alc_test_pin_ctl_get, \
2418 .put = alc_test_pin_ctl_put, \
2419 .private_value = nid \
2420 }
2421
2422#define PIN_SRC_TEST(xname,nid) { \
2423 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2424 .name = xname, \
2425 .info = alc_test_pin_src_info, \
2426 .get = alc_test_pin_src_get, \
2427 .put = alc_test_pin_src_put, \
2428 .private_value = nid \
2429 }
2430
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002431static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002432 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2433 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2434 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2435 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002436 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2437 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2438 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2439 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002440 PIN_CTL_TEST("Front Pin Mode", 0x14),
2441 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2442 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2443 PIN_CTL_TEST("Side Pin Mode", 0x17),
2444 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2445 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2446 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2447 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2448 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2449 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2450 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2451 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2452 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2453 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2454 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2455 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2456 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2457 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2458 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2459 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002462 {
2463 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2464 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002465 .info = alc_ch_mode_info,
2466 .get = alc_ch_mode_get,
2467 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002468 },
2469 { } /* end */
2470};
2471
2472static struct hda_verb alc880_test_init_verbs[] = {
2473 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2476 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2478 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2479 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2480 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2481 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002482 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2486 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002487 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2491 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002492 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2495 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2496 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002497 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2499 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2501 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2502 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002503 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002504 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2505 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2507 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002508 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002510 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002512 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002513 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002514 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002515 /* Analog input/passthru */
2516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002521 { }
2522};
2523#endif
2524
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525/*
2526 */
2527
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002528static const char *alc880_models[ALC880_MODEL_LAST] = {
2529 [ALC880_3ST] = "3stack",
2530 [ALC880_TCL_S700] = "tcl",
2531 [ALC880_3ST_DIG] = "3stack-digout",
2532 [ALC880_CLEVO] = "clevo",
2533 [ALC880_5ST] = "5stack",
2534 [ALC880_5ST_DIG] = "5stack-digout",
2535 [ALC880_W810] = "w810",
2536 [ALC880_Z71V] = "z71v",
2537 [ALC880_6ST] = "6stack",
2538 [ALC880_6ST_DIG] = "6stack-digout",
2539 [ALC880_ASUS] = "asus",
2540 [ALC880_ASUS_W1V] = "asus-w1v",
2541 [ALC880_ASUS_DIG] = "asus-dig",
2542 [ALC880_ASUS_DIG2] = "asus-dig2",
2543 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002544 [ALC880_UNIWILL_P53] = "uniwill-p53",
2545 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002546 [ALC880_F1734] = "F1734",
2547 [ALC880_LG] = "lg",
2548 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002549#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002550 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002551#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002552 [ALC880_AUTO] = "auto",
2553};
2554
2555static struct snd_pci_quirk alc880_cfg_tbl[] = {
2556 /* Broken BIOS configuration */
2557 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2558 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2559
2560 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2561 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002562 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002563 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2564 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2565 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2566 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2567 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2568 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2569
2570 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2571 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2572
2573 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2574 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2575 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2576 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2577 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2578 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2579 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2580 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2581 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2582 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002583 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002584 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2585 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2586 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2587 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2588
2589 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2590 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2591 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2592 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2593 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2594 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2595 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2596 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2597 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2598 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2599 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2600 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2601 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2602 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2603 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2604 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2605 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2606 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2607
2608 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2609 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2610 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2611 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2612
2613 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2614 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2615 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002616 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002617
2618 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2619 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2620 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2621 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2622
2623 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2624 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2625 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2626 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2627 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2628 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2629 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2630 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2631 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2632 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2633 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002634
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 {}
2636};
2637
Takashi Iwai16ded522005-06-10 19:58:24 +02002638/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002639 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002640 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002641static struct alc_config_preset alc880_presets[] = {
2642 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002644 .init_verbs = { alc880_volume_init_verbs,
2645 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002646 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002647 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002648 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2649 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002650 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002651 .input_mux = &alc880_capture_source,
2652 },
2653 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002654 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002655 .init_verbs = { alc880_volume_init_verbs,
2656 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002657 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 .dac_nids = alc880_dac_nids,
2659 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2661 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002662 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002663 .input_mux = &alc880_capture_source,
2664 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002665 [ALC880_TCL_S700] = {
2666 .mixers = { alc880_tcl_s700_mixer },
2667 .init_verbs = { alc880_volume_init_verbs,
2668 alc880_pin_tcl_S700_init_verbs,
2669 alc880_gpio2_init_verbs },
2670 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2671 .dac_nids = alc880_dac_nids,
2672 .hp_nid = 0x03,
2673 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2674 .channel_mode = alc880_2_jack_modes,
2675 .input_mux = &alc880_capture_source,
2676 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002678 .mixers = { alc880_three_stack_mixer,
2679 alc880_five_stack_mixer},
2680 .init_verbs = { alc880_volume_init_verbs,
2681 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002682 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2683 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2685 .channel_mode = alc880_fivestack_modes,
2686 .input_mux = &alc880_capture_source,
2687 },
2688 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002689 .mixers = { alc880_three_stack_mixer,
2690 alc880_five_stack_mixer },
2691 .init_verbs = { alc880_volume_init_verbs,
2692 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002693 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2694 .dac_nids = alc880_dac_nids,
2695 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002696 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2697 .channel_mode = alc880_fivestack_modes,
2698 .input_mux = &alc880_capture_source,
2699 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002700 [ALC880_6ST] = {
2701 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002702 .init_verbs = { alc880_volume_init_verbs,
2703 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002704 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2705 .dac_nids = alc880_6st_dac_nids,
2706 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2707 .channel_mode = alc880_sixstack_modes,
2708 .input_mux = &alc880_6stack_capture_source,
2709 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002710 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002712 .init_verbs = { alc880_volume_init_verbs,
2713 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002714 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2715 .dac_nids = alc880_6st_dac_nids,
2716 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002717 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2718 .channel_mode = alc880_sixstack_modes,
2719 .input_mux = &alc880_6stack_capture_source,
2720 },
2721 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002723 .init_verbs = { alc880_volume_init_verbs,
2724 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002725 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002726 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2727 .dac_nids = alc880_w810_dac_nids,
2728 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2730 .channel_mode = alc880_w810_modes,
2731 .input_mux = &alc880_capture_source,
2732 },
2733 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002735 .init_verbs = { alc880_volume_init_verbs,
2736 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002737 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2738 .dac_nids = alc880_z71v_dac_nids,
2739 .dig_out_nid = ALC880_DIGOUT_NID,
2740 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002741 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2742 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002743 .input_mux = &alc880_capture_source,
2744 },
2745 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002747 .init_verbs = { alc880_volume_init_verbs,
2748 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002749 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2750 .dac_nids = alc880_f1734_dac_nids,
2751 .hp_nid = 0x02,
2752 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2753 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002754 .input_mux = &alc880_capture_source,
2755 },
2756 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002757 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002758 .init_verbs = { alc880_volume_init_verbs,
2759 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002760 alc880_gpio1_init_verbs },
2761 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2762 .dac_nids = alc880_asus_dac_nids,
2763 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2764 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002765 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002766 .input_mux = &alc880_capture_source,
2767 },
2768 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002769 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002770 .init_verbs = { alc880_volume_init_verbs,
2771 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 alc880_gpio1_init_verbs },
2773 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2774 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002775 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2777 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002778 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002779 .input_mux = &alc880_capture_source,
2780 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002781 [ALC880_ASUS_DIG2] = {
2782 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002783 .init_verbs = { alc880_volume_init_verbs,
2784 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002785 alc880_gpio2_init_verbs }, /* use GPIO2 */
2786 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2787 .dac_nids = alc880_asus_dac_nids,
2788 .dig_out_nid = ALC880_DIGOUT_NID,
2789 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2790 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002791 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002792 .input_mux = &alc880_capture_source,
2793 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002796 .init_verbs = { alc880_volume_init_verbs,
2797 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002798 alc880_gpio1_init_verbs },
2799 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2800 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2803 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002804 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002805 .input_mux = &alc880_capture_source,
2806 },
2807 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002808 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002809 .init_verbs = { alc880_volume_init_verbs,
2810 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002811 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2812 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002813 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002814 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2815 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002816 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002817 .input_mux = &alc880_capture_source,
2818 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002819 [ALC880_UNIWILL] = {
2820 .mixers = { alc880_uniwill_mixer },
2821 .init_verbs = { alc880_volume_init_verbs,
2822 alc880_uniwill_init_verbs },
2823 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2824 .dac_nids = alc880_asus_dac_nids,
2825 .dig_out_nid = ALC880_DIGOUT_NID,
2826 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2827 .channel_mode = alc880_threestack_modes,
2828 .need_dac_fix = 1,
2829 .input_mux = &alc880_capture_source,
2830 .unsol_event = alc880_uniwill_unsol_event,
2831 .init_hook = alc880_uniwill_automute,
2832 },
2833 [ALC880_UNIWILL_P53] = {
2834 .mixers = { alc880_uniwill_p53_mixer },
2835 .init_verbs = { alc880_volume_init_verbs,
2836 alc880_uniwill_p53_init_verbs },
2837 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2838 .dac_nids = alc880_asus_dac_nids,
2839 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002840 .channel_mode = alc880_threestack_modes,
2841 .input_mux = &alc880_capture_source,
2842 .unsol_event = alc880_uniwill_p53_unsol_event,
2843 .init_hook = alc880_uniwill_p53_hp_automute,
2844 },
2845 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002846 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002847 alc880_pcbeep_mixer, },
2848 .init_verbs = { alc880_volume_init_verbs,
2849 alc880_uniwill_p53_init_verbs,
2850 alc880_beep_init_verbs },
2851 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2852 .dac_nids = alc880_dac_nids,
2853 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2854 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002855 .input_mux = &alc880_capture_source,
2856 .unsol_event = alc880_uniwill_p53_unsol_event,
2857 .init_hook = alc880_uniwill_p53_hp_automute,
2858 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002859 [ALC880_CLEVO] = {
2860 .mixers = { alc880_three_stack_mixer },
2861 .init_verbs = { alc880_volume_init_verbs,
2862 alc880_pin_clevo_init_verbs },
2863 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2864 .dac_nids = alc880_dac_nids,
2865 .hp_nid = 0x03,
2866 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2867 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002868 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002869 .input_mux = &alc880_capture_source,
2870 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002871 [ALC880_LG] = {
2872 .mixers = { alc880_lg_mixer },
2873 .init_verbs = { alc880_volume_init_verbs,
2874 alc880_lg_init_verbs },
2875 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2876 .dac_nids = alc880_lg_dac_nids,
2877 .dig_out_nid = ALC880_DIGOUT_NID,
2878 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2879 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002880 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002881 .input_mux = &alc880_lg_capture_source,
2882 .unsol_event = alc880_lg_unsol_event,
2883 .init_hook = alc880_lg_automute,
2884 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002885 [ALC880_LG_LW] = {
2886 .mixers = { alc880_lg_lw_mixer },
2887 .init_verbs = { alc880_volume_init_verbs,
2888 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002889 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002890 .dac_nids = alc880_dac_nids,
2891 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002892 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2893 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002894 .input_mux = &alc880_lg_lw_capture_source,
2895 .unsol_event = alc880_lg_lw_unsol_event,
2896 .init_hook = alc880_lg_lw_automute,
2897 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002898#ifdef CONFIG_SND_DEBUG
2899 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002900 .mixers = { alc880_test_mixer },
2901 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002902 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2903 .dac_nids = alc880_test_dac_nids,
2904 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002905 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2906 .channel_mode = alc880_test_modes,
2907 .input_mux = &alc880_test_capture_source,
2908 },
2909#endif
2910};
2911
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002912/*
2913 * Automatic parse of I/O pins from the BIOS configuration
2914 */
2915
2916#define NUM_CONTROL_ALLOC 32
2917#define NUM_VERB_ALLOC 32
2918
2919enum {
2920 ALC_CTL_WIDGET_VOL,
2921 ALC_CTL_WIDGET_MUTE,
2922 ALC_CTL_BIND_MUTE,
2923};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002924static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002925 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2926 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002927 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002928};
2929
2930/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002931static int add_control(struct alc_spec *spec, int type, const char *name,
2932 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002933{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002934 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002935
2936 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2937 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2938
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002939 /* array + terminator */
2940 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2941 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002942 return -ENOMEM;
2943 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002944 memcpy(knew, spec->kctl_alloc,
2945 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002946 kfree(spec->kctl_alloc);
2947 }
2948 spec->kctl_alloc = knew;
2949 spec->num_kctl_alloc = num;
2950 }
2951
2952 knew = &spec->kctl_alloc[spec->num_kctl_used];
2953 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002954 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002955 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002956 return -ENOMEM;
2957 knew->private_value = val;
2958 spec->num_kctl_used++;
2959 return 0;
2960}
2961
2962#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2963#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2964#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2965#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2966#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2967#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2968#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2969#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2970#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2971#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2972#define ALC880_PIN_CD_NID 0x1c
2973
2974/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002975static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2976 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977{
2978 hda_nid_t nid;
2979 int assigned[4];
2980 int i, j;
2981
2982 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002983 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002984
2985 /* check the pins hardwired to audio widget */
2986 for (i = 0; i < cfg->line_outs; i++) {
2987 nid = cfg->line_out_pins[i];
2988 if (alc880_is_fixed_pin(nid)) {
2989 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002990 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002991 assigned[idx] = 1;
2992 }
2993 }
2994 /* left pins can be connect to any audio widget */
2995 for (i = 0; i < cfg->line_outs; i++) {
2996 nid = cfg->line_out_pins[i];
2997 if (alc880_is_fixed_pin(nid))
2998 continue;
2999 /* search for an empty channel */
3000 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003001 if (!assigned[j]) {
3002 spec->multiout.dac_nids[i] =
3003 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003004 assigned[j] = 1;
3005 break;
3006 }
3007 }
3008 }
3009 spec->multiout.num_dacs = cfg->line_outs;
3010 return 0;
3011}
3012
3013/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003014static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3015 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003016{
3017 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003018 static const char *chname[4] = {
3019 "Front", "Surround", NULL /*CLFE*/, "Side"
3020 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003021 hda_nid_t nid;
3022 int i, err;
3023
3024 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003025 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003026 continue;
3027 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3028 if (i == 2) {
3029 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003030 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3031 "Center Playback Volume",
3032 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3033 HDA_OUTPUT));
3034 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003035 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003036 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3037 "LFE Playback Volume",
3038 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3039 HDA_OUTPUT));
3040 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003041 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003042 err = add_control(spec, ALC_CTL_BIND_MUTE,
3043 "Center Playback Switch",
3044 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3045 HDA_INPUT));
3046 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003047 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003048 err = add_control(spec, ALC_CTL_BIND_MUTE,
3049 "LFE Playback Switch",
3050 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3051 HDA_INPUT));
3052 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003053 return err;
3054 } else {
3055 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003056 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3057 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3058 HDA_OUTPUT));
3059 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 return err;
3061 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003062 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3063 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3064 HDA_INPUT));
3065 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003066 return err;
3067 }
3068 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003069 return 0;
3070}
3071
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003072/* add playback controls for speaker and HP outputs */
3073static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3074 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003075{
3076 hda_nid_t nid;
3077 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003078 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003080 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003081 return 0;
3082
3083 if (alc880_is_fixed_pin(pin)) {
3084 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003085 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003086 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003088 else
3089 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003090 /* control HP volume/switch on the output mixer amp */
3091 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003092 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003093 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3094 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3095 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003096 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003097 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003098 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3099 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3100 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 return err;
3102 } else if (alc880_is_multi_pin(pin)) {
3103 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003105 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003106 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3107 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3108 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 return err;
3110 }
3111 return 0;
3112}
3113
3114/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003115static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3116 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003117 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118{
3119 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003120 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003121
3122 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003123 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3124 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3125 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126 return err;
3127 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003128 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3129 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3130 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131 return err;
3132 return 0;
3133}
3134
3135/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003136static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3137 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003138{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003140 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003141
3142 for (i = 0; i < AUTO_PIN_LAST; i++) {
3143 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003144 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003145 err = new_analog_input(spec, cfg->input_pins[i],
3146 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003147 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003148 if (err < 0)
3149 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003150 imux->items[imux->num_items].label =
3151 auto_pin_cfg_labels[i];
3152 imux->items[imux->num_items].index =
3153 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003154 imux->num_items++;
3155 }
3156 }
3157 return 0;
3158}
3159
Kailang Yangdf694da2005-12-05 19:42:22 +01003160static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3161 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003162 int dac_idx)
3163{
3164 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003165 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3166 pin_type);
3167 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3168 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003169 /* need the manual connection? */
3170 if (alc880_is_multi_pin(nid)) {
3171 struct alc_spec *spec = codec->spec;
3172 int idx = alc880_multi_pin_idx(nid);
3173 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3174 AC_VERB_SET_CONNECT_SEL,
3175 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3176 }
3177}
3178
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003179static int get_pin_type(int line_out_type)
3180{
3181 if (line_out_type == AUTO_PIN_HP_OUT)
3182 return PIN_HP;
3183 else
3184 return PIN_OUT;
3185}
3186
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003187static void alc880_auto_init_multi_out(struct hda_codec *codec)
3188{
3189 struct alc_spec *spec = codec->spec;
3190 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003191
3192 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003193 for (i = 0; i < spec->autocfg.line_outs; i++) {
3194 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003195 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3196 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 }
3198}
3199
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003200static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003201{
3202 struct alc_spec *spec = codec->spec;
3203 hda_nid_t pin;
3204
Takashi Iwai82bc9552006-03-21 11:24:42 +01003205 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003206 if (pin) /* connect to front */
3207 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003208 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003209 if (pin) /* connect to front */
3210 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3211}
3212
3213static void alc880_auto_init_analog_input(struct hda_codec *codec)
3214{
3215 struct alc_spec *spec = codec->spec;
3216 int i;
3217
3218 for (i = 0; i < AUTO_PIN_LAST; i++) {
3219 hda_nid_t nid = spec->autocfg.input_pins[i];
3220 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003221 snd_hda_codec_write(codec, nid, 0,
3222 AC_VERB_SET_PIN_WIDGET_CONTROL,
3223 i <= AUTO_PIN_FRONT_MIC ?
3224 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003225 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003226 snd_hda_codec_write(codec, nid, 0,
3227 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003228 AMP_OUT_MUTE);
3229 }
3230 }
3231}
3232
3233/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003234/* return 1 if successful, 0 if the proper config is not found,
3235 * or a negative error code
3236 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003237static int alc880_parse_auto_config(struct hda_codec *codec)
3238{
3239 struct alc_spec *spec = codec->spec;
3240 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003241 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003243 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3244 alc880_ignore);
3245 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003246 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003247 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003248 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003249
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003250 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3251 if (err < 0)
3252 return err;
3253 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3254 if (err < 0)
3255 return err;
3256 err = alc880_auto_create_extra_out(spec,
3257 spec->autocfg.speaker_pins[0],
3258 "Speaker");
3259 if (err < 0)
3260 return err;
3261 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3262 "Headphone");
3263 if (err < 0)
3264 return err;
3265 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3266 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 return err;
3268
3269 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3270
3271 if (spec->autocfg.dig_out_pin)
3272 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3273 if (spec->autocfg.dig_in_pin)
3274 spec->dig_in_nid = ALC880_DIGIN_NID;
3275
3276 if (spec->kctl_alloc)
3277 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3278
3279 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3280
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003281 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003282 spec->input_mux = &spec->private_imux;
3283
3284 return 1;
3285}
3286
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003287/* additional initialization for auto-configuration model */
3288static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003289{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003290 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003291 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003292 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293}
3294
3295/*
3296 * OK, here we have finally the patch for ALC880
3297 */
3298
Linus Torvalds1da177e2005-04-16 15:20:36 -07003299static int patch_alc880(struct hda_codec *codec)
3300{
3301 struct alc_spec *spec;
3302 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003303 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003304
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003305 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003306 if (spec == NULL)
3307 return -ENOMEM;
3308
3309 codec->spec = spec;
3310
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003311 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3312 alc880_models,
3313 alc880_cfg_tbl);
3314 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003315 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3316 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003317 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003318 }
3319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 if (board_config == ALC880_AUTO) {
3321 /* automatic parse from the BIOS config */
3322 err = alc880_parse_auto_config(codec);
3323 if (err < 0) {
3324 alc_free(codec);
3325 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003326 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003327 printk(KERN_INFO
3328 "hda_codec: Cannot set up configuration "
3329 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003330 board_config = ALC880_3ST;
3331 }
3332 }
3333
Kailang Yangdf694da2005-12-05 19:42:22 +01003334 if (board_config != ALC880_AUTO)
3335 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003336
3337 spec->stream_name_analog = "ALC880 Analog";
3338 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3339 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3340
3341 spec->stream_name_digital = "ALC880 Digital";
3342 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3343 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3344
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003345 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003346 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003347 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003348 /* get type */
3349 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003350 if (wcap != AC_WID_AUD_IN) {
3351 spec->adc_nids = alc880_adc_nids_alt;
3352 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003353 spec->mixers[spec->num_mixers] =
3354 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003355 spec->num_mixers++;
3356 } else {
3357 spec->adc_nids = alc880_adc_nids;
3358 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3359 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3360 spec->num_mixers++;
3361 }
3362 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003363
3364 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003366 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003367
3368 return 0;
3369}
3370
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003371
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372/*
3373 * ALC260 support
3374 */
3375
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376static hda_nid_t alc260_dac_nids[1] = {
3377 /* front */
3378 0x02,
3379};
3380
3381static hda_nid_t alc260_adc_nids[1] = {
3382 /* ADC0 */
3383 0x04,
3384};
3385
Kailang Yangdf694da2005-12-05 19:42:22 +01003386static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003387 /* ADC1 */
3388 0x05,
3389};
3390
Kailang Yangdf694da2005-12-05 19:42:22 +01003391static hda_nid_t alc260_hp_adc_nids[2] = {
3392 /* ADC1, 0 */
3393 0x05, 0x04
3394};
3395
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003396/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3397 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3398 */
3399static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003400 /* ADC0, ADC1 */
3401 0x04, 0x05
3402};
3403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404#define ALC260_DIGOUT_NID 0x03
3405#define ALC260_DIGIN_NID 0x06
3406
3407static struct hda_input_mux alc260_capture_source = {
3408 .num_items = 4,
3409 .items = {
3410 { "Mic", 0x0 },
3411 { "Front Mic", 0x1 },
3412 { "Line", 0x2 },
3413 { "CD", 0x4 },
3414 },
3415};
3416
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003417/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003418 * headphone jack and the internal CD lines since these are the only pins at
3419 * which audio can appear. For flexibility, also allow the option of
3420 * recording the mixer output on the second ADC (ADC0 doesn't have a
3421 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003422 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003423static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3424 {
3425 .num_items = 3,
3426 .items = {
3427 { "Mic/Line", 0x0 },
3428 { "CD", 0x4 },
3429 { "Headphone", 0x2 },
3430 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003431 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003432 {
3433 .num_items = 4,
3434 .items = {
3435 { "Mic/Line", 0x0 },
3436 { "CD", 0x4 },
3437 { "Headphone", 0x2 },
3438 { "Mixer", 0x5 },
3439 },
3440 },
3441
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003442};
3443
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003444/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3445 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003446 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003447static struct hda_input_mux alc260_acer_capture_sources[2] = {
3448 {
3449 .num_items = 4,
3450 .items = {
3451 { "Mic", 0x0 },
3452 { "Line", 0x2 },
3453 { "CD", 0x4 },
3454 { "Headphone", 0x5 },
3455 },
3456 },
3457 {
3458 .num_items = 5,
3459 .items = {
3460 { "Mic", 0x0 },
3461 { "Line", 0x2 },
3462 { "CD", 0x4 },
3463 { "Headphone", 0x6 },
3464 { "Mixer", 0x5 },
3465 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003466 },
3467};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003468/*
3469 * This is just place-holder, so there's something for alc_build_pcms to look
3470 * at when it calculates the maximum number of channels. ALC260 has no mixer
3471 * element which allows changing the channel mode, so the verb list is
3472 * never used.
3473 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003474static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003475 { 2, NULL },
3476};
3477
Kailang Yangdf694da2005-12-05 19:42:22 +01003478
3479/* Mixer combinations
3480 *
3481 * basic: base_output + input + pc_beep + capture
3482 * HP: base_output + input + capture_alt
3483 * HP_3013: hp_3013 + input + capture
3484 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003485 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003486 */
3487
3488static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003489 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003490 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003491 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3492 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3493 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3494 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3495 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003496};
Kailang Yangdf694da2005-12-05 19:42:22 +01003497
3498static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003499 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3500 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3501 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3502 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3504 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3505 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003507 { } /* end */
3508};
3509
Kailang Yangdf694da2005-12-05 19:42:22 +01003510static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3511 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3512 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3513 { } /* end */
3514};
3515
3516static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3517 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3518 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3519 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3520 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3521 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3523 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3524 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003525 { } /* end */
3526};
3527
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003528/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3529 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3530 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003531static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003532 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003533 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003534 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003535 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3536 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3537 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3538 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003539 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003540 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3541 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3542 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003543 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003544 { } /* end */
3545};
3546
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003547/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3548 * versions of the ALC260 don't act on requests to enable mic bias from NID
3549 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3550 * datasheet doesn't mention this restriction. At this stage it's not clear
3551 * whether this behaviour is intentional or is a hardware bug in chip
3552 * revisions available in early 2006. Therefore for now allow the
3553 * "Headphone Jack Mode" control to span all choices, but if it turns out
3554 * that the lack of mic bias for this NID is intentional we could change the
3555 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3556 *
3557 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3558 * don't appear to make the mic bias available from the "line" jack, even
3559 * though the NID used for this jack (0x14) can supply it. The theory is
3560 * that perhaps Acer have included blocking capacitors between the ALC260
3561 * and the output jack. If this turns out to be the case for all such
3562 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3563 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003564 *
3565 * The C20x Tablet series have a mono internal speaker which is controlled
3566 * via the chip's Mono sum widget and pin complex, so include the necessary
3567 * controls for such models. On models without a "mono speaker" the control
3568 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003569 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003570static struct snd_kcontrol_new alc260_acer_mixer[] = {
3571 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3572 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003573 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003574 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3575 HDA_OUTPUT),
3576 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3577 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003578 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3579 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3581 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3582 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3583 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3584 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3585 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3586 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3587 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3588 { } /* end */
3589};
3590
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003591/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3592 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3593 */
3594static struct snd_kcontrol_new alc260_will_mixer[] = {
3595 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3596 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3598 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3599 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3600 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3601 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3602 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3603 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3604 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3605 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3606 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3607 { } /* end */
3608};
3609
3610/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3611 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3612 */
3613static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3614 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3615 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3617 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3618 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3619 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3620 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3621 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3622 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3623 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3624 { } /* end */
3625};
3626
Kailang Yangdf694da2005-12-05 19:42:22 +01003627/* capture mixer elements */
3628static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003629 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3630 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003631 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3632 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003633 {
3634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003635 /* The multiple "Capture Source" controls confuse alsamixer
3636 * So call somewhat different..
3637 * FIXME: the controls appear in the "playback" view!
3638 */
3639 /* .name = "Capture Source", */
3640 .name = "Input Source",
3641 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003642 .info = alc_mux_enum_info,
3643 .get = alc_mux_enum_get,
3644 .put = alc_mux_enum_put,
3645 },
3646 { } /* end */
3647};
3648
Kailang Yangdf694da2005-12-05 19:42:22 +01003649static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3650 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3651 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3652 {
3653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3654 /* The multiple "Capture Source" controls confuse alsamixer
3655 * So call somewhat different..
3656 * FIXME: the controls appear in the "playback" view!
3657 */
3658 /* .name = "Capture Source", */
3659 .name = "Input Source",
3660 .count = 1,
3661 .info = alc_mux_enum_info,
3662 .get = alc_mux_enum_get,
3663 .put = alc_mux_enum_put,
3664 },
3665 { } /* end */
3666};
3667
3668/*
3669 * initialization verbs
3670 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003671static struct hda_verb alc260_init_verbs[] = {
3672 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003674 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003675 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003676 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003677 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003678 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003679 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003680 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003681 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003682 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003683 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003685 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003686 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003687 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003688 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003689 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3690 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003691 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003692 /* set connection select to line in (default select for this ADC) */
3693 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003694 /* mute capture amp left and right */
3695 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3696 /* set connection select to line in (default select for this ADC) */
3697 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003698 /* set vol=0 Line-Out mixer amp left and right */
3699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3700 /* unmute pin widget amp left and right (no gain on this amp) */
3701 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3702 /* set vol=0 HP mixer amp left and right */
3703 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3704 /* unmute pin widget amp left and right (no gain on this amp) */
3705 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3706 /* set vol=0 Mono mixer amp left and right */
3707 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3708 /* unmute pin widget amp left and right (no gain on this amp) */
3709 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3710 /* unmute LINE-2 out pin */
3711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003712 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3713 * Line In 2 = 0x03
3714 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003715 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003717 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003719 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003721 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003722 /* mute Front out path */
3723 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3724 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3725 /* mute Headphone out path */
3726 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3727 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3728 /* mute Mono out path */
3729 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3730 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003731 { }
3732};
3733
Takashi Iwai474167d2006-05-17 17:17:43 +02003734#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003735static struct hda_verb alc260_hp_init_verbs[] = {
3736 /* Headphone and output */
3737 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3738 /* mono output */
3739 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3740 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3741 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3742 /* Mic2 (front panel) pin widget for input and vref at 80% */
3743 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3744 /* Line In pin widget for input */
3745 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3746 /* Line-2 pin widget for output */
3747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3748 /* CD pin widget for input */
3749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3750 /* unmute amp left and right */
3751 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3752 /* set connection select to line in (default select for this ADC) */
3753 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3754 /* unmute Line-Out mixer amp left and right (volume = 0) */
3755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3756 /* mute pin widget amp left and right (no gain on this amp) */
3757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3758 /* unmute HP mixer amp left and right (volume = 0) */
3759 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3760 /* mute pin widget amp left and right (no gain on this amp) */
3761 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003762 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3763 * Line In 2 = 0x03
3764 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003765 /* unmute CD */
3766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3767 /* unmute Line In */
3768 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3769 /* unmute Mic */
3770 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3771 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3772 /* Unmute Front out path */
3773 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3774 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3775 /* Unmute Headphone out path */
3776 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3777 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3778 /* Unmute Mono out path */
3779 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3780 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3781 { }
3782};
Takashi Iwai474167d2006-05-17 17:17:43 +02003783#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003784
3785static struct hda_verb alc260_hp_3013_init_verbs[] = {
3786 /* Line out and output */
3787 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3788 /* mono output */
3789 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3790 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3791 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3792 /* Mic2 (front panel) pin widget for input and vref at 80% */
3793 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3794 /* Line In pin widget for input */
3795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3796 /* Headphone pin widget for output */
3797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3798 /* CD pin widget for input */
3799 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3800 /* unmute amp left and right */
3801 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3802 /* set connection select to line in (default select for this ADC) */
3803 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3804 /* unmute Line-Out mixer amp left and right (volume = 0) */
3805 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3806 /* mute pin widget amp left and right (no gain on this amp) */
3807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3808 /* unmute HP mixer amp left and right (volume = 0) */
3809 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3810 /* mute pin widget amp left and right (no gain on this amp) */
3811 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003812 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3813 * Line In 2 = 0x03
3814 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003815 /* unmute CD */
3816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3817 /* unmute Line In */
3818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3819 /* unmute Mic */
3820 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3821 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3822 /* Unmute Front out path */
3823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3824 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3825 /* Unmute Headphone out path */
3826 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3827 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3828 /* Unmute Mono out path */
3829 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3830 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3831 { }
3832};
3833
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003834/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003835 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3836 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003837 */
3838static struct hda_verb alc260_fujitsu_init_verbs[] = {
3839 /* Disable all GPIOs */
3840 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3841 /* Internal speaker is connected to headphone pin */
3842 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3843 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003845 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3846 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3847 /* Ensure all other unused pins are disabled and muted. */
3848 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003850 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003851 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003852 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003853 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003856
Jonathan Woithef7ace402006-02-28 11:46:14 +01003857 /* Disable digital (SPDIF) pins */
3858 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3859 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003860
Jonathan Woithef7ace402006-02-28 11:46:14 +01003861 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3862 * when acting as an output.
3863 */
3864 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3865
3866 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3871 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3872 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3873 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3874 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3875 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003876
Jonathan Woithef7ace402006-02-28 11:46:14 +01003877 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3878 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3879 /* Unmute Line1 pin widget output buffer since it starts as an output.
3880 * If the pin mode is changed by the user the pin mode control will
3881 * take care of enabling the pin's input/output buffers as needed.
3882 * Therefore there's no need to enable the input buffer at this
3883 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003884 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003885 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003886 /* Unmute input buffer of pin widget used for Line-in (no equiv
3887 * mixer ctrl)
3888 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003889 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003890
Jonathan Woithef7ace402006-02-28 11:46:14 +01003891 /* Mute capture amp left and right */
3892 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3893 /* Set ADC connection select to match default mixer setting - line
3894 * in (on mic1 pin)
3895 */
3896 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003897
Jonathan Woithef7ace402006-02-28 11:46:14 +01003898 /* Do the same for the second ADC: mute capture input amp and
3899 * set ADC connection to line in (on mic1 pin)
3900 */
3901 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3902 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003903
Jonathan Woithef7ace402006-02-28 11:46:14 +01003904 /* Mute all inputs to mixer widget (even unconnected ones) */
3905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003913
3914 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003915};
3916
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003917/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3918 * similar laptops (adapted from Fujitsu init verbs).
3919 */
3920static struct hda_verb alc260_acer_init_verbs[] = {
3921 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3922 * the headphone jack. Turn this on and rely on the standard mute
3923 * methods whenever the user wants to turn these outputs off.
3924 */
3925 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3926 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3927 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3928 /* Internal speaker/Headphone jack is connected to Line-out pin */
3929 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3930 /* Internal microphone/Mic jack is connected to Mic1 pin */
3931 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3932 /* Line In jack is connected to Line1 pin */
3933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003934 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3935 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003936 /* Ensure all other unused pins are disabled and muted. */
3937 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3938 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003939 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3940 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3943 /* Disable digital (SPDIF) pins */
3944 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3945 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3946
3947 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3948 * bus when acting as outputs.
3949 */
3950 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3951 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3952
3953 /* Start with output sum widgets muted and their output gains at min */
3954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3956 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3958 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3960 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3961 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3962 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3963
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003964 /* Unmute Line-out pin widget amp left and right
3965 * (no equiv mixer ctrl)
3966 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003967 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003968 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3969 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003970 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3971 * inputs. If the pin mode is changed by the user the pin mode control
3972 * will take care of enabling the pin's input/output buffers as needed.
3973 * Therefore there's no need to enable the input buffer at this
3974 * stage.
3975 */
3976 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3978
3979 /* Mute capture amp left and right */
3980 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3981 /* Set ADC connection select to match default mixer setting - mic
3982 * (on mic1 pin)
3983 */
3984 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3985
3986 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003987 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003988 */
3989 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003990 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003991
3992 /* Mute all inputs to mixer widget (even unconnected ones) */
3993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3999 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4001
4002 { }
4003};
4004
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004005static struct hda_verb alc260_will_verbs[] = {
4006 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4007 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4008 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4009 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4010 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4011 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4012 {}
4013};
4014
4015static struct hda_verb alc260_replacer_672v_verbs[] = {
4016 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4017 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4018 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4019
4020 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4021 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4022 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4023
4024 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4025 {}
4026};
4027
4028/* toggle speaker-output according to the hp-jack state */
4029static void alc260_replacer_672v_automute(struct hda_codec *codec)
4030{
4031 unsigned int present;
4032
4033 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4034 present = snd_hda_codec_read(codec, 0x0f, 0,
4035 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4036 if (present) {
4037 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4038 snd_hda_codec_write(codec, 0x0f, 0,
4039 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4040 } else {
4041 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4042 snd_hda_codec_write(codec, 0x0f, 0,
4043 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4044 }
4045}
4046
4047static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4048 unsigned int res)
4049{
4050 if ((res >> 26) == ALC880_HP_EVENT)
4051 alc260_replacer_672v_automute(codec);
4052}
4053
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004054/* Test configuration for debugging, modelled after the ALC880 test
4055 * configuration.
4056 */
4057#ifdef CONFIG_SND_DEBUG
4058static hda_nid_t alc260_test_dac_nids[1] = {
4059 0x02,
4060};
4061static hda_nid_t alc260_test_adc_nids[2] = {
4062 0x04, 0x05,
4063};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004064/* For testing the ALC260, each input MUX needs its own definition since
4065 * the signal assignments are different. This assumes that the first ADC
4066 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004067 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004068static struct hda_input_mux alc260_test_capture_sources[2] = {
4069 {
4070 .num_items = 7,
4071 .items = {
4072 { "MIC1 pin", 0x0 },
4073 { "MIC2 pin", 0x1 },
4074 { "LINE1 pin", 0x2 },
4075 { "LINE2 pin", 0x3 },
4076 { "CD pin", 0x4 },
4077 { "LINE-OUT pin", 0x5 },
4078 { "HP-OUT pin", 0x6 },
4079 },
4080 },
4081 {
4082 .num_items = 8,
4083 .items = {
4084 { "MIC1 pin", 0x0 },
4085 { "MIC2 pin", 0x1 },
4086 { "LINE1 pin", 0x2 },
4087 { "LINE2 pin", 0x3 },
4088 { "CD pin", 0x4 },
4089 { "Mixer", 0x5 },
4090 { "LINE-OUT pin", 0x6 },
4091 { "HP-OUT pin", 0x7 },
4092 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004093 },
4094};
4095static struct snd_kcontrol_new alc260_test_mixer[] = {
4096 /* Output driver widgets */
4097 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4098 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4099 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4100 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4101 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4102 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4103
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004104 /* Modes for retasking pin widgets
4105 * Note: the ALC260 doesn't seem to act on requests to enable mic
4106 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4107 * mention this restriction. At this stage it's not clear whether
4108 * this behaviour is intentional or is a hardware bug in chip
4109 * revisions available at least up until early 2006. Therefore for
4110 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4111 * choices, but if it turns out that the lack of mic bias for these
4112 * NIDs is intentional we could change their modes from
4113 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4114 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004115 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4116 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4117 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4118 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4119 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4120 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4121
4122 /* Loopback mixer controls */
4123 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4124 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4125 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4126 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4127 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4128 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4129 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4130 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4131 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4132 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4133 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4134 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4135 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4136 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4137 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4138 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004139
4140 /* Controls for GPIO pins, assuming they are configured as outputs */
4141 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4142 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4143 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4144 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4145
Jonathan Woithe92621f12006-02-28 11:47:47 +01004146 /* Switches to allow the digital IO pins to be enabled. The datasheet
4147 * is ambigious as to which NID is which; testing on laptops which
4148 * make this output available should provide clarification.
4149 */
4150 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4151 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4152
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004153 { } /* end */
4154};
4155static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004156 /* Enable all GPIOs as outputs with an initial value of 0 */
4157 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4158 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4159 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4160
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004161 /* Enable retasking pins as output, initially without power amp */
4162 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4163 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4166 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4167 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4168
Jonathan Woithe92621f12006-02-28 11:47:47 +01004169 /* Disable digital (SPDIF) pins initially, but users can enable
4170 * them via a mixer switch. In the case of SPDIF-out, this initverb
4171 * payload also sets the generation to 0, output to be in "consumer"
4172 * PCM format, copyright asserted, no pre-emphasis and no validity
4173 * control.
4174 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004175 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4176 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4177
Jonathan Woithef7ace402006-02-28 11:46:14 +01004178 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004179 * OUT1 sum bus when acting as an output.
4180 */
4181 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4182 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4183 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4184 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4185
4186 /* Start with output sum widgets muted and their output gains at min */
4187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4190 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4193 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4194 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4195 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4196
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004197 /* Unmute retasking pin widget output buffers since the default
4198 * state appears to be output. As the pin mode is changed by the
4199 * user the pin mode control will take care of enabling the pin's
4200 * input/output buffers as needed.
4201 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004202 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4203 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4204 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4205 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4206 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4207 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4208 /* Also unmute the mono-out pin widget */
4209 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4210
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004211 /* Mute capture amp left and right */
4212 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004213 /* Set ADC connection select to match default mixer setting (mic1
4214 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004215 */
4216 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4217
4218 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004219 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004220 */
4221 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4222 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4223
4224 /* Mute all inputs to mixer widget (even unconnected ones) */
4225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4233
4234 { }
4235};
4236#endif
4237
Linus Torvalds1da177e2005-04-16 15:20:36 -07004238static struct hda_pcm_stream alc260_pcm_analog_playback = {
4239 .substreams = 1,
4240 .channels_min = 2,
4241 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004242};
4243
4244static struct hda_pcm_stream alc260_pcm_analog_capture = {
4245 .substreams = 1,
4246 .channels_min = 2,
4247 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004248};
4249
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004250#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4251#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4252
Kailang Yangdf694da2005-12-05 19:42:22 +01004253/*
4254 * for BIOS auto-configuration
4255 */
4256
4257static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4258 const char *pfx)
4259{
4260 hda_nid_t nid_vol;
4261 unsigned long vol_val, sw_val;
4262 char name[32];
4263 int err;
4264
4265 if (nid >= 0x0f && nid < 0x11) {
4266 nid_vol = nid - 0x7;
4267 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4268 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4269 } else if (nid == 0x11) {
4270 nid_vol = nid - 0x7;
4271 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4272 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4273 } else if (nid >= 0x12 && nid <= 0x15) {
4274 nid_vol = 0x08;
4275 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4276 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4277 } else
4278 return 0; /* N/A */
4279
4280 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004281 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4282 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004283 return err;
4284 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004285 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4286 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004287 return err;
4288 return 1;
4289}
4290
4291/* add playback controls from the parsed DAC table */
4292static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4293 const struct auto_pin_cfg *cfg)
4294{
4295 hda_nid_t nid;
4296 int err;
4297
4298 spec->multiout.num_dacs = 1;
4299 spec->multiout.dac_nids = spec->private_dac_nids;
4300 spec->multiout.dac_nids[0] = 0x02;
4301
4302 nid = cfg->line_out_pins[0];
4303 if (nid) {
4304 err = alc260_add_playback_controls(spec, nid, "Front");
4305 if (err < 0)
4306 return err;
4307 }
4308
Takashi Iwai82bc9552006-03-21 11:24:42 +01004309 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004310 if (nid) {
4311 err = alc260_add_playback_controls(spec, nid, "Speaker");
4312 if (err < 0)
4313 return err;
4314 }
4315
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004316 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004317 if (nid) {
4318 err = alc260_add_playback_controls(spec, nid, "Headphone");
4319 if (err < 0)
4320 return err;
4321 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004322 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004323}
4324
4325/* create playback/capture controls for input pins */
4326static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4327 const struct auto_pin_cfg *cfg)
4328{
Kailang Yangdf694da2005-12-05 19:42:22 +01004329 struct hda_input_mux *imux = &spec->private_imux;
4330 int i, err, idx;
4331
4332 for (i = 0; i < AUTO_PIN_LAST; i++) {
4333 if (cfg->input_pins[i] >= 0x12) {
4334 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004335 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004336 auto_pin_cfg_labels[i], idx,
4337 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004338 if (err < 0)
4339 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004340 imux->items[imux->num_items].label =
4341 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004342 imux->items[imux->num_items].index = idx;
4343 imux->num_items++;
4344 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004345 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004346 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004347 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004348 auto_pin_cfg_labels[i], idx,
4349 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004350 if (err < 0)
4351 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004352 imux->items[imux->num_items].label =
4353 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004354 imux->items[imux->num_items].index = idx;
4355 imux->num_items++;
4356 }
4357 }
4358 return 0;
4359}
4360
4361static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4362 hda_nid_t nid, int pin_type,
4363 int sel_idx)
4364{
4365 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004366 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4367 pin_type);
4368 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4369 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004370 /* need the manual connection? */
4371 if (nid >= 0x12) {
4372 int idx = nid - 0x12;
4373 snd_hda_codec_write(codec, idx + 0x0b, 0,
4374 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004375 }
4376}
4377
4378static void alc260_auto_init_multi_out(struct hda_codec *codec)
4379{
4380 struct alc_spec *spec = codec->spec;
4381 hda_nid_t nid;
4382
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004383 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004384 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004385 if (nid) {
4386 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4387 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4388 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004389
Takashi Iwai82bc9552006-03-21 11:24:42 +01004390 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004391 if (nid)
4392 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4393
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004394 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004395 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004396 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004397}
Kailang Yangdf694da2005-12-05 19:42:22 +01004398
4399#define ALC260_PIN_CD_NID 0x16
4400static void alc260_auto_init_analog_input(struct hda_codec *codec)
4401{
4402 struct alc_spec *spec = codec->spec;
4403 int i;
4404
4405 for (i = 0; i < AUTO_PIN_LAST; i++) {
4406 hda_nid_t nid = spec->autocfg.input_pins[i];
4407 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004408 snd_hda_codec_write(codec, nid, 0,
4409 AC_VERB_SET_PIN_WIDGET_CONTROL,
4410 i <= AUTO_PIN_FRONT_MIC ?
4411 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004412 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004413 snd_hda_codec_write(codec, nid, 0,
4414 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004415 AMP_OUT_MUTE);
4416 }
4417 }
4418}
4419
4420/*
4421 * generic initialization of ADC, input mixers and output mixers
4422 */
4423static struct hda_verb alc260_volume_init_verbs[] = {
4424 /*
4425 * Unmute ADC0-1 and set the default input to mic-in
4426 */
4427 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4428 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4429 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4430 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4431
4432 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4433 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004434 * Note: PASD motherboards uses the Line In 2 as the input for
4435 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004436 */
4437 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4441 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4443
4444 /*
4445 * Set up output mixers (0x08 - 0x0a)
4446 */
4447 /* set vol=0 to output mixers */
4448 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4450 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4451 /* set up input amps for analog loopback */
4452 /* Amp Indices: DAC = 0, mixer = 1 */
4453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4455 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4457 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4458 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4459
4460 { }
4461};
4462
4463static int alc260_parse_auto_config(struct hda_codec *codec)
4464{
4465 struct alc_spec *spec = codec->spec;
4466 unsigned int wcap;
4467 int err;
4468 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4469
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004470 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4471 alc260_ignore);
4472 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004473 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004474 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4475 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004476 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004477 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004478 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004479 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4480 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004481 return err;
4482
4483 spec->multiout.max_channels = 2;
4484
4485 if (spec->autocfg.dig_out_pin)
4486 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4487 if (spec->kctl_alloc)
4488 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4489
4490 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4491
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004492 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004493 spec->input_mux = &spec->private_imux;
4494
4495 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004496 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004497 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4498 if (wcap != AC_WID_AUD_IN) {
4499 spec->adc_nids = alc260_adc_nids_alt;
4500 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4501 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004502 } else {
4503 spec->adc_nids = alc260_adc_nids;
4504 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4505 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004506 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004507 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004508
4509 return 1;
4510}
4511
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004512/* additional initialization for auto-configuration model */
4513static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004514{
Kailang Yangdf694da2005-12-05 19:42:22 +01004515 alc260_auto_init_multi_out(codec);
4516 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004517}
4518
4519/*
4520 * ALC260 configurations
4521 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004522static const char *alc260_models[ALC260_MODEL_LAST] = {
4523 [ALC260_BASIC] = "basic",
4524 [ALC260_HP] = "hp",
4525 [ALC260_HP_3013] = "hp-3013",
4526 [ALC260_FUJITSU_S702X] = "fujitsu",
4527 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004528 [ALC260_WILL] = "will",
4529 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004530#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004531 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004532#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004533 [ALC260_AUTO] = "auto",
4534};
4535
4536static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004537 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004538 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004539 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004540 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004541 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4542 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4543 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4544 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4545 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4546 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4547 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4548 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4549 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4550 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4551 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4552 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004553 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4554 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004555 {}
4556};
4557
Kailang Yangdf694da2005-12-05 19:42:22 +01004558static struct alc_config_preset alc260_presets[] = {
4559 [ALC260_BASIC] = {
4560 .mixers = { alc260_base_output_mixer,
4561 alc260_input_mixer,
4562 alc260_pc_beep_mixer,
4563 alc260_capture_mixer },
4564 .init_verbs = { alc260_init_verbs },
4565 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4566 .dac_nids = alc260_dac_nids,
4567 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4568 .adc_nids = alc260_adc_nids,
4569 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4570 .channel_mode = alc260_modes,
4571 .input_mux = &alc260_capture_source,
4572 },
4573 [ALC260_HP] = {
4574 .mixers = { alc260_base_output_mixer,
4575 alc260_input_mixer,
4576 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004577 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004578 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4579 .dac_nids = alc260_dac_nids,
4580 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4581 .adc_nids = alc260_hp_adc_nids,
4582 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4583 .channel_mode = alc260_modes,
4584 .input_mux = &alc260_capture_source,
4585 },
4586 [ALC260_HP_3013] = {
4587 .mixers = { alc260_hp_3013_mixer,
4588 alc260_input_mixer,
4589 alc260_capture_alt_mixer },
4590 .init_verbs = { alc260_hp_3013_init_verbs },
4591 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4592 .dac_nids = alc260_dac_nids,
4593 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4594 .adc_nids = alc260_hp_adc_nids,
4595 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4596 .channel_mode = alc260_modes,
4597 .input_mux = &alc260_capture_source,
4598 },
4599 [ALC260_FUJITSU_S702X] = {
4600 .mixers = { alc260_fujitsu_mixer,
4601 alc260_capture_mixer },
4602 .init_verbs = { alc260_fujitsu_init_verbs },
4603 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4604 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004605 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4606 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004607 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4608 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004609 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4610 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004611 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004612 [ALC260_ACER] = {
4613 .mixers = { alc260_acer_mixer,
4614 alc260_capture_mixer },
4615 .init_verbs = { alc260_acer_init_verbs },
4616 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4617 .dac_nids = alc260_dac_nids,
4618 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4619 .adc_nids = alc260_dual_adc_nids,
4620 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4621 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004622 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4623 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004624 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004625 [ALC260_WILL] = {
4626 .mixers = { alc260_will_mixer,
4627 alc260_capture_mixer },
4628 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4629 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4630 .dac_nids = alc260_dac_nids,
4631 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4632 .adc_nids = alc260_adc_nids,
4633 .dig_out_nid = ALC260_DIGOUT_NID,
4634 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4635 .channel_mode = alc260_modes,
4636 .input_mux = &alc260_capture_source,
4637 },
4638 [ALC260_REPLACER_672V] = {
4639 .mixers = { alc260_replacer_672v_mixer,
4640 alc260_capture_mixer },
4641 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4642 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4643 .dac_nids = alc260_dac_nids,
4644 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4645 .adc_nids = alc260_adc_nids,
4646 .dig_out_nid = ALC260_DIGOUT_NID,
4647 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4648 .channel_mode = alc260_modes,
4649 .input_mux = &alc260_capture_source,
4650 .unsol_event = alc260_replacer_672v_unsol_event,
4651 .init_hook = alc260_replacer_672v_automute,
4652 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004653#ifdef CONFIG_SND_DEBUG
4654 [ALC260_TEST] = {
4655 .mixers = { alc260_test_mixer,
4656 alc260_capture_mixer },
4657 .init_verbs = { alc260_test_init_verbs },
4658 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4659 .dac_nids = alc260_test_dac_nids,
4660 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4661 .adc_nids = alc260_test_adc_nids,
4662 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4663 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004664 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4665 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004666 },
4667#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004668};
4669
Linus Torvalds1da177e2005-04-16 15:20:36 -07004670static int patch_alc260(struct hda_codec *codec)
4671{
4672 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004673 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004674
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004675 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004676 if (spec == NULL)
4677 return -ENOMEM;
4678
4679 codec->spec = spec;
4680
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004681 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4682 alc260_models,
4683 alc260_cfg_tbl);
4684 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004685 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4686 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004687 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004688 }
4689
Kailang Yangdf694da2005-12-05 19:42:22 +01004690 if (board_config == ALC260_AUTO) {
4691 /* automatic parse from the BIOS config */
4692 err = alc260_parse_auto_config(codec);
4693 if (err < 0) {
4694 alc_free(codec);
4695 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004696 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004697 printk(KERN_INFO
4698 "hda_codec: Cannot set up configuration "
4699 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004700 board_config = ALC260_BASIC;
4701 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004702 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004703
Kailang Yangdf694da2005-12-05 19:42:22 +01004704 if (board_config != ALC260_AUTO)
4705 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004706
4707 spec->stream_name_analog = "ALC260 Analog";
4708 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4709 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4710
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004711 spec->stream_name_digital = "ALC260 Digital";
4712 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4713 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4714
Linus Torvalds1da177e2005-04-16 15:20:36 -07004715 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004716 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004717 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004718
4719 return 0;
4720}
4721
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004722
Linus Torvalds1da177e2005-04-16 15:20:36 -07004723/*
4724 * ALC882 support
4725 *
4726 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4727 * configuration. Each pin widget can choose any input DACs and a mixer.
4728 * Each ADC is connected from a mixer of all inputs. This makes possible
4729 * 6-channel independent captures.
4730 *
4731 * In addition, an independent DAC for the multi-playback (not used in this
4732 * driver yet).
4733 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004734#define ALC882_DIGOUT_NID 0x06
4735#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004736
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004737static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004738 { 8, NULL }
4739};
4740
4741static hda_nid_t alc882_dac_nids[4] = {
4742 /* front, rear, clfe, rear_surr */
4743 0x02, 0x03, 0x04, 0x05
4744};
4745
Kailang Yangdf694da2005-12-05 19:42:22 +01004746/* identical with ALC880 */
4747#define alc882_adc_nids alc880_adc_nids
4748#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004749
4750/* input MUX */
4751/* FIXME: should be a matrix-type input source selection */
4752
4753static struct hda_input_mux alc882_capture_source = {
4754 .num_items = 4,
4755 .items = {
4756 { "Mic", 0x0 },
4757 { "Front Mic", 0x1 },
4758 { "Line", 0x2 },
4759 { "CD", 0x4 },
4760 },
4761};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004762#define alc882_mux_enum_info alc_mux_enum_info
4763#define alc882_mux_enum_get alc_mux_enum_get
4764
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004765static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4766 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004767{
4768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4769 struct alc_spec *spec = codec->spec;
4770 const struct hda_input_mux *imux = spec->input_mux;
4771 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4772 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4773 hda_nid_t nid = capture_mixers[adc_idx];
4774 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4775 unsigned int i, idx;
4776
4777 idx = ucontrol->value.enumerated.item[0];
4778 if (idx >= imux->num_items)
4779 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004780 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004781 return 0;
4782 for (i = 0; i < imux->num_items; i++) {
4783 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4784 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4785 v | (imux->items[i].index << 8));
4786 }
4787 *cur_val = idx;
4788 return 1;
4789}
4790
Kailang Yangdf694da2005-12-05 19:42:22 +01004791/*
Kailang Yang272a5272007-05-14 11:00:38 +02004792 * 2ch mode
4793 */
4794static struct hda_verb alc882_3ST_ch2_init[] = {
4795 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4796 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4797 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4798 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4799 { } /* end */
4800};
4801
4802/*
4803 * 6ch mode
4804 */
4805static struct hda_verb alc882_3ST_ch6_init[] = {
4806 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4807 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4808 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4809 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4810 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4811 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4812 { } /* end */
4813};
4814
4815static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4816 { 2, alc882_3ST_ch2_init },
4817 { 6, alc882_3ST_ch6_init },
4818};
4819
4820/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004821 * 6ch mode
4822 */
4823static struct hda_verb alc882_sixstack_ch6_init[] = {
4824 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4825 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4826 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4827 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4828 { } /* end */
4829};
4830
4831/*
4832 * 8ch mode
4833 */
4834static struct hda_verb alc882_sixstack_ch8_init[] = {
4835 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4836 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4837 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4838 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4839 { } /* end */
4840};
4841
4842static struct hda_channel_mode alc882_sixstack_modes[2] = {
4843 { 6, alc882_sixstack_ch6_init },
4844 { 8, alc882_sixstack_ch8_init },
4845};
4846
Linus Torvalds1da177e2005-04-16 15:20:36 -07004847/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4848 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4849 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004850static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004851 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004852 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004853 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004854 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004855 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4856 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004857 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4858 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004859 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004860 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4862 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4863 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4864 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4865 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004867 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4869 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004870 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004871 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4872 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4873 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004874 { } /* end */
4875};
4876
Kailang Yangbdd148a2007-05-08 15:19:08 +02004877static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4879 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4882 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4883 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4885 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4887 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4888 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4889 { } /* end */
4890};
4891
Kailang Yang272a5272007-05-14 11:00:38 +02004892static struct snd_kcontrol_new alc882_targa_mixer[] = {
4893 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4894 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4898 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4899 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4902 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4903 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4904 { } /* end */
4905};
4906
4907/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4908 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4909 */
4910static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4912 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4914 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4919 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4920 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4923 { } /* end */
4924};
4925
Kailang Yangdf694da2005-12-05 19:42:22 +01004926static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4927 {
4928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4929 .name = "Channel Mode",
4930 .info = alc_ch_mode_info,
4931 .get = alc_ch_mode_get,
4932 .put = alc_ch_mode_put,
4933 },
4934 { } /* end */
4935};
4936
Linus Torvalds1da177e2005-04-16 15:20:36 -07004937static struct hda_verb alc882_init_verbs[] = {
4938 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004939 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004942 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4945 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004946 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004947 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4948 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4949 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004950 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004951 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4952 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4953 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004954
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004955 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004956 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004957 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004958 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004959 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004962 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004963 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004964 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004965 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004966 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004967 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004968 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004969 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004970 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004971 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004972 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004973 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4974 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004975 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004976 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4977 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004978 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004979 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4980 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4983 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004984 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004985 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004986
4987 /* FIXME: use matrix-type input source selection */
4988 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4989 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004994 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4998 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004999 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5004 /* ADC1: mute amp left and right */
5005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005006 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005007 /* ADC2: mute amp left and right */
5008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005009 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005010 /* ADC3: mute amp left and right */
5011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005012 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005013
5014 { }
5015};
5016
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005017static struct hda_verb alc882_eapd_verbs[] = {
5018 /* change to EAPD mode */
5019 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005020 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005021 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005022};
5023
Tobin Davis9102cd12006-12-15 10:02:12 +01005024/* Mac Pro test */
5025static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5026 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5027 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5028 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5029 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5030 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5031 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5032 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5033 { } /* end */
5034};
5035
5036static struct hda_verb alc882_macpro_init_verbs[] = {
5037 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5041 /* Front Pin: output 0 (0x0c) */
5042 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5043 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5044 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5045 /* Front Mic pin: input vref at 80% */
5046 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5048 /* Speaker: output */
5049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5051 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5052 /* Headphone output (output 0 - 0x0c) */
5053 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5054 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5055 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5056
5057 /* FIXME: use matrix-type input source selection */
5058 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5059 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5064 /* Input mixer2 */
5065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5069 /* Input mixer3 */
5070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5074 /* ADC1: mute amp left and right */
5075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5076 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5077 /* ADC2: mute amp left and right */
5078 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5079 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5080 /* ADC3: mute amp left and right */
5081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5082 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5083
5084 { }
5085};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005086
Kailang Yang272a5272007-05-14 11:00:38 +02005087static struct hda_verb alc882_targa_verbs[] = {
5088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5090
5091 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5092 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5093
5094 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5095 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5096 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5097
5098 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5099 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5100 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5101 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5102 { } /* end */
5103};
5104
5105/* toggle speaker-output according to the hp-jack state */
5106static void alc882_targa_automute(struct hda_codec *codec)
5107{
5108 unsigned int present;
5109
5110 present = snd_hda_codec_read(codec, 0x14, 0,
5111 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5112 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5113 0x80, present ? 0x80 : 0);
5114 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5115 0x80, present ? 0x80 : 0);
5116 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5117}
5118
5119static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5120{
5121 /* Looks like the unsol event is incompatible with the standard
5122 * definition. 4bit tag is placed at 26 bit!
5123 */
5124 if (((res >> 26) == ALC880_HP_EVENT)) {
5125 alc882_targa_automute(codec);
5126 }
5127}
5128
5129static struct hda_verb alc882_asus_a7j_verbs[] = {
5130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5132
5133 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5135 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5136
5137 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5138 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5139 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5140
5141 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5142 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5143 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5144 { } /* end */
5145};
5146
Tobin Davis9102cd12006-12-15 10:02:12 +01005147static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5148{
5149 unsigned int gpiostate, gpiomask, gpiodir;
5150
5151 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5152 AC_VERB_GET_GPIO_DATA, 0);
5153
5154 if (!muted)
5155 gpiostate |= (1 << pin);
5156 else
5157 gpiostate &= ~(1 << pin);
5158
5159 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5160 AC_VERB_GET_GPIO_MASK, 0);
5161 gpiomask |= (1 << pin);
5162
5163 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5164 AC_VERB_GET_GPIO_DIRECTION, 0);
5165 gpiodir |= (1 << pin);
5166
5167
5168 snd_hda_codec_write(codec, codec->afg, 0,
5169 AC_VERB_SET_GPIO_MASK, gpiomask);
5170 snd_hda_codec_write(codec, codec->afg, 0,
5171 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5172
5173 msleep(1);
5174
5175 snd_hda_codec_write(codec, codec->afg, 0,
5176 AC_VERB_SET_GPIO_DATA, gpiostate);
5177}
5178
Kailang Yangdf694da2005-12-05 19:42:22 +01005179/*
5180 * generic initialization of ADC, input mixers and output mixers
5181 */
5182static struct hda_verb alc882_auto_init_verbs[] = {
5183 /*
5184 * Unmute ADC0-2 and set the default input to mic-in
5185 */
5186 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5188 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5190 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5192
5193 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5194 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005195 * Note: PASD motherboards uses the Line In 2 as the input for
5196 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005197 */
5198 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5204
5205 /*
5206 * Set up output mixers (0x0c - 0x0f)
5207 */
5208 /* set vol=0 to output mixers */
5209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5212 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5213 /* set up input amps for analog loopback */
5214 /* Amp Indices: DAC = 0, mixer = 1 */
5215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5221 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5222 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5223 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5224 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5225
5226 /* FIXME: use matrix-type input source selection */
5227 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5228 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5233 /* Input mixer2 */
5234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5237 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5238 /* Input mixer3 */
5239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5242 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5243
5244 { }
5245};
5246
5247/* capture mixer elements */
5248static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5249 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5250 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5251 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5252 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5253 {
5254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5255 /* The multiple "Capture Source" controls confuse alsamixer
5256 * So call somewhat different..
5257 * FIXME: the controls appear in the "playback" view!
5258 */
5259 /* .name = "Capture Source", */
5260 .name = "Input Source",
5261 .count = 2,
5262 .info = alc882_mux_enum_info,
5263 .get = alc882_mux_enum_get,
5264 .put = alc882_mux_enum_put,
5265 },
5266 { } /* end */
5267};
5268
5269static struct snd_kcontrol_new alc882_capture_mixer[] = {
5270 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5271 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5272 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5273 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5274 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5275 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5276 {
5277 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5278 /* The multiple "Capture Source" controls confuse alsamixer
5279 * So call somewhat different..
5280 * FIXME: the controls appear in the "playback" view!
5281 */
5282 /* .name = "Capture Source", */
5283 .name = "Input Source",
5284 .count = 3,
5285 .info = alc882_mux_enum_info,
5286 .get = alc882_mux_enum_get,
5287 .put = alc882_mux_enum_put,
5288 },
5289 { } /* end */
5290};
5291
5292/* pcm configuration: identiacal with ALC880 */
5293#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5294#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5295#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5296#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5297
5298/*
5299 * configuration and preset
5300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005301static const char *alc882_models[ALC882_MODEL_LAST] = {
5302 [ALC882_3ST_DIG] = "3stack-dig",
5303 [ALC882_6ST_DIG] = "6stack-dig",
5304 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005305 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005306 [ALC885_MACPRO] = "macpro",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005307 [ALC882_AUTO] = "auto",
5308};
5309
5310static struct snd_pci_quirk alc882_cfg_tbl[] = {
5311 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5312 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5313 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005314 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005315 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005316 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005317 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005318 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005319 {}
5320};
5321
5322static struct alc_config_preset alc882_presets[] = {
5323 [ALC882_3ST_DIG] = {
5324 .mixers = { alc882_base_mixer },
5325 .init_verbs = { alc882_init_verbs },
5326 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5327 .dac_nids = alc882_dac_nids,
5328 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005329 .dig_in_nid = ALC882_DIGIN_NID,
5330 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5331 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005332 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005333 .input_mux = &alc882_capture_source,
5334 },
5335 [ALC882_6ST_DIG] = {
5336 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5337 .init_verbs = { alc882_init_verbs },
5338 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5339 .dac_nids = alc882_dac_nids,
5340 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005341 .dig_in_nid = ALC882_DIGIN_NID,
5342 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5343 .channel_mode = alc882_sixstack_modes,
5344 .input_mux = &alc882_capture_source,
5345 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005346 [ALC882_ARIMA] = {
5347 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5348 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5349 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5350 .dac_nids = alc882_dac_nids,
5351 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5352 .channel_mode = alc882_sixstack_modes,
5353 .input_mux = &alc882_capture_source,
5354 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005355 [ALC882_W2JC] = {
5356 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5357 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5358 alc880_gpio1_init_verbs },
5359 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5360 .dac_nids = alc882_dac_nids,
5361 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5362 .channel_mode = alc880_threestack_modes,
5363 .need_dac_fix = 1,
5364 .input_mux = &alc882_capture_source,
5365 .dig_out_nid = ALC882_DIGOUT_NID,
5366 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005367 [ALC885_MACPRO] = {
5368 .mixers = { alc882_macpro_mixer },
5369 .init_verbs = { alc882_macpro_init_verbs },
5370 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5371 .dac_nids = alc882_dac_nids,
5372 .dig_out_nid = ALC882_DIGOUT_NID,
5373 .dig_in_nid = ALC882_DIGIN_NID,
5374 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5375 .channel_mode = alc882_ch_modes,
5376 .input_mux = &alc882_capture_source,
5377 },
Kailang Yang272a5272007-05-14 11:00:38 +02005378 [ALC882_TARGA] = {
5379 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5380 alc882_capture_mixer },
5381 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5382 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5383 .dac_nids = alc882_dac_nids,
5384 .dig_out_nid = ALC882_DIGOUT_NID,
5385 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5386 .adc_nids = alc882_adc_nids,
5387 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5388 .channel_mode = alc882_3ST_6ch_modes,
5389 .need_dac_fix = 1,
5390 .input_mux = &alc882_capture_source,
5391 .unsol_event = alc882_targa_unsol_event,
5392 .init_hook = alc882_targa_automute,
5393 },
5394 [ALC882_ASUS_A7J] = {
5395 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5396 alc882_capture_mixer },
5397 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5398 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5399 .dac_nids = alc882_dac_nids,
5400 .dig_out_nid = ALC882_DIGOUT_NID,
5401 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5402 .adc_nids = alc882_adc_nids,
5403 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5404 .channel_mode = alc882_3ST_6ch_modes,
5405 .need_dac_fix = 1,
5406 .input_mux = &alc882_capture_source,
5407 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005408};
5409
5410
5411/*
5412 * BIOS auto configuration
5413 */
5414static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5415 hda_nid_t nid, int pin_type,
5416 int dac_idx)
5417{
5418 /* set as output */
5419 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005420 int idx;
5421
Kailang Yangdf694da2005-12-05 19:42:22 +01005422 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5423 idx = 4;
5424 else
5425 idx = spec->multiout.dac_nids[dac_idx] - 2;
5426
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005427 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5428 pin_type);
5429 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5430 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005431 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5432
5433}
5434
5435static void alc882_auto_init_multi_out(struct hda_codec *codec)
5436{
5437 struct alc_spec *spec = codec->spec;
5438 int i;
5439
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005440 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005441 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005442 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005443 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005444 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005445 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005446 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005447 }
5448}
5449
5450static void alc882_auto_init_hp_out(struct hda_codec *codec)
5451{
5452 struct alc_spec *spec = codec->spec;
5453 hda_nid_t pin;
5454
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005455 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005456 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005457 /* use dac 0 */
5458 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005459}
5460
5461#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5462#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5463
5464static void alc882_auto_init_analog_input(struct hda_codec *codec)
5465{
5466 struct alc_spec *spec = codec->spec;
5467 int i;
5468
5469 for (i = 0; i < AUTO_PIN_LAST; i++) {
5470 hda_nid_t nid = spec->autocfg.input_pins[i];
5471 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005472 snd_hda_codec_write(codec, nid, 0,
5473 AC_VERB_SET_PIN_WIDGET_CONTROL,
5474 i <= AUTO_PIN_FRONT_MIC ?
5475 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005476 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005477 snd_hda_codec_write(codec, nid, 0,
5478 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005479 AMP_OUT_MUTE);
5480 }
5481 }
5482}
5483
5484/* almost identical with ALC880 parser... */
5485static int alc882_parse_auto_config(struct hda_codec *codec)
5486{
5487 struct alc_spec *spec = codec->spec;
5488 int err = alc880_parse_auto_config(codec);
5489
5490 if (err < 0)
5491 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005492 else if (err > 0)
5493 /* hack - override the init verbs */
5494 spec->init_verbs[0] = alc882_auto_init_verbs;
5495 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005496}
5497
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005498/* additional initialization for auto-configuration model */
5499static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005500{
Kailang Yangdf694da2005-12-05 19:42:22 +01005501 alc882_auto_init_multi_out(codec);
5502 alc882_auto_init_hp_out(codec);
5503 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005504}
5505
Linus Torvalds1da177e2005-04-16 15:20:36 -07005506static int patch_alc882(struct hda_codec *codec)
5507{
5508 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005509 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005511 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005512 if (spec == NULL)
5513 return -ENOMEM;
5514
Linus Torvalds1da177e2005-04-16 15:20:36 -07005515 codec->spec = spec;
5516
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005517 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5518 alc882_models,
5519 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005520
Kailang Yangdf694da2005-12-05 19:42:22 +01005521 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005522 /* Pick up systems that don't supply PCI SSID */
5523 switch (codec->subsystem_id) {
5524 case 0x106b0c00: /* Mac Pro */
5525 board_config = ALC885_MACPRO;
5526 break;
5527 default:
5528 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5529 "trying auto-probe from BIOS...\n");
5530 board_config = ALC882_AUTO;
5531 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005532 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005533
Kailang Yangdf694da2005-12-05 19:42:22 +01005534 if (board_config == ALC882_AUTO) {
5535 /* automatic parse from the BIOS config */
5536 err = alc882_parse_auto_config(codec);
5537 if (err < 0) {
5538 alc_free(codec);
5539 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005540 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005541 printk(KERN_INFO
5542 "hda_codec: Cannot set up configuration "
5543 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005544 board_config = ALC882_3ST_DIG;
5545 }
5546 }
5547
5548 if (board_config != ALC882_AUTO)
5549 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005550
Tobin Davis9102cd12006-12-15 10:02:12 +01005551 if (board_config == ALC885_MACPRO) {
5552 alc882_gpio_mute(codec, 0, 0);
5553 alc882_gpio_mute(codec, 1, 0);
5554 }
5555
Linus Torvalds1da177e2005-04-16 15:20:36 -07005556 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005557 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5558 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005559
5560 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005561 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5562 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005563
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005564 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005565 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005566 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005567 /* get type */
5568 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005569 if (wcap != AC_WID_AUD_IN) {
5570 spec->adc_nids = alc882_adc_nids_alt;
5571 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005572 spec->mixers[spec->num_mixers] =
5573 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005574 spec->num_mixers++;
5575 } else {
5576 spec->adc_nids = alc882_adc_nids;
5577 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5578 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5579 spec->num_mixers++;
5580 }
5581 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005582
5583 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005584 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005585 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005586
5587 return 0;
5588}
5589
5590/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005591 * ALC883 support
5592 *
5593 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5594 * configuration. Each pin widget can choose any input DACs and a mixer.
5595 * Each ADC is connected from a mixer of all inputs. This makes possible
5596 * 6-channel independent captures.
5597 *
5598 * In addition, an independent DAC for the multi-playback (not used in this
5599 * driver yet).
5600 */
5601#define ALC883_DIGOUT_NID 0x06
5602#define ALC883_DIGIN_NID 0x0a
5603
5604static hda_nid_t alc883_dac_nids[4] = {
5605 /* front, rear, clfe, rear_surr */
5606 0x02, 0x04, 0x03, 0x05
5607};
5608
5609static hda_nid_t alc883_adc_nids[2] = {
5610 /* ADC1-2 */
5611 0x08, 0x09,
5612};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005613
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005614/* input MUX */
5615/* FIXME: should be a matrix-type input source selection */
5616
5617static struct hda_input_mux alc883_capture_source = {
5618 .num_items = 4,
5619 .items = {
5620 { "Mic", 0x0 },
5621 { "Front Mic", 0x1 },
5622 { "Line", 0x2 },
5623 { "CD", 0x4 },
5624 },
5625};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005626
5627static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5628 .num_items = 2,
5629 .items = {
5630 { "Mic", 0x1 },
5631 { "Line", 0x2 },
5632 },
5633};
5634
Kailang Yang272a5272007-05-14 11:00:38 +02005635static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5636 .num_items = 4,
5637 .items = {
5638 { "Mic", 0x0 },
5639 { "iMic", 0x1 },
5640 { "Line", 0x2 },
5641 { "CD", 0x4 },
5642 },
5643};
5644
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005645#define alc883_mux_enum_info alc_mux_enum_info
5646#define alc883_mux_enum_get alc_mux_enum_get
5647
5648static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5649 struct snd_ctl_elem_value *ucontrol)
5650{
5651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5652 struct alc_spec *spec = codec->spec;
5653 const struct hda_input_mux *imux = spec->input_mux;
5654 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5655 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5656 hda_nid_t nid = capture_mixers[adc_idx];
5657 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5658 unsigned int i, idx;
5659
5660 idx = ucontrol->value.enumerated.item[0];
5661 if (idx >= imux->num_items)
5662 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005663 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005664 return 0;
5665 for (i = 0; i < imux->num_items; i++) {
5666 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5667 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5668 v | (imux->items[i].index << 8));
5669 }
5670 *cur_val = idx;
5671 return 1;
5672}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005673
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005674/*
5675 * 2ch mode
5676 */
5677static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5678 { 2, NULL }
5679};
5680
5681/*
5682 * 2ch mode
5683 */
5684static struct hda_verb alc883_3ST_ch2_init[] = {
5685 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5686 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5687 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5688 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5689 { } /* end */
5690};
5691
5692/*
5693 * 6ch mode
5694 */
5695static struct hda_verb alc883_3ST_ch6_init[] = {
5696 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5697 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5698 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5699 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5700 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5701 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5702 { } /* end */
5703};
5704
5705static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5706 { 2, alc883_3ST_ch2_init },
5707 { 6, alc883_3ST_ch6_init },
5708};
5709
5710/*
5711 * 6ch mode
5712 */
5713static struct hda_verb alc883_sixstack_ch6_init[] = {
5714 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5715 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5716 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5717 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5718 { } /* end */
5719};
5720
5721/*
5722 * 8ch mode
5723 */
5724static struct hda_verb alc883_sixstack_ch8_init[] = {
5725 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5726 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5727 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5728 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5729 { } /* end */
5730};
5731
5732static struct hda_channel_mode alc883_sixstack_modes[2] = {
5733 { 6, alc883_sixstack_ch6_init },
5734 { 8, alc883_sixstack_ch8_init },
5735};
5736
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005737static struct hda_verb alc883_medion_eapd_verbs[] = {
5738 /* eanable EAPD on medion laptop */
5739 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5740 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5741 { }
5742};
5743
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005744/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5745 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5746 */
5747
5748static struct snd_kcontrol_new alc883_base_mixer[] = {
5749 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5750 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5751 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5752 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5753 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5754 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5755 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5756 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5757 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5758 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5759 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5760 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5761 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5762 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5763 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005765 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005766 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005768 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005769 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5770 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5771 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5772 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5773 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5774 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5775 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5776 {
5777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5778 /* .name = "Capture Source", */
5779 .name = "Input Source",
5780 .count = 2,
5781 .info = alc883_mux_enum_info,
5782 .get = alc883_mux_enum_get,
5783 .put = alc883_mux_enum_put,
5784 },
5785 { } /* end */
5786};
5787
5788static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5789 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5790 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005800 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5802 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5803 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5804 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5805 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5806 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5807 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5808 {
5809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5810 /* .name = "Capture Source", */
5811 .name = "Input Source",
5812 .count = 2,
5813 .info = alc883_mux_enum_info,
5814 .get = alc883_mux_enum_get,
5815 .put = alc883_mux_enum_put,
5816 },
5817 { } /* end */
5818};
5819
5820static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5821 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5822 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5823 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5824 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5825 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5826 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5827 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5828 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5830 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5831 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5832 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5833 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5837 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5840 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5841 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5842 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5843 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5844 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5845 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5846 {
5847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5848 /* .name = "Capture Source", */
5849 .name = "Input Source",
5850 .count = 2,
5851 .info = alc883_mux_enum_info,
5852 .get = alc883_mux_enum_get,
5853 .put = alc883_mux_enum_put,
5854 },
5855 { } /* end */
5856};
5857
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005858static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5860 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5861 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5862 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5863 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5865 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5866 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005873 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005876 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5878 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5879 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5880 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5881 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5882
5883 {
5884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5885 /* .name = "Capture Source", */
5886 .name = "Input Source",
5887 .count = 1,
5888 .info = alc883_mux_enum_info,
5889 .get = alc883_mux_enum_get,
5890 .put = alc883_mux_enum_put,
5891 },
5892 { } /* end */
5893};
5894
Kailang Yangccc656c2006-10-17 12:32:26 +02005895static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5896 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5898 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5899 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5900 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5901 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5902 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5903 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5904 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5905 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5906 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5907 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5908 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005910 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5912 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5913 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5914 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5915 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5916 {
5917 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5918 /* .name = "Capture Source", */
5919 .name = "Input Source",
5920 .count = 2,
5921 .info = alc883_mux_enum_info,
5922 .get = alc883_mux_enum_get,
5923 .put = alc883_mux_enum_put,
5924 },
5925 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005926};
Kailang Yangccc656c2006-10-17 12:32:26 +02005927
5928static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5931 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005935 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5937 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5938 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5939 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5940 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5941 {
5942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5943 /* .name = "Capture Source", */
5944 .name = "Input Source",
5945 .count = 2,
5946 .info = alc883_mux_enum_info,
5947 .get = alc883_mux_enum_get,
5948 .put = alc883_mux_enum_put,
5949 },
5950 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005951};
Kailang Yangccc656c2006-10-17 12:32:26 +02005952
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005953static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5954 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5955 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5956 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5957 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5962 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5963 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5964 {
5965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5966 /* .name = "Capture Source", */
5967 .name = "Input Source",
5968 .count = 1,
5969 .info = alc883_mux_enum_info,
5970 .get = alc883_mux_enum_get,
5971 .put = alc883_mux_enum_put,
5972 },
5973 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005974};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005975
Kailang Yang272a5272007-05-14 11:00:38 +02005976static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
5977 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5978 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
5979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5984 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5985 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5986 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5987 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5988 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5989 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5990 {
5991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5992 /* .name = "Capture Source", */
5993 .name = "Input Source",
5994 .count = 2,
5995 .info = alc883_mux_enum_info,
5996 .get = alc883_mux_enum_get,
5997 .put = alc883_mux_enum_put,
5998 },
5999 { } /* end */
6000};
6001
6002static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6005 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6012 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6013 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6014 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6015 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6016 {
6017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6018 /* .name = "Capture Source", */
6019 .name = "Input Source",
6020 .count = 2,
6021 .info = alc883_mux_enum_info,
6022 .get = alc883_mux_enum_get,
6023 .put = alc883_mux_enum_put,
6024 },
6025 { } /* end */
6026};
6027
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006028static struct snd_kcontrol_new alc888_hp_nettle_mixer[] = {
6029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6030 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6032 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6033 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6034 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6035 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6036 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6037 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6038 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6040 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6041 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6047 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6048 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6050 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6051 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6052 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6053 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6054 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6055 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6056 {
6057 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6058 /* .name = "Capture Source", */
6059 .name = "Input Source",
6060 .count = 2,
6061 .info = alc883_mux_enum_info,
6062 .get = alc883_mux_enum_get,
6063 .put = alc883_mux_enum_put,
6064 },
6065 { } /* end */
6066};
6067
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006068static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6069 {
6070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6071 .name = "Channel Mode",
6072 .info = alc_ch_mode_info,
6073 .get = alc_ch_mode_get,
6074 .put = alc_ch_mode_put,
6075 },
6076 { } /* end */
6077};
6078
6079static struct hda_verb alc883_init_verbs[] = {
6080 /* ADC1: mute amp left and right */
6081 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6082 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6083 /* ADC2: mute amp left and right */
6084 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6085 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6086 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6090 /* Rear mixer */
6091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6093 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6094 /* CLFE mixer */
6095 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6096 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6097 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6098 /* Side mixer */
6099 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6100 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6101 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6102
6103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6108
6109 /* Front Pin: output 0 (0x0c) */
6110 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6111 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6112 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6113 /* Rear Pin: output 1 (0x0d) */
6114 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6116 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6117 /* CLFE Pin: output 2 (0x0e) */
6118 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6119 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6120 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6121 /* Side Pin: output 3 (0x0f) */
6122 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6123 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6124 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6125 /* Mic (rear) pin: input vref at 80% */
6126 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6127 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6128 /* Front Mic pin: input vref at 80% */
6129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6130 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6131 /* Line In pin: input */
6132 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6133 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6134 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6137 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6138 /* CD pin widget for input */
6139 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6140
6141 /* FIXME: use matrix-type input source selection */
6142 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6143 /* Input mixer2 */
6144 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6146 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6147 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6148 /* Input mixer3 */
6149 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6152 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6153 { }
6154};
6155
Kailang Yangccc656c2006-10-17 12:32:26 +02006156static struct hda_verb alc883_tagra_verbs[] = {
6157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6159
6160 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6161 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6162
6163 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6164 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6165 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6166
6167 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006168 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6169 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6170 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006171
6172 { } /* end */
6173};
6174
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006175static struct hda_verb alc883_lenovo_101e_verbs[] = {
6176 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6177 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6178 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6179 { } /* end */
6180};
6181
Kailang Yang272a5272007-05-14 11:00:38 +02006182static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6183 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6185 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6186 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6187 { } /* end */
6188};
6189
6190static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6193 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6194 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6195 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6196 { } /* end */
6197};
6198
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006199static struct hda_verb alc888_hp_nettle_verbs[] = {
6200 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6201 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6202 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6203 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6204 { }
6205};
6206
Kailang Yang272a5272007-05-14 11:00:38 +02006207/* toggle front-jack and RCA according to the hp-jack state */
6208static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6209{
6210 unsigned int present;
6211
6212 present = snd_hda_codec_read(codec, 0x1b, 0,
6213 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6214 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6215 0x80, present ? 0x80 : 0);
6216 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6217 0x80, present ? 0x80 : 0);
6218 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6219 0x80, present ? 0x80 : 0);
6220 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6221 0x80, present ? 0x80 : 0);
6222
6223}
6224
6225/* toggle RCA according to the front-jack state */
6226static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6227{
6228 unsigned int present;
6229
6230 present = snd_hda_codec_read(codec, 0x14, 0,
6231 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6232 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6233 0x80, present ? 0x80 : 0);
6234 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6235 0x80, present ? 0x80 : 0);
6236
6237}
6238static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6239 unsigned int res)
6240{
6241 if ((res >> 26) == ALC880_HP_EVENT)
6242 alc888_lenovo_ms7195_front_automute(codec);
6243 if ((res >> 26) == ALC880_FRONT_EVENT)
6244 alc888_lenovo_ms7195_rca_automute(codec);
6245}
6246
6247static struct hda_verb alc883_medion_md2_verbs[] = {
6248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6250
6251 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6252
6253 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6254 { } /* end */
6255};
6256
6257/* toggle speaker-output according to the hp-jack state */
6258static void alc883_medion_md2_automute(struct hda_codec *codec)
6259{
6260 unsigned int present;
6261
6262 present = snd_hda_codec_read(codec, 0x14, 0,
6263 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6264 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6265 0x80, present ? 0x80 : 0);
6266 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6267 0x80, present ? 0x80 : 0);
6268}
6269
6270static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6271 unsigned int res)
6272{
6273 if ((res >> 26) == ALC880_HP_EVENT)
6274 alc883_medion_md2_automute(codec);
6275}
6276
Kailang Yangccc656c2006-10-17 12:32:26 +02006277/* toggle speaker-output according to the hp-jack state */
6278static void alc883_tagra_automute(struct hda_codec *codec)
6279{
6280 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006281 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006282
6283 present = snd_hda_codec_read(codec, 0x14, 0,
6284 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006285 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006286 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006287 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006288 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006289 0x80, bits);
6290 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6291 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006292}
6293
6294static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6295{
6296 if ((res >> 26) == ALC880_HP_EVENT)
6297 alc883_tagra_automute(codec);
6298}
6299
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006300static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6301{
6302 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006303 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006304
6305 present = snd_hda_codec_read(codec, 0x14, 0,
6306 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006307 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006308 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006309 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006310 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006311 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006312}
6313
6314static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6315{
6316 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006317 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006318
6319 present = snd_hda_codec_read(codec, 0x1b, 0,
6320 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006321 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006322 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006323 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006324 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006325 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006326 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006327 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006328 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006329 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006330}
6331
6332static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6333 unsigned int res)
6334{
6335 if ((res >> 26) == ALC880_HP_EVENT)
6336 alc883_lenovo_101e_all_automute(codec);
6337 if ((res >> 26) == ALC880_FRONT_EVENT)
6338 alc883_lenovo_101e_ispeaker_automute(codec);
6339}
6340
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006341/*
6342 * generic initialization of ADC, input mixers and output mixers
6343 */
6344static struct hda_verb alc883_auto_init_verbs[] = {
6345 /*
6346 * Unmute ADC0-2 and set the default input to mic-in
6347 */
6348 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6349 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6350 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6352
6353 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6354 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006355 * Note: PASD motherboards uses the Line In 2 as the input for
6356 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006357 */
6358 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6361 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6362 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6364
6365 /*
6366 * Set up output mixers (0x0c - 0x0f)
6367 */
6368 /* set vol=0 to output mixers */
6369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6372 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6373 /* set up input amps for analog loopback */
6374 /* Amp Indices: DAC = 0, mixer = 1 */
6375 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6381 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6382 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6383 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6384 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6385
6386 /* FIXME: use matrix-type input source selection */
6387 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6388 /* Input mixer1 */
6389 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006392 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6394 /* Input mixer2 */
6395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006398 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006399 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6400
6401 { }
6402};
6403
6404/* capture mixer elements */
6405static struct snd_kcontrol_new alc883_capture_mixer[] = {
6406 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6407 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6408 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6409 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6410 {
6411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6412 /* The multiple "Capture Source" controls confuse alsamixer
6413 * So call somewhat different..
6414 * FIXME: the controls appear in the "playback" view!
6415 */
6416 /* .name = "Capture Source", */
6417 .name = "Input Source",
6418 .count = 2,
6419 .info = alc882_mux_enum_info,
6420 .get = alc882_mux_enum_get,
6421 .put = alc882_mux_enum_put,
6422 },
6423 { } /* end */
6424};
6425
6426/* pcm configuration: identiacal with ALC880 */
6427#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6428#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6429#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6430#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6431
6432/*
6433 * configuration and preset
6434 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006435static const char *alc883_models[ALC883_MODEL_LAST] = {
6436 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6437 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6438 [ALC883_3ST_6ch] = "3stack-6ch",
6439 [ALC883_6ST_DIG] = "6stack-dig",
6440 [ALC883_TARGA_DIG] = "targa-dig",
6441 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006442 [ALC883_ACER] = "acer",
6443 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006444 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006445 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006446 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006447 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6448 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006449 [ALC888_HP_NETTLE] = "hp-nettle",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006450 [ALC883_AUTO] = "auto",
6451};
6452
6453static struct snd_pci_quirk alc883_cfg_tbl[] = {
6454 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006455 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006456 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6457 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6458 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006459 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006460 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6461 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006462 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006463 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006464 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006465 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006466 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006467 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6468 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6469 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6470 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6471 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6472 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6473 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6474 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6475 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6476 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006477 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006478 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6479 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6480 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006481 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6482 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6483 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006484 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_HP_NETTLE),
Kailang Yang272a5272007-05-14 11:00:38 +02006485 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006486 {}
6487};
6488
6489static struct alc_config_preset alc883_presets[] = {
6490 [ALC883_3ST_2ch_DIG] = {
6491 .mixers = { alc883_3ST_2ch_mixer },
6492 .init_verbs = { alc883_init_verbs },
6493 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6494 .dac_nids = alc883_dac_nids,
6495 .dig_out_nid = ALC883_DIGOUT_NID,
6496 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6497 .adc_nids = alc883_adc_nids,
6498 .dig_in_nid = ALC883_DIGIN_NID,
6499 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6500 .channel_mode = alc883_3ST_2ch_modes,
6501 .input_mux = &alc883_capture_source,
6502 },
6503 [ALC883_3ST_6ch_DIG] = {
6504 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6505 .init_verbs = { alc883_init_verbs },
6506 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6507 .dac_nids = alc883_dac_nids,
6508 .dig_out_nid = ALC883_DIGOUT_NID,
6509 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6510 .adc_nids = alc883_adc_nids,
6511 .dig_in_nid = ALC883_DIGIN_NID,
6512 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6513 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006514 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006515 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006516 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006517 [ALC883_3ST_6ch] = {
6518 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6519 .init_verbs = { alc883_init_verbs },
6520 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6521 .dac_nids = alc883_dac_nids,
6522 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6523 .adc_nids = alc883_adc_nids,
6524 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6525 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006526 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006527 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006528 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006529 [ALC883_6ST_DIG] = {
6530 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6531 .init_verbs = { alc883_init_verbs },
6532 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6533 .dac_nids = alc883_dac_nids,
6534 .dig_out_nid = ALC883_DIGOUT_NID,
6535 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6536 .adc_nids = alc883_adc_nids,
6537 .dig_in_nid = ALC883_DIGIN_NID,
6538 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6539 .channel_mode = alc883_sixstack_modes,
6540 .input_mux = &alc883_capture_source,
6541 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006542 [ALC883_TARGA_DIG] = {
6543 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6544 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6546 .dac_nids = alc883_dac_nids,
6547 .dig_out_nid = ALC883_DIGOUT_NID,
6548 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6549 .adc_nids = alc883_adc_nids,
6550 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6551 .channel_mode = alc883_3ST_6ch_modes,
6552 .need_dac_fix = 1,
6553 .input_mux = &alc883_capture_source,
6554 .unsol_event = alc883_tagra_unsol_event,
6555 .init_hook = alc883_tagra_automute,
6556 },
6557 [ALC883_TARGA_2ch_DIG] = {
6558 .mixers = { alc883_tagra_2ch_mixer},
6559 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6561 .dac_nids = alc883_dac_nids,
6562 .dig_out_nid = ALC883_DIGOUT_NID,
6563 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6564 .adc_nids = alc883_adc_nids,
6565 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6566 .channel_mode = alc883_3ST_2ch_modes,
6567 .input_mux = &alc883_capture_source,
6568 .unsol_event = alc883_tagra_unsol_event,
6569 .init_hook = alc883_tagra_automute,
6570 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02006571 [ALC883_ACER] = {
6572 .mixers = { alc883_base_mixer,
6573 alc883_chmode_mixer },
6574 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6575 * and the headphone jack. Turn this on and rely on the
6576 * standard mute methods whenever the user wants to turn
6577 * these outputs off.
6578 */
6579 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6580 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6581 .dac_nids = alc883_dac_nids,
6582 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6583 .adc_nids = alc883_adc_nids,
6584 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6585 .channel_mode = alc883_3ST_2ch_modes,
6586 .input_mux = &alc883_capture_source,
6587 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006588 [ALC883_MEDION] = {
6589 .mixers = { alc883_fivestack_mixer,
6590 alc883_chmode_mixer },
6591 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006592 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006593 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6594 .dac_nids = alc883_dac_nids,
6595 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6596 .adc_nids = alc883_adc_nids,
6597 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6598 .channel_mode = alc883_sixstack_modes,
6599 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006600 },
Kailang Yang272a5272007-05-14 11:00:38 +02006601 [ALC883_MEDION_MD2] = {
6602 .mixers = { alc883_medion_md2_mixer},
6603 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6604 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6605 .dac_nids = alc883_dac_nids,
6606 .dig_out_nid = ALC883_DIGOUT_NID,
6607 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6608 .adc_nids = alc883_adc_nids,
6609 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6610 .channel_mode = alc883_3ST_2ch_modes,
6611 .input_mux = &alc883_capture_source,
6612 .unsol_event = alc883_medion_md2_unsol_event,
6613 .init_hook = alc883_medion_md2_automute,
6614 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006615 [ALC883_LAPTOP_EAPD] = {
6616 .mixers = { alc883_base_mixer,
6617 alc883_chmode_mixer },
6618 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6620 .dac_nids = alc883_dac_nids,
6621 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6622 .adc_nids = alc883_adc_nids,
6623 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6624 .channel_mode = alc883_3ST_2ch_modes,
6625 .input_mux = &alc883_capture_source,
6626 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006627 [ALC883_LENOVO_101E_2ch] = {
6628 .mixers = { alc883_lenovo_101e_2ch_mixer},
6629 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6630 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6631 .dac_nids = alc883_dac_nids,
6632 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6633 .adc_nids = alc883_adc_nids,
6634 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6635 .channel_mode = alc883_3ST_2ch_modes,
6636 .input_mux = &alc883_lenovo_101e_capture_source,
6637 .unsol_event = alc883_lenovo_101e_unsol_event,
6638 .init_hook = alc883_lenovo_101e_all_automute,
6639 },
Kailang Yang272a5272007-05-14 11:00:38 +02006640 [ALC883_LENOVO_NB0763] = {
6641 .mixers = { alc883_lenovo_nb0763_mixer },
6642 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6643 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6644 .dac_nids = alc883_dac_nids,
6645 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6646 .adc_nids = alc883_adc_nids,
6647 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6648 .channel_mode = alc883_3ST_2ch_modes,
6649 .need_dac_fix = 1,
6650 .input_mux = &alc883_lenovo_nb0763_capture_source,
6651 .unsol_event = alc883_medion_md2_unsol_event,
6652 .init_hook = alc883_medion_md2_automute,
6653 },
6654 [ALC888_LENOVO_MS7195_DIG] = {
6655 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6656 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6657 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6658 .dac_nids = alc883_dac_nids,
6659 .dig_out_nid = ALC883_DIGOUT_NID,
6660 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6661 .adc_nids = alc883_adc_nids,
6662 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6663 .channel_mode = alc883_3ST_6ch_modes,
6664 .need_dac_fix = 1,
6665 .input_mux = &alc883_capture_source,
6666 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6667 .init_hook = alc888_lenovo_ms7195_front_automute,
6668 },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006669 [ALC888_HP_NETTLE] = {
6670 .mixers = { alc888_hp_nettle_mixer, alc883_chmode_mixer },
6671 .init_verbs = { alc883_init_verbs, alc888_hp_nettle_verbs },
6672 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6673 .dac_nids = alc883_dac_nids,
6674 .dig_out_nid = ALC883_DIGOUT_NID,
6675 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6676 .adc_nids = alc883_adc_nids,
6677 .dig_in_nid = ALC883_DIGIN_NID,
6678 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6679 .channel_mode = alc883_sixstack_modes,
6680 .input_mux = &alc883_capture_source,
6681 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006682};
6683
6684
6685/*
6686 * BIOS auto configuration
6687 */
6688static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6689 hda_nid_t nid, int pin_type,
6690 int dac_idx)
6691{
6692 /* set as output */
6693 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006694 int idx;
6695
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006696 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6697 idx = 4;
6698 else
6699 idx = spec->multiout.dac_nids[dac_idx] - 2;
6700
6701 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6702 pin_type);
6703 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6704 AMP_OUT_UNMUTE);
6705 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6706
6707}
6708
6709static void alc883_auto_init_multi_out(struct hda_codec *codec)
6710{
6711 struct alc_spec *spec = codec->spec;
6712 int i;
6713
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006714 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006715 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006716 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006717 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006718 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006719 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006720 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006721 }
6722}
6723
6724static void alc883_auto_init_hp_out(struct hda_codec *codec)
6725{
6726 struct alc_spec *spec = codec->spec;
6727 hda_nid_t pin;
6728
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006729 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006730 if (pin) /* connect to front */
6731 /* use dac 0 */
6732 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6733}
6734
6735#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6736#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6737
6738static void alc883_auto_init_analog_input(struct hda_codec *codec)
6739{
6740 struct alc_spec *spec = codec->spec;
6741 int i;
6742
6743 for (i = 0; i < AUTO_PIN_LAST; i++) {
6744 hda_nid_t nid = spec->autocfg.input_pins[i];
6745 if (alc883_is_input_pin(nid)) {
6746 snd_hda_codec_write(codec, nid, 0,
6747 AC_VERB_SET_PIN_WIDGET_CONTROL,
6748 (i <= AUTO_PIN_FRONT_MIC ?
6749 PIN_VREF80 : PIN_IN));
6750 if (nid != ALC883_PIN_CD_NID)
6751 snd_hda_codec_write(codec, nid, 0,
6752 AC_VERB_SET_AMP_GAIN_MUTE,
6753 AMP_OUT_MUTE);
6754 }
6755 }
6756}
6757
6758/* almost identical with ALC880 parser... */
6759static int alc883_parse_auto_config(struct hda_codec *codec)
6760{
6761 struct alc_spec *spec = codec->spec;
6762 int err = alc880_parse_auto_config(codec);
6763
6764 if (err < 0)
6765 return err;
6766 else if (err > 0)
6767 /* hack - override the init verbs */
6768 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006769 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6770 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006771 return err;
6772}
6773
6774/* additional initialization for auto-configuration model */
6775static void alc883_auto_init(struct hda_codec *codec)
6776{
6777 alc883_auto_init_multi_out(codec);
6778 alc883_auto_init_hp_out(codec);
6779 alc883_auto_init_analog_input(codec);
6780}
6781
6782static int patch_alc883(struct hda_codec *codec)
6783{
6784 struct alc_spec *spec;
6785 int err, board_config;
6786
6787 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6788 if (spec == NULL)
6789 return -ENOMEM;
6790
6791 codec->spec = spec;
6792
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006793 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6794 alc883_models,
6795 alc883_cfg_tbl);
6796 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006797 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6798 "trying auto-probe from BIOS...\n");
6799 board_config = ALC883_AUTO;
6800 }
6801
6802 if (board_config == ALC883_AUTO) {
6803 /* automatic parse from the BIOS config */
6804 err = alc883_parse_auto_config(codec);
6805 if (err < 0) {
6806 alc_free(codec);
6807 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006808 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006809 printk(KERN_INFO
6810 "hda_codec: Cannot set up configuration "
6811 "from BIOS. Using base mode...\n");
6812 board_config = ALC883_3ST_2ch_DIG;
6813 }
6814 }
6815
6816 if (board_config != ALC883_AUTO)
6817 setup_preset(spec, &alc883_presets[board_config]);
6818
6819 spec->stream_name_analog = "ALC883 Analog";
6820 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6821 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6822
6823 spec->stream_name_digital = "ALC883 Digital";
6824 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6825 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6826
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006827 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006828 spec->adc_nids = alc883_adc_nids;
6829 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6830 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006831
6832 codec->patch_ops = alc_patch_ops;
6833 if (board_config == ALC883_AUTO)
6834 spec->init_hook = alc883_auto_init;
6835
6836 return 0;
6837}
6838
6839/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006840 * ALC262 support
6841 */
6842
6843#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6844#define ALC262_DIGIN_NID ALC880_DIGIN_NID
6845
6846#define alc262_dac_nids alc260_dac_nids
6847#define alc262_adc_nids alc882_adc_nids
6848#define alc262_adc_nids_alt alc882_adc_nids_alt
6849
6850#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01006851#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01006852
6853static struct snd_kcontrol_new alc262_base_mixer[] = {
6854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6855 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6856 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6857 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6858 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6859 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006862 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006863 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6864 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006865 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006866 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6867 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6868 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6869 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6870 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6871 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006872 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01006873};
6874
Kailang Yangccc656c2006-10-17 12:32:26 +02006875static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
6876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6877 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6878 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6879 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006884 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006885 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6886 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006887 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006888 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6889 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6890 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
6891 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6892 { } /* end */
6893};
6894
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006895static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6896 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6897 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6899 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6900 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6901
6902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006904 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006905 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6906 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006907 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006908 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6909 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6910 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6911 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6912 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6913 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6914 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6915 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6916 { } /* end */
6917};
6918
Kailang Yangcd7509a2007-01-26 18:33:17 +01006919static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
6920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6921 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6922 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6924 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6925 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6926 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
6927 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006928 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006929 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6930 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6933 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6934 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6935 { } /* end */
6936};
6937
6938static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6939 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6940 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006941 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006942 { } /* end */
6943};
6944
Kailang Yang272a5272007-05-14 11:00:38 +02006945static struct snd_kcontrol_new alc262_sony_mixer[] = {
6946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6947 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6950 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6951 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6952 { } /* end */
6953};
6954
Kailang Yang83c34212007-07-05 11:43:05 +02006955static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
6956 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6957 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6961 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6962 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6963 { } /* end */
6964};
Kailang Yang272a5272007-05-14 11:00:38 +02006965
Kailang Yangdf694da2005-12-05 19:42:22 +01006966#define alc262_capture_mixer alc882_capture_mixer
6967#define alc262_capture_alt_mixer alc882_capture_alt_mixer
6968
6969/*
6970 * generic initialization of ADC, input mixers and output mixers
6971 */
6972static struct hda_verb alc262_init_verbs[] = {
6973 /*
6974 * Unmute ADC0-2 and set the default input to mic-in
6975 */
6976 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6978 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6979 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6980 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6981 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6982
6983 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6984 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006985 * Note: PASD motherboards uses the Line In 2 as the input for
6986 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006987 */
6988 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6993 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6994
6995 /*
6996 * Set up output mixers (0x0c - 0x0e)
6997 */
6998 /* set vol=0 to output mixers */
6999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7002 /* set up input amps for analog loopback */
7003 /* Amp Indices: DAC = 0, mixer = 1 */
7004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7005 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7006 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7007 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7009 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7010
7011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7013 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7014 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7015 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7016 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7017
7018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7020 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7021 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7022 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7023
7024 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7025 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7026
7027 /* FIXME: use matrix-type input source selection */
7028 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7029 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7033 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7034 /* Input mixer2 */
7035 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7036 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7037 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7038 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7039 /* Input mixer3 */
7040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007043 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007044
7045 { }
7046};
7047
Kailang Yangccc656c2006-10-17 12:32:26 +02007048static struct hda_verb alc262_hippo_unsol_verbs[] = {
7049 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7051 {}
7052};
7053
7054static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7055 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7056 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7057 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7058
7059 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7060 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7061 {}
7062};
7063
Kailang Yang272a5272007-05-14 11:00:38 +02007064static struct hda_verb alc262_sony_unsol_verbs[] = {
7065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7067 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7068
7069 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7071};
7072
Kailang Yangccc656c2006-10-17 12:32:26 +02007073/* mute/unmute internal speaker according to the hp jack and mute state */
7074static void alc262_hippo_automute(struct hda_codec *codec, int force)
7075{
7076 struct alc_spec *spec = codec->spec;
7077 unsigned int mute;
7078
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007079 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007080 unsigned int present;
7081 /* need to execute and sync at first */
7082 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7083 present = snd_hda_codec_read(codec, 0x15, 0,
7084 AC_VERB_GET_PIN_SENSE, 0);
7085 spec->jack_present = (present & 0x80000000) != 0;
7086 spec->sense_updated = 1;
7087 }
7088 if (spec->jack_present) {
7089 /* mute internal speaker */
7090 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7091 0x80, 0x80);
7092 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7093 0x80, 0x80);
7094 } else {
7095 /* unmute internal speaker if necessary */
7096 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7097 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7098 0x80, mute & 0x80);
7099 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7100 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7101 0x80, mute & 0x80);
7102 }
7103}
7104
7105/* unsolicited event for HP jack sensing */
7106static void alc262_hippo_unsol_event(struct hda_codec *codec,
7107 unsigned int res)
7108{
7109 if ((res >> 26) != ALC880_HP_EVENT)
7110 return;
7111 alc262_hippo_automute(codec, 1);
7112}
7113
7114static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7115{
7116 struct alc_spec *spec = codec->spec;
7117 unsigned int mute;
7118
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007119 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007120 unsigned int present;
7121 /* need to execute and sync at first */
7122 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7123 present = snd_hda_codec_read(codec, 0x1b, 0,
7124 AC_VERB_GET_PIN_SENSE, 0);
7125 spec->jack_present = (present & 0x80000000) != 0;
7126 spec->sense_updated = 1;
7127 }
7128 if (spec->jack_present) {
7129 /* mute internal speaker */
7130 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7131 0x80, 0x80);
7132 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7133 0x80, 0x80);
7134 } else {
7135 /* unmute internal speaker if necessary */
7136 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7137 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7138 0x80, mute & 0x80);
7139 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7140 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7141 0x80, mute & 0x80);
7142 }
7143}
7144
7145/* unsolicited event for HP jack sensing */
7146static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7147 unsigned int res)
7148{
7149 if ((res >> 26) != ALC880_HP_EVENT)
7150 return;
7151 alc262_hippo1_automute(codec, 1);
7152}
7153
Takashi Iwai834be882006-03-01 14:16:17 +01007154/*
7155 * fujitsu model
7156 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7157 */
7158
7159#define ALC_HP_EVENT 0x37
7160
7161static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7162 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7164 {}
7165};
7166
7167static struct hda_input_mux alc262_fujitsu_capture_source = {
7168 .num_items = 2,
7169 .items = {
7170 { "Mic", 0x0 },
7171 { "CD", 0x4 },
7172 },
7173};
7174
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007175static struct hda_input_mux alc262_HP_capture_source = {
7176 .num_items = 5,
7177 .items = {
7178 { "Mic", 0x0 },
7179 { "Front Mic", 0x3 },
7180 { "Line", 0x2 },
7181 { "CD", 0x4 },
7182 { "AUX IN", 0x6 },
7183 },
7184};
7185
Takashi Iwai834be882006-03-01 14:16:17 +01007186/* mute/unmute internal speaker according to the hp jack and mute state */
7187static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7188{
7189 struct alc_spec *spec = codec->spec;
7190 unsigned int mute;
7191
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007192 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007193 unsigned int present;
7194 /* need to execute and sync at first */
7195 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7196 present = snd_hda_codec_read(codec, 0x14, 0,
7197 AC_VERB_GET_PIN_SENSE, 0);
7198 spec->jack_present = (present & 0x80000000) != 0;
7199 spec->sense_updated = 1;
7200 }
7201 if (spec->jack_present) {
7202 /* mute internal speaker */
7203 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7204 0x80, 0x80);
7205 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7206 0x80, 0x80);
7207 } else {
7208 /* unmute internal speaker if necessary */
7209 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7210 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7211 0x80, mute & 0x80);
7212 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7213 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7214 0x80, mute & 0x80);
7215 }
7216}
7217
7218/* unsolicited event for HP jack sensing */
7219static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7220 unsigned int res)
7221{
7222 if ((res >> 26) != ALC_HP_EVENT)
7223 return;
7224 alc262_fujitsu_automute(codec, 1);
7225}
7226
7227/* bind volumes of both NID 0x0c and 0x0d */
7228static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7229 struct snd_ctl_elem_value *ucontrol)
7230{
7231 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7232 long *valp = ucontrol->value.integer.value;
7233 int change;
7234
7235 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7236 0x7f, valp[0] & 0x7f);
7237 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7238 0x7f, valp[1] & 0x7f);
7239 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7240 0x7f, valp[0] & 0x7f);
7241 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7242 0x7f, valp[1] & 0x7f);
7243 return change;
7244}
7245
7246/* bind hp and internal speaker mute (with plug check) */
7247static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7248 struct snd_ctl_elem_value *ucontrol)
7249{
7250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7251 long *valp = ucontrol->value.integer.value;
7252 int change;
7253
7254 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7255 0x80, valp[0] ? 0 : 0x80);
7256 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7257 0x80, valp[1] ? 0 : 0x80);
7258 if (change || codec->in_resume)
7259 alc262_fujitsu_automute(codec, codec->in_resume);
7260 return change;
7261}
7262
7263static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7264 {
7265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7266 .name = "Master Playback Volume",
7267 .info = snd_hda_mixer_amp_volume_info,
7268 .get = snd_hda_mixer_amp_volume_get,
7269 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007270 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007271 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7272 },
7273 {
7274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7275 .name = "Master Playback Switch",
7276 .info = snd_hda_mixer_amp_switch_info,
7277 .get = snd_hda_mixer_amp_switch_get,
7278 .put = alc262_fujitsu_master_sw_put,
7279 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7280 },
7281 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7282 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7283 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7285 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7286 { } /* end */
7287};
7288
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007289/* additional init verbs for Benq laptops */
7290static struct hda_verb alc262_EAPD_verbs[] = {
7291 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7292 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7293 {}
7294};
7295
Kailang Yang83c34212007-07-05 11:43:05 +02007296static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7298 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7299
7300 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7301 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7302 {}
7303};
7304
Kailang Yangdf694da2005-12-05 19:42:22 +01007305/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007306static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7307 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007308{
7309 hda_nid_t nid;
7310 int err;
7311
7312 spec->multiout.num_dacs = 1; /* only use one dac */
7313 spec->multiout.dac_nids = spec->private_dac_nids;
7314 spec->multiout.dac_nids[0] = 2;
7315
7316 nid = cfg->line_out_pins[0];
7317 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007318 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7319 "Front Playback Volume",
7320 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7321 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007322 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007323 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7324 "Front Playback Switch",
7325 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7326 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007327 return err;
7328 }
7329
Takashi Iwai82bc9552006-03-21 11:24:42 +01007330 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007331 if (nid) {
7332 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007333 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7334 "Speaker Playback Volume",
7335 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7336 HDA_OUTPUT));
7337 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007338 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007339 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7340 "Speaker Playback Switch",
7341 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7342 HDA_OUTPUT));
7343 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007344 return err;
7345 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007346 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7347 "Speaker Playback Switch",
7348 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7349 HDA_OUTPUT));
7350 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007351 return err;
7352 }
7353 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007354 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007355 if (nid) {
7356 /* spec->multiout.hp_nid = 2; */
7357 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007358 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7359 "Headphone Playback Volume",
7360 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7361 HDA_OUTPUT));
7362 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007363 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007364 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7365 "Headphone Playback Switch",
7366 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7367 HDA_OUTPUT));
7368 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007369 return err;
7370 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007371 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7372 "Headphone Playback Switch",
7373 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7374 HDA_OUTPUT));
7375 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007376 return err;
7377 }
7378 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007379 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007380}
7381
7382/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007383#define alc262_auto_create_analog_input_ctls \
7384 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007385
7386/*
7387 * generic initialization of ADC, input mixers and output mixers
7388 */
7389static struct hda_verb alc262_volume_init_verbs[] = {
7390 /*
7391 * Unmute ADC0-2 and set the default input to mic-in
7392 */
7393 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7395 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7396 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7397 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7398 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7399
7400 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7401 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007402 * Note: PASD motherboards uses the Line In 2 as the input for
7403 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007404 */
7405 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7411
7412 /*
7413 * Set up output mixers (0x0c - 0x0f)
7414 */
7415 /* set vol=0 to output mixers */
7416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7417 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7418 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7419
7420 /* set up input amps for analog loopback */
7421 /* Amp Indices: DAC = 0, mixer = 1 */
7422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7425 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7426 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7427 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7428
7429 /* FIXME: use matrix-type input source selection */
7430 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7431 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7432 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7433 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7434 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7436 /* Input mixer2 */
7437 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7438 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7439 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7440 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7441 /* Input mixer3 */
7442 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7443 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7444 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7446
7447 { }
7448};
7449
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007450static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7451 /*
7452 * Unmute ADC0-2 and set the default input to mic-in
7453 */
7454 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7456 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7457 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7458 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7459 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7460
7461 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7462 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007463 * Note: PASD motherboards uses the Line In 2 as the input for
7464 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007465 */
7466 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7467 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7468 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7469 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7474
7475 /*
7476 * Set up output mixers (0x0c - 0x0e)
7477 */
7478 /* set vol=0 to output mixers */
7479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7480 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7482
7483 /* set up input amps for analog loopback */
7484 /* Amp Indices: DAC = 0, mixer = 1 */
7485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7486 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7488 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7490 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7491
7492 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7494 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7495
7496 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7498
7499 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7500 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7501
7502 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7503 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7504 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7506 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7507
7508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7512 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7513 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7514
7515
7516 /* FIXME: use matrix-type input source selection */
7517 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7518 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7523 /* Input mixer2 */
7524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7528 /* Input mixer3 */
7529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7533
7534 { }
7535};
7536
Kailang Yangcd7509a2007-01-26 18:33:17 +01007537static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7538 /*
7539 * Unmute ADC0-2 and set the default input to mic-in
7540 */
7541 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7543 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7544 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7545 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7547
7548 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7549 * mixer widget
7550 * Note: PASD motherboards uses the Line In 2 as the input for front
7551 * panel mic (mic 2)
7552 */
7553 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7555 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7556 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7558 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7559 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7562 /*
7563 * Set up output mixers (0x0c - 0x0e)
7564 */
7565 /* set vol=0 to output mixers */
7566 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7567 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7569
7570 /* set up input amps for analog loopback */
7571 /* Amp Indices: DAC = 0, mixer = 1 */
7572 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7574 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7575 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7576 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7577 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7578
7579
7580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7581 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7582 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7583 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7584 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7585 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7586 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7587
7588 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7590
7591 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7592 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7593
7594 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7595 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7596 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7597 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7598 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7599 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7600
7601 /* FIXME: use matrix-type input source selection */
7602 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7603 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7609 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7611 /* Input mixer2 */
7612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7617 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7619 /* Input mixer3 */
7620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7625 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7627
7628 { }
7629};
7630
Kailang Yangdf694da2005-12-05 19:42:22 +01007631/* pcm configuration: identiacal with ALC880 */
7632#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7633#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7634#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7635#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7636
7637/*
7638 * BIOS auto configuration
7639 */
7640static int alc262_parse_auto_config(struct hda_codec *codec)
7641{
7642 struct alc_spec *spec = codec->spec;
7643 int err;
7644 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7645
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007646 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7647 alc262_ignore);
7648 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007649 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007650 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007651 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007652 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7653 if (err < 0)
7654 return err;
7655 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7656 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007657 return err;
7658
7659 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7660
7661 if (spec->autocfg.dig_out_pin)
7662 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7663 if (spec->autocfg.dig_in_pin)
7664 spec->dig_in_nid = ALC262_DIGIN_NID;
7665
7666 if (spec->kctl_alloc)
7667 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7668
7669 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007670 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007671 spec->input_mux = &spec->private_imux;
7672
7673 return 1;
7674}
7675
7676#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7677#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7678#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7679
7680
7681/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007682static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007683{
Kailang Yangdf694da2005-12-05 19:42:22 +01007684 alc262_auto_init_multi_out(codec);
7685 alc262_auto_init_hp_out(codec);
7686 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007687}
7688
7689/*
7690 * configuration and preset
7691 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007692static const char *alc262_models[ALC262_MODEL_LAST] = {
7693 [ALC262_BASIC] = "basic",
7694 [ALC262_HIPPO] = "hippo",
7695 [ALC262_HIPPO_1] = "hippo_1",
7696 [ALC262_FUJITSU] = "fujitsu",
7697 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007698 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007699 [ALC262_BENQ_ED8] = "benq",
Kailang Yang272a5272007-05-14 11:00:38 +02007700 [ALC262_BENQ_ED8] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007701 [ALC262_AUTO] = "auto",
7702};
7703
7704static struct snd_pci_quirk alc262_cfg_tbl[] = {
7705 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7706 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7707 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007708 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7709 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007710 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007711 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007712 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007713 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007714 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7715 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7716 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7717 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7718 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7719 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7720 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7721 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007722 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7723 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7724 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7725 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02007726 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Kailang Yang272a5272007-05-14 11:00:38 +02007727 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7728 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7729 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007730 {}
7731};
7732
7733static struct alc_config_preset alc262_presets[] = {
7734 [ALC262_BASIC] = {
7735 .mixers = { alc262_base_mixer },
7736 .init_verbs = { alc262_init_verbs },
7737 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7738 .dac_nids = alc262_dac_nids,
7739 .hp_nid = 0x03,
7740 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7741 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007742 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007743 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007744 [ALC262_HIPPO] = {
7745 .mixers = { alc262_base_mixer },
7746 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7747 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7748 .dac_nids = alc262_dac_nids,
7749 .hp_nid = 0x03,
7750 .dig_out_nid = ALC262_DIGOUT_NID,
7751 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7752 .channel_mode = alc262_modes,
7753 .input_mux = &alc262_capture_source,
7754 .unsol_event = alc262_hippo_unsol_event,
7755 },
7756 [ALC262_HIPPO_1] = {
7757 .mixers = { alc262_hippo1_mixer },
7758 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7759 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7760 .dac_nids = alc262_dac_nids,
7761 .hp_nid = 0x02,
7762 .dig_out_nid = ALC262_DIGOUT_NID,
7763 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7764 .channel_mode = alc262_modes,
7765 .input_mux = &alc262_capture_source,
7766 .unsol_event = alc262_hippo1_unsol_event,
7767 },
Takashi Iwai834be882006-03-01 14:16:17 +01007768 [ALC262_FUJITSU] = {
7769 .mixers = { alc262_fujitsu_mixer },
7770 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7771 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7772 .dac_nids = alc262_dac_nids,
7773 .hp_nid = 0x03,
7774 .dig_out_nid = ALC262_DIGOUT_NID,
7775 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7776 .channel_mode = alc262_modes,
7777 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007778 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007779 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007780 [ALC262_HP_BPC] = {
7781 .mixers = { alc262_HP_BPC_mixer },
7782 .init_verbs = { alc262_HP_BPC_init_verbs },
7783 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7784 .dac_nids = alc262_dac_nids,
7785 .hp_nid = 0x03,
7786 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7787 .channel_mode = alc262_modes,
7788 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007789 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007790 [ALC262_HP_BPC_D7000_WF] = {
7791 .mixers = { alc262_HP_BPC_WildWest_mixer },
7792 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7793 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7794 .dac_nids = alc262_dac_nids,
7795 .hp_nid = 0x03,
7796 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7797 .channel_mode = alc262_modes,
7798 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007799 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007800 [ALC262_HP_BPC_D7000_WL] = {
7801 .mixers = { alc262_HP_BPC_WildWest_mixer,
7802 alc262_HP_BPC_WildWest_option_mixer },
7803 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7804 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7805 .dac_nids = alc262_dac_nids,
7806 .hp_nid = 0x03,
7807 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7808 .channel_mode = alc262_modes,
7809 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007810 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007811 [ALC262_BENQ_ED8] = {
7812 .mixers = { alc262_base_mixer },
7813 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7814 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7815 .dac_nids = alc262_dac_nids,
7816 .hp_nid = 0x03,
7817 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7818 .channel_mode = alc262_modes,
7819 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007820 },
Kailang Yang272a5272007-05-14 11:00:38 +02007821 [ALC262_SONY_ASSAMD] = {
7822 .mixers = { alc262_sony_mixer },
7823 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7824 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7825 .dac_nids = alc262_dac_nids,
7826 .hp_nid = 0x02,
7827 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7828 .channel_mode = alc262_modes,
7829 .input_mux = &alc262_capture_source,
7830 .unsol_event = alc262_hippo_unsol_event,
Kailang Yang83c34212007-07-05 11:43:05 +02007831 },
7832 [ALC262_BENQ_T31] = {
7833 .mixers = { alc262_benq_t31_mixer },
7834 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
7835 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7836 .dac_nids = alc262_dac_nids,
7837 .hp_nid = 0x03,
7838 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7839 .channel_mode = alc262_modes,
7840 .input_mux = &alc262_capture_source,
7841 .unsol_event = alc262_hippo_unsol_event,
Kailang Yang272a5272007-05-14 11:00:38 +02007842 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007843};
7844
7845static int patch_alc262(struct hda_codec *codec)
7846{
7847 struct alc_spec *spec;
7848 int board_config;
7849 int err;
7850
Robert P. J. Daydc041e02006-12-19 14:44:15 +01007851 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01007852 if (spec == NULL)
7853 return -ENOMEM;
7854
7855 codec->spec = spec;
7856#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007857 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7858 * under-run
7859 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007860 {
7861 int tmp;
7862 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7863 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7864 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7865 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7866 }
7867#endif
7868
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007869 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7870 alc262_models,
7871 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01007872
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007873 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007874 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7875 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007876 board_config = ALC262_AUTO;
7877 }
7878
7879 if (board_config == ALC262_AUTO) {
7880 /* automatic parse from the BIOS config */
7881 err = alc262_parse_auto_config(codec);
7882 if (err < 0) {
7883 alc_free(codec);
7884 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007885 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007886 printk(KERN_INFO
7887 "hda_codec: Cannot set up configuration "
7888 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007889 board_config = ALC262_BASIC;
7890 }
7891 }
7892
7893 if (board_config != ALC262_AUTO)
7894 setup_preset(spec, &alc262_presets[board_config]);
7895
7896 spec->stream_name_analog = "ALC262 Analog";
7897 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7898 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7899
7900 spec->stream_name_digital = "ALC262 Digital";
7901 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7902 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7903
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007904 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007905 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007906 unsigned int wcap = get_wcaps(codec, 0x07);
7907
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007908 /* get type */
7909 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007910 if (wcap != AC_WID_AUD_IN) {
7911 spec->adc_nids = alc262_adc_nids_alt;
7912 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007913 spec->mixers[spec->num_mixers] =
7914 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01007915 spec->num_mixers++;
7916 } else {
7917 spec->adc_nids = alc262_adc_nids;
7918 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
7919 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
7920 spec->num_mixers++;
7921 }
7922 }
7923
7924 codec->patch_ops = alc_patch_ops;
7925 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007926 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01007927
Kailang Yangdf694da2005-12-05 19:42:22 +01007928 return 0;
7929}
7930
Kailang Yangdf694da2005-12-05 19:42:22 +01007931/*
Kailang Yanga361d842007-06-05 12:30:55 +02007932 * ALC268 channel source setting (2 channel)
7933 */
7934#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
7935#define alc268_modes alc260_modes
7936
7937static hda_nid_t alc268_dac_nids[2] = {
7938 /* front, hp */
7939 0x02, 0x03
7940};
7941
7942static hda_nid_t alc268_adc_nids[2] = {
7943 /* ADC0-1 */
7944 0x08, 0x07
7945};
7946
7947static hda_nid_t alc268_adc_nids_alt[1] = {
7948 /* ADC0 */
7949 0x08
7950};
7951
7952static struct snd_kcontrol_new alc268_base_mixer[] = {
7953 /* output mixer control */
7954 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
7955 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
7957 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7958 { }
7959};
7960
7961/*
7962 * generic initialization of ADC, input mixers and output mixers
7963 */
7964static struct hda_verb alc268_base_init_verbs[] = {
7965 /* Unmute DAC0-1 and set vol = 0 */
7966 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7967 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7968 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7969 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7970 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7971 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7972
7973 /*
7974 * Set up output mixers (0x0c - 0x0e)
7975 */
7976 /* set vol=0 to output mixers */
7977 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7978 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7979 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7980 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
7981
7982 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7983 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7984
7985 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7986 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7987 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7988 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7989 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7990 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7991 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7992 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7993
7994 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7996 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7997 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7999 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8000 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8001 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8002
8003 /* FIXME: use matrix-type input source selection */
8004 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8005 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8006 /* Input mixer2 */
8007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8010 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8011
8012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8015 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8016 { }
8017};
8018
8019/*
8020 * generic initialization of ADC, input mixers and output mixers
8021 */
8022static struct hda_verb alc268_volume_init_verbs[] = {
8023 /* set output DAC */
8024 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8025 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8026 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8027 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8028
8029 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8030 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8031 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8032 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8033 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8034
8035 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8036 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8037 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8038 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8039 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8040
8041 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8042 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8043 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8044 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8045
8046 /* set PCBEEP vol = 0 */
8047 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8048
8049 { }
8050};
8051
8052#define alc268_mux_enum_info alc_mux_enum_info
8053#define alc268_mux_enum_get alc_mux_enum_get
8054
8055static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8056 struct snd_ctl_elem_value *ucontrol)
8057{
8058 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8059 struct alc_spec *spec = codec->spec;
8060 const struct hda_input_mux *imux = spec->input_mux;
8061 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8062 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8063 hda_nid_t nid = capture_mixers[adc_idx];
8064 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8065 unsigned int i, idx;
8066
8067 idx = ucontrol->value.enumerated.item[0];
8068 if (idx >= imux->num_items)
8069 idx = imux->num_items - 1;
8070 if (*cur_val == idx && !codec->in_resume)
8071 return 0;
8072 for (i = 0; i < imux->num_items; i++) {
8073 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8074 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8075 v | (imux->items[i].index << 8));
8076 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8077 idx );
8078 }
8079 *cur_val = idx;
8080 return 1;
8081}
8082
8083static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8084 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8085 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8086 {
8087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8088 /* The multiple "Capture Source" controls confuse alsamixer
8089 * So call somewhat different..
8090 * FIXME: the controls appear in the "playback" view!
8091 */
8092 /* .name = "Capture Source", */
8093 .name = "Input Source",
8094 .count = 1,
8095 .info = alc268_mux_enum_info,
8096 .get = alc268_mux_enum_get,
8097 .put = alc268_mux_enum_put,
8098 },
8099 { } /* end */
8100};
8101
8102static struct snd_kcontrol_new alc268_capture_mixer[] = {
8103 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8104 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8105 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8106 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8107 {
8108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8109 /* The multiple "Capture Source" controls confuse alsamixer
8110 * So call somewhat different..
8111 * FIXME: the controls appear in the "playback" view!
8112 */
8113 /* .name = "Capture Source", */
8114 .name = "Input Source",
8115 .count = 2,
8116 .info = alc268_mux_enum_info,
8117 .get = alc268_mux_enum_get,
8118 .put = alc268_mux_enum_put,
8119 },
8120 { } /* end */
8121};
8122
8123static struct hda_input_mux alc268_capture_source = {
8124 .num_items = 4,
8125 .items = {
8126 { "Mic", 0x0 },
8127 { "Front Mic", 0x1 },
8128 { "Line", 0x2 },
8129 { "CD", 0x3 },
8130 },
8131};
8132
8133/* create input playback/capture controls for the given pin */
8134static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8135 const char *ctlname, int idx)
8136{
8137 char name[32];
8138 int err;
8139
8140 sprintf(name, "%s Playback Volume", ctlname);
8141 if (nid == 0x14) {
8142 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8143 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8144 HDA_OUTPUT));
8145 if (err < 0)
8146 return err;
8147 } else if (nid == 0x15) {
8148 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8149 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8150 HDA_OUTPUT));
8151 if (err < 0)
8152 return err;
8153 } else
8154 return -1;
8155 sprintf(name, "%s Playback Switch", ctlname);
8156 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8157 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8158 if (err < 0)
8159 return err;
8160 return 0;
8161}
8162
8163/* add playback controls from the parsed DAC table */
8164static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8165 const struct auto_pin_cfg *cfg)
8166{
8167 hda_nid_t nid;
8168 int err;
8169
8170 spec->multiout.num_dacs = 2; /* only use one dac */
8171 spec->multiout.dac_nids = spec->private_dac_nids;
8172 spec->multiout.dac_nids[0] = 2;
8173 spec->multiout.dac_nids[1] = 3;
8174
8175 nid = cfg->line_out_pins[0];
8176 if (nid)
8177 alc268_new_analog_output(spec, nid, "Front", 0);
8178
8179 nid = cfg->speaker_pins[0];
8180 if (nid == 0x1d) {
8181 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8182 "Speaker Playback Volume",
8183 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8184 if (err < 0)
8185 return err;
8186 }
8187 nid = cfg->hp_pins[0];
8188 if (nid)
8189 alc268_new_analog_output(spec, nid, "Headphone", 0);
8190
8191 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8192 if (nid == 0x16) {
8193 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8194 "Mono Playback Switch",
8195 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8196 if (err < 0)
8197 return err;
8198 }
8199 return 0;
8200}
8201
8202/* create playback/capture controls for input pins */
8203static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8204 const struct auto_pin_cfg *cfg)
8205{
8206 struct hda_input_mux *imux = &spec->private_imux;
8207 int i, idx1;
8208
8209 for (i = 0; i < AUTO_PIN_LAST; i++) {
8210 switch(cfg->input_pins[i]) {
8211 case 0x18:
8212 idx1 = 0; /* Mic 1 */
8213 break;
8214 case 0x19:
8215 idx1 = 1; /* Mic 2 */
8216 break;
8217 case 0x1a:
8218 idx1 = 2; /* Line In */
8219 break;
8220 case 0x1c:
8221 idx1 = 3; /* CD */
8222 break;
8223 default:
8224 continue;
8225 }
8226 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8227 imux->items[imux->num_items].index = idx1;
8228 imux->num_items++;
8229 }
8230 return 0;
8231}
8232
8233static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8234{
8235 struct alc_spec *spec = codec->spec;
8236 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8237 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8238 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8239 unsigned int dac_vol1, dac_vol2;
8240
8241 if (speaker_nid) {
8242 snd_hda_codec_write(codec, speaker_nid, 0,
8243 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8244 snd_hda_codec_write(codec, 0x0f, 0,
8245 AC_VERB_SET_AMP_GAIN_MUTE,
8246 AMP_IN_UNMUTE(1));
8247 snd_hda_codec_write(codec, 0x10, 0,
8248 AC_VERB_SET_AMP_GAIN_MUTE,
8249 AMP_IN_UNMUTE(1));
8250 } else {
8251 snd_hda_codec_write(codec, 0x0f, 0,
8252 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8253 snd_hda_codec_write(codec, 0x10, 0,
8254 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8255 }
8256
8257 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8258 if (line_nid == 0x14)
8259 dac_vol2 = AMP_OUT_ZERO;
8260 else if (line_nid == 0x15)
8261 dac_vol1 = AMP_OUT_ZERO;
8262 if (hp_nid == 0x14)
8263 dac_vol2 = AMP_OUT_ZERO;
8264 else if (hp_nid == 0x15)
8265 dac_vol1 = AMP_OUT_ZERO;
8266 if (line_nid != 0x16 || hp_nid != 0x16 ||
8267 spec->autocfg.line_out_pins[1] != 0x16 ||
8268 spec->autocfg.line_out_pins[2] != 0x16)
8269 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8270
8271 snd_hda_codec_write(codec, 0x02, 0,
8272 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8273 snd_hda_codec_write(codec, 0x03, 0,
8274 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8275}
8276
8277/* pcm configuration: identiacal with ALC880 */
8278#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8279#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8280#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8281
8282/*
8283 * BIOS auto configuration
8284 */
8285static int alc268_parse_auto_config(struct hda_codec *codec)
8286{
8287 struct alc_spec *spec = codec->spec;
8288 int err;
8289 static hda_nid_t alc268_ignore[] = { 0 };
8290
8291 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8292 alc268_ignore);
8293 if (err < 0)
8294 return err;
8295 if (!spec->autocfg.line_outs)
8296 return 0; /* can't find valid BIOS pin config */
8297
8298 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8299 if (err < 0)
8300 return err;
8301 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8302 if (err < 0)
8303 return err;
8304
8305 spec->multiout.max_channels = 2;
8306
8307 /* digital only support output */
8308 if (spec->autocfg.dig_out_pin)
8309 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8310
8311 if (spec->kctl_alloc)
8312 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8313
8314 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8315 spec->num_mux_defs = 1;
8316 spec->input_mux = &spec->private_imux;
8317
8318 return 1;
8319}
8320
8321#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8322#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8323#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8324
8325/* init callback for auto-configuration model -- overriding the default init */
8326static void alc268_auto_init(struct hda_codec *codec)
8327{
8328 alc268_auto_init_multi_out(codec);
8329 alc268_auto_init_hp_out(codec);
8330 alc268_auto_init_mono_speaker_out(codec);
8331 alc268_auto_init_analog_input(codec);
8332}
8333
8334/*
8335 * configuration and preset
8336 */
8337static const char *alc268_models[ALC268_MODEL_LAST] = {
8338 [ALC268_3ST] = "3stack",
8339 [ALC268_AUTO] = "auto",
8340};
8341
8342static struct snd_pci_quirk alc268_cfg_tbl[] = {
8343 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8344 {}
8345};
8346
8347static struct alc_config_preset alc268_presets[] = {
8348 [ALC268_3ST] = {
8349 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8350 .init_verbs = { alc268_base_init_verbs },
8351 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8352 .dac_nids = alc268_dac_nids,
8353 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8354 .adc_nids = alc268_adc_nids_alt,
8355 .hp_nid = 0x03,
8356 .dig_out_nid = ALC268_DIGOUT_NID,
8357 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8358 .channel_mode = alc268_modes,
8359 .input_mux = &alc268_capture_source,
8360 },
8361};
8362
8363static int patch_alc268(struct hda_codec *codec)
8364{
8365 struct alc_spec *spec;
8366 int board_config;
8367 int err;
8368
8369 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8370 if (spec == NULL)
8371 return -ENOMEM;
8372
8373 codec->spec = spec;
8374
8375 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8376 alc268_models,
8377 alc268_cfg_tbl);
8378
8379 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8380 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8381 "trying auto-probe from BIOS...\n");
8382 board_config = ALC268_AUTO;
8383 }
8384
8385 if (board_config == ALC268_AUTO) {
8386 /* automatic parse from the BIOS config */
8387 err = alc268_parse_auto_config(codec);
8388 if (err < 0) {
8389 alc_free(codec);
8390 return err;
8391 } else if (!err) {
8392 printk(KERN_INFO
8393 "hda_codec: Cannot set up configuration "
8394 "from BIOS. Using base mode...\n");
8395 board_config = ALC268_3ST;
8396 }
8397 }
8398
8399 if (board_config != ALC268_AUTO)
8400 setup_preset(spec, &alc268_presets[board_config]);
8401
8402 spec->stream_name_analog = "ALC268 Analog";
8403 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8404 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8405
8406 spec->stream_name_digital = "ALC268 Digital";
8407 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8408
8409 if (board_config == ALC268_AUTO) {
8410 if (!spec->adc_nids && spec->input_mux) {
8411 /* check whether NID 0x07 is valid */
8412 unsigned int wcap = get_wcaps(codec, 0x07);
8413
8414 /* get type */
8415 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8416 if (wcap != AC_WID_AUD_IN) {
8417 spec->adc_nids = alc268_adc_nids_alt;
8418 spec->num_adc_nids =
8419 ARRAY_SIZE(alc268_adc_nids_alt);
8420 spec->mixers[spec->num_mixers] =
8421 alc268_capture_alt_mixer;
8422 spec->num_mixers++;
8423 } else {
8424 spec->adc_nids = alc268_adc_nids;
8425 spec->num_adc_nids =
8426 ARRAY_SIZE(alc268_adc_nids);
8427 spec->mixers[spec->num_mixers] =
8428 alc268_capture_mixer;
8429 spec->num_mixers++;
8430 }
8431 }
8432 }
8433 codec->patch_ops = alc_patch_ops;
8434 if (board_config == ALC268_AUTO)
8435 spec->init_hook = alc268_auto_init;
8436
8437 return 0;
8438}
8439
8440/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008441 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8442 */
8443
8444/*
8445 * set the path ways for 2 channel output
8446 * need to set the codec line out and mic 1 pin widgets to inputs
8447 */
8448static struct hda_verb alc861_threestack_ch2_init[] = {
8449 /* set pin widget 1Ah (line in) for input */
8450 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008451 /* set pin widget 18h (mic1/2) for input, for mic also enable
8452 * the vref
8453 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008454 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8455
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008456 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8457#if 0
8458 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8459 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8460#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008461 { } /* end */
8462};
8463/*
8464 * 6ch mode
8465 * need to set the codec line out and mic 1 pin widgets to outputs
8466 */
8467static struct hda_verb alc861_threestack_ch6_init[] = {
8468 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8469 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8470 /* set pin widget 18h (mic1) for output (CLFE)*/
8471 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8472
8473 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008474 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008475
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008476 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8477#if 0
8478 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8479 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8480#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008481 { } /* end */
8482};
8483
8484static struct hda_channel_mode alc861_threestack_modes[2] = {
8485 { 2, alc861_threestack_ch2_init },
8486 { 6, alc861_threestack_ch6_init },
8487};
Takashi Iwai22309c32006-08-09 16:57:28 +02008488/* Set mic1 as input and unmute the mixer */
8489static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8490 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8491 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8492 { } /* end */
8493};
8494/* Set mic1 as output and mute mixer */
8495static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8496 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8497 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8498 { } /* end */
8499};
8500
8501static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8502 { 2, alc861_uniwill_m31_ch2_init },
8503 { 4, alc861_uniwill_m31_ch4_init },
8504};
Kailang Yangdf694da2005-12-05 19:42:22 +01008505
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008506/* Set mic1 and line-in as input and unmute the mixer */
8507static struct hda_verb alc861_asus_ch2_init[] = {
8508 /* set pin widget 1Ah (line in) for input */
8509 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008510 /* set pin widget 18h (mic1/2) for input, for mic also enable
8511 * the vref
8512 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008513 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8514
8515 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8516#if 0
8517 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8518 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8519#endif
8520 { } /* end */
8521};
8522/* Set mic1 nad line-in as output and mute mixer */
8523static struct hda_verb alc861_asus_ch6_init[] = {
8524 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8525 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8526 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8527 /* set pin widget 18h (mic1) for output (CLFE)*/
8528 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8529 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8530 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8531 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8532
8533 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8534#if 0
8535 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8536 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8537#endif
8538 { } /* end */
8539};
8540
8541static struct hda_channel_mode alc861_asus_modes[2] = {
8542 { 2, alc861_asus_ch2_init },
8543 { 6, alc861_asus_ch6_init },
8544};
8545
Kailang Yangdf694da2005-12-05 19:42:22 +01008546/* patch-ALC861 */
8547
8548static struct snd_kcontrol_new alc861_base_mixer[] = {
8549 /* output mixer control */
8550 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8551 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8552 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8553 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8554 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8555
8556 /*Input mixer control */
8557 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8558 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8559 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8560 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8561 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8562 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8564 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8565 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8566 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008567
Kailang Yangdf694da2005-12-05 19:42:22 +01008568 /* Capture mixer control */
8569 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8570 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8571 {
8572 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8573 .name = "Capture Source",
8574 .count = 1,
8575 .info = alc_mux_enum_info,
8576 .get = alc_mux_enum_get,
8577 .put = alc_mux_enum_put,
8578 },
8579 { } /* end */
8580};
8581
8582static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8583 /* output mixer control */
8584 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8585 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8586 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8587 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8588 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8589
8590 /* Input mixer control */
8591 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8592 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8593 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8594 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8595 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8596 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8598 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8599 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008601
Kailang Yangdf694da2005-12-05 19:42:22 +01008602 /* Capture mixer control */
8603 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8604 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8605 {
8606 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8607 .name = "Capture Source",
8608 .count = 1,
8609 .info = alc_mux_enum_info,
8610 .get = alc_mux_enum_get,
8611 .put = alc_mux_enum_put,
8612 },
8613 {
8614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8615 .name = "Channel Mode",
8616 .info = alc_ch_mode_info,
8617 .get = alc_ch_mode_get,
8618 .put = alc_ch_mode_put,
8619 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8620 },
8621 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008622};
8623
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008624static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008625 /* output mixer control */
8626 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8628 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8629
8630 /*Capture mixer control */
8631 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8632 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8633 {
8634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8635 .name = "Capture Source",
8636 .count = 1,
8637 .info = alc_mux_enum_info,
8638 .get = alc_mux_enum_get,
8639 .put = alc_mux_enum_put,
8640 },
8641
8642 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008643};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008644
Takashi Iwai22309c32006-08-09 16:57:28 +02008645static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8646 /* output mixer control */
8647 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8648 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8649 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8650 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8651 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8652
8653 /* Input mixer control */
8654 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8655 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8656 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8657 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8658 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8659 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8661 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8662 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008664
Takashi Iwai22309c32006-08-09 16:57:28 +02008665 /* Capture mixer control */
8666 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8667 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8668 {
8669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8670 .name = "Capture Source",
8671 .count = 1,
8672 .info = alc_mux_enum_info,
8673 .get = alc_mux_enum_get,
8674 .put = alc_mux_enum_put,
8675 },
8676 {
8677 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8678 .name = "Channel Mode",
8679 .info = alc_ch_mode_info,
8680 .get = alc_ch_mode_get,
8681 .put = alc_ch_mode_put,
8682 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8683 },
8684 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008685};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008686
8687static struct snd_kcontrol_new alc861_asus_mixer[] = {
8688 /* output mixer control */
8689 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8690 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8691 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8692 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8693 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8694
8695 /* Input mixer control */
8696 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8697 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8698 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8699 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8700 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8701 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8703 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8704 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8706
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008707 /* Capture mixer control */
8708 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8709 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8710 {
8711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8712 .name = "Capture Source",
8713 .count = 1,
8714 .info = alc_mux_enum_info,
8715 .get = alc_mux_enum_get,
8716 .put = alc_mux_enum_put,
8717 },
8718 {
8719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8720 .name = "Channel Mode",
8721 .info = alc_ch_mode_info,
8722 .get = alc_ch_mode_get,
8723 .put = alc_ch_mode_put,
8724 .private_value = ARRAY_SIZE(alc861_asus_modes),
8725 },
8726 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008727};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008728
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008729/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008730static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008731 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8732 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8733 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8734 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8735 { }
8736};
8737
Kailang Yangdf694da2005-12-05 19:42:22 +01008738/*
8739 * generic initialization of ADC, input mixers and output mixers
8740 */
8741static struct hda_verb alc861_base_init_verbs[] = {
8742 /*
8743 * Unmute ADC0 and set the default input to mic-in
8744 */
8745 /* port-A for surround (rear panel) */
8746 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8747 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8748 /* port-B for mic-in (rear panel) with vref */
8749 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8750 /* port-C for line-in (rear panel) */
8751 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8752 /* port-D for Front */
8753 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8754 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8755 /* port-E for HP out (front panel) */
8756 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8757 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008758 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008759 /* port-F for mic-in (front panel) with vref */
8760 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8761 /* port-G for CLFE (rear panel) */
8762 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8763 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8764 /* port-H for side (rear panel) */
8765 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8766 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8767 /* CD-in */
8768 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8769 /* route front mic to ADC1*/
8770 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8772
8773 /* Unmute DAC0~3 & spdif out*/
8774 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8775 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8776 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8777 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8778 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8779
8780 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8781 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8782 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8783 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8784 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8785
8786 /* Unmute Stereo Mixer 15 */
8787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008791
8792 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8793 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8794 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8795 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8796 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8798 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8799 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008800 /* hp used DAC 3 (Front) */
8801 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008802 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8803
8804 { }
8805};
8806
8807static struct hda_verb alc861_threestack_init_verbs[] = {
8808 /*
8809 * Unmute ADC0 and set the default input to mic-in
8810 */
8811 /* port-A for surround (rear panel) */
8812 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8813 /* port-B for mic-in (rear panel) with vref */
8814 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8815 /* port-C for line-in (rear panel) */
8816 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8817 /* port-D for Front */
8818 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8819 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8820 /* port-E for HP out (front panel) */
8821 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8822 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008823 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008824 /* port-F for mic-in (front panel) with vref */
8825 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8826 /* port-G for CLFE (rear panel) */
8827 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8828 /* port-H for side (rear panel) */
8829 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8830 /* CD-in */
8831 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8832 /* route front mic to ADC1*/
8833 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8834 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8835 /* Unmute DAC0~3 & spdif out*/
8836 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8837 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8838 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8839 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8840 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8841
8842 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8843 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8844 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8845 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8846 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8847
8848 /* Unmute Stereo Mixer 15 */
8849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008853
8854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8857 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8859 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8860 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008862 /* hp used DAC 3 (Front) */
8863 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8865 { }
8866};
Takashi Iwai22309c32006-08-09 16:57:28 +02008867
8868static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
8869 /*
8870 * Unmute ADC0 and set the default input to mic-in
8871 */
8872 /* port-A for surround (rear panel) */
8873 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8874 /* port-B for mic-in (rear panel) with vref */
8875 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8876 /* port-C for line-in (rear panel) */
8877 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8878 /* port-D for Front */
8879 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8880 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8881 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008882 /* this has to be set to VREF80 */
8883 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008884 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008885 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008886 /* port-F for mic-in (front panel) with vref */
8887 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8888 /* port-G for CLFE (rear panel) */
8889 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8890 /* port-H for side (rear panel) */
8891 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8892 /* CD-in */
8893 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8894 /* route front mic to ADC1*/
8895 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8896 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8897 /* Unmute DAC0~3 & spdif out*/
8898 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8899 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8900 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8901 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8903
8904 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8905 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8906 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8907 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8908 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8909
8910 /* Unmute Stereo Mixer 15 */
8911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02008915
8916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8918 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8919 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8920 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8921 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8922 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8923 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008924 /* hp used DAC 3 (Front) */
8925 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02008926 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8927 { }
8928};
8929
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008930static struct hda_verb alc861_asus_init_verbs[] = {
8931 /*
8932 * Unmute ADC0 and set the default input to mic-in
8933 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008934 /* port-A for surround (rear panel)
8935 * according to codec#0 this is the HP jack
8936 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008937 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
8938 /* route front PCM to HP */
8939 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
8940 /* port-B for mic-in (rear panel) with vref */
8941 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8942 /* port-C for line-in (rear panel) */
8943 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8944 /* port-D for Front */
8945 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8946 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8947 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008948 /* this has to be set to VREF80 */
8949 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008950 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008951 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008952 /* port-F for mic-in (front panel) with vref */
8953 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8954 /* port-G for CLFE (rear panel) */
8955 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8956 /* port-H for side (rear panel) */
8957 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8958 /* CD-in */
8959 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8960 /* route front mic to ADC1*/
8961 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8962 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8963 /* Unmute DAC0~3 & spdif out*/
8964 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8965 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8966 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8967 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8969 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8970 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8971 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8972 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8973 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8974
8975 /* Unmute Stereo Mixer 15 */
8976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008980
8981 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8982 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8983 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8985 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8986 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8987 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008989 /* hp used DAC 3 (Front) */
8990 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8992 { }
8993};
8994
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008995/* additional init verbs for ASUS laptops */
8996static struct hda_verb alc861_asus_laptop_init_verbs[] = {
8997 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
8998 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
8999 { }
9000};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009001
Kailang Yangdf694da2005-12-05 19:42:22 +01009002/*
9003 * generic initialization of ADC, input mixers and output mixers
9004 */
9005static struct hda_verb alc861_auto_init_verbs[] = {
9006 /*
9007 * Unmute ADC0 and set the default input to mic-in
9008 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009009 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9011
9012 /* Unmute DAC0~3 & spdif out*/
9013 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9014 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9015 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9016 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9018
9019 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9020 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9021 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9022 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9023 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9024
9025 /* Unmute Stereo Mixer 15 */
9026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9028 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9029 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9030
9031 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9032 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9033 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9035 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9036 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9037 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9038 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9039
9040 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9041 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009042 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9043 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009044 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9045 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009046 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9047 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009048
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009049 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009050
9051 { }
9052};
9053
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009054static struct hda_verb alc861_toshiba_init_verbs[] = {
9055 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009056
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009057 { }
9058};
9059
9060/* toggle speaker-output according to the hp-jack state */
9061static void alc861_toshiba_automute(struct hda_codec *codec)
9062{
9063 unsigned int present;
9064
9065 present = snd_hda_codec_read(codec, 0x0f, 0,
9066 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9067 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
9068 0x80, present ? 0x80 : 0);
9069 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
9070 0x80, present ? 0x80 : 0);
9071 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
9072 0x80, present ? 0 : 0x80);
9073 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
9074 0x80, present ? 0 : 0x80);
9075}
9076
9077static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9078 unsigned int res)
9079{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009080 if ((res >> 26) == ALC880_HP_EVENT)
9081 alc861_toshiba_automute(codec);
9082}
9083
Kailang Yangdf694da2005-12-05 19:42:22 +01009084/* pcm configuration: identiacal with ALC880 */
9085#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9086#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9087#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9088#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9089
9090
9091#define ALC861_DIGOUT_NID 0x07
9092
9093static struct hda_channel_mode alc861_8ch_modes[1] = {
9094 { 8, NULL }
9095};
9096
9097static hda_nid_t alc861_dac_nids[4] = {
9098 /* front, surround, clfe, side */
9099 0x03, 0x06, 0x05, 0x04
9100};
9101
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009102static hda_nid_t alc660_dac_nids[3] = {
9103 /* front, clfe, surround */
9104 0x03, 0x05, 0x06
9105};
9106
Kailang Yangdf694da2005-12-05 19:42:22 +01009107static hda_nid_t alc861_adc_nids[1] = {
9108 /* ADC0-2 */
9109 0x08,
9110};
9111
9112static struct hda_input_mux alc861_capture_source = {
9113 .num_items = 5,
9114 .items = {
9115 { "Mic", 0x0 },
9116 { "Front Mic", 0x3 },
9117 { "Line", 0x1 },
9118 { "CD", 0x4 },
9119 { "Mixer", 0x5 },
9120 },
9121};
9122
9123/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009124static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9125 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009126{
9127 int i;
9128 hda_nid_t nid;
9129
9130 spec->multiout.dac_nids = spec->private_dac_nids;
9131 for (i = 0; i < cfg->line_outs; i++) {
9132 nid = cfg->line_out_pins[i];
9133 if (nid) {
9134 if (i >= ARRAY_SIZE(alc861_dac_nids))
9135 continue;
9136 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9137 }
9138 }
9139 spec->multiout.num_dacs = cfg->line_outs;
9140 return 0;
9141}
9142
9143/* add playback controls from the parsed DAC table */
9144static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9145 const struct auto_pin_cfg *cfg)
9146{
9147 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009148 static const char *chname[4] = {
9149 "Front", "Surround", NULL /*CLFE*/, "Side"
9150 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009151 hda_nid_t nid;
9152 int i, idx, err;
9153
9154 for (i = 0; i < cfg->line_outs; i++) {
9155 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009156 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009157 continue;
9158 if (nid == 0x05) {
9159 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009160 err = add_control(spec, ALC_CTL_BIND_MUTE,
9161 "Center Playback Switch",
9162 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9163 HDA_OUTPUT));
9164 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009166 err = add_control(spec, ALC_CTL_BIND_MUTE,
9167 "LFE Playback Switch",
9168 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9169 HDA_OUTPUT));
9170 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009171 return err;
9172 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009173 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9174 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009175 if (nid == alc861_dac_nids[idx])
9176 break;
9177 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009178 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9179 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9180 HDA_OUTPUT));
9181 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009182 return err;
9183 }
9184 }
9185 return 0;
9186}
9187
9188static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9189{
9190 int err;
9191 hda_nid_t nid;
9192
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009193 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009194 return 0;
9195
9196 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9197 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009198 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9199 "Headphone Playback Switch",
9200 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9201 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009202 return err;
9203 spec->multiout.hp_nid = nid;
9204 }
9205 return 0;
9206}
9207
9208/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009209static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9210 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009211{
Kailang Yangdf694da2005-12-05 19:42:22 +01009212 struct hda_input_mux *imux = &spec->private_imux;
9213 int i, err, idx, idx1;
9214
9215 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009216 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009217 case 0x0c:
9218 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009219 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009220 break;
9221 case 0x0f:
9222 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009223 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009224 break;
9225 case 0x0d:
9226 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009227 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009228 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009229 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009230 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009231 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009232 break;
9233 case 0x11:
9234 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009235 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009236 break;
9237 default:
9238 continue;
9239 }
9240
Takashi Iwai4a471b72005-12-07 13:56:29 +01009241 err = new_analog_input(spec, cfg->input_pins[i],
9242 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009243 if (err < 0)
9244 return err;
9245
Takashi Iwai4a471b72005-12-07 13:56:29 +01009246 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009247 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009248 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009249 }
9250 return 0;
9251}
9252
9253static struct snd_kcontrol_new alc861_capture_mixer[] = {
9254 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9255 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9256
9257 {
9258 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9259 /* The multiple "Capture Source" controls confuse alsamixer
9260 * So call somewhat different..
9261 *FIXME: the controls appear in the "playback" view!
9262 */
9263 /* .name = "Capture Source", */
9264 .name = "Input Source",
9265 .count = 1,
9266 .info = alc_mux_enum_info,
9267 .get = alc_mux_enum_get,
9268 .put = alc_mux_enum_put,
9269 },
9270 { } /* end */
9271};
9272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009273static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9274 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009275 int pin_type, int dac_idx)
9276{
9277 /* set as output */
9278
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009279 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9280 pin_type);
9281 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9282 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009283
9284}
9285
9286static void alc861_auto_init_multi_out(struct hda_codec *codec)
9287{
9288 struct alc_spec *spec = codec->spec;
9289 int i;
9290
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009291 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009292 for (i = 0; i < spec->autocfg.line_outs; i++) {
9293 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009294 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009295 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009296 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009297 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009298 }
9299}
9300
9301static void alc861_auto_init_hp_out(struct hda_codec *codec)
9302{
9303 struct alc_spec *spec = codec->spec;
9304 hda_nid_t pin;
9305
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009306 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009307 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009308 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9309 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009310}
9311
9312static void alc861_auto_init_analog_input(struct hda_codec *codec)
9313{
9314 struct alc_spec *spec = codec->spec;
9315 int i;
9316
9317 for (i = 0; i < AUTO_PIN_LAST; i++) {
9318 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009319 if (nid >= 0x0c && nid <= 0x11) {
9320 snd_hda_codec_write(codec, nid, 0,
9321 AC_VERB_SET_PIN_WIDGET_CONTROL,
9322 i <= AUTO_PIN_FRONT_MIC ?
9323 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009324 }
9325 }
9326}
9327
9328/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009329/* return 1 if successful, 0 if the proper config is not found,
9330 * or a negative error code
9331 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009332static int alc861_parse_auto_config(struct hda_codec *codec)
9333{
9334 struct alc_spec *spec = codec->spec;
9335 int err;
9336 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9337
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009338 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9339 alc861_ignore);
9340 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009341 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009342 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009343 return 0; /* can't find valid BIOS pin config */
9344
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009345 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9346 if (err < 0)
9347 return err;
9348 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9349 if (err < 0)
9350 return err;
9351 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9352 if (err < 0)
9353 return err;
9354 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9355 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009356 return err;
9357
9358 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9359
9360 if (spec->autocfg.dig_out_pin)
9361 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9362
9363 if (spec->kctl_alloc)
9364 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9365
9366 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9367
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009368 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009369 spec->input_mux = &spec->private_imux;
9370
9371 spec->adc_nids = alc861_adc_nids;
9372 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9373 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9374 spec->num_mixers++;
9375
9376 return 1;
9377}
9378
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009379/* additional initialization for auto-configuration model */
9380static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009381{
Kailang Yangdf694da2005-12-05 19:42:22 +01009382 alc861_auto_init_multi_out(codec);
9383 alc861_auto_init_hp_out(codec);
9384 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009385}
9386
9387
9388/*
9389 * configuration and preset
9390 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009391static const char *alc861_models[ALC861_MODEL_LAST] = {
9392 [ALC861_3ST] = "3stack",
9393 [ALC660_3ST] = "3stack-660",
9394 [ALC861_3ST_DIG] = "3stack-dig",
9395 [ALC861_6ST_DIG] = "6stack-dig",
9396 [ALC861_UNIWILL_M31] = "uniwill-m31",
9397 [ALC861_TOSHIBA] = "toshiba",
9398 [ALC861_ASUS] = "asus",
9399 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9400 [ALC861_AUTO] = "auto",
9401};
9402
9403static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009404 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009405 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9406 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009407 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +02009408 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009409 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +02009410 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +01009411 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009412 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
9413 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009414 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009415 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009416 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009417 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009418 {}
9419};
9420
9421static struct alc_config_preset alc861_presets[] = {
9422 [ALC861_3ST] = {
9423 .mixers = { alc861_3ST_mixer },
9424 .init_verbs = { alc861_threestack_init_verbs },
9425 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9426 .dac_nids = alc861_dac_nids,
9427 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9428 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009429 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009430 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9431 .adc_nids = alc861_adc_nids,
9432 .input_mux = &alc861_capture_source,
9433 },
9434 [ALC861_3ST_DIG] = {
9435 .mixers = { alc861_base_mixer },
9436 .init_verbs = { alc861_threestack_init_verbs },
9437 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9438 .dac_nids = alc861_dac_nids,
9439 .dig_out_nid = ALC861_DIGOUT_NID,
9440 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9441 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009442 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009443 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9444 .adc_nids = alc861_adc_nids,
9445 .input_mux = &alc861_capture_source,
9446 },
9447 [ALC861_6ST_DIG] = {
9448 .mixers = { alc861_base_mixer },
9449 .init_verbs = { alc861_base_init_verbs },
9450 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9451 .dac_nids = alc861_dac_nids,
9452 .dig_out_nid = ALC861_DIGOUT_NID,
9453 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9454 .channel_mode = alc861_8ch_modes,
9455 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9456 .adc_nids = alc861_adc_nids,
9457 .input_mux = &alc861_capture_source,
9458 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009459 [ALC660_3ST] = {
9460 .mixers = { alc861_3ST_mixer },
9461 .init_verbs = { alc861_threestack_init_verbs },
9462 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9463 .dac_nids = alc660_dac_nids,
9464 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9465 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009466 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009467 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9468 .adc_nids = alc861_adc_nids,
9469 .input_mux = &alc861_capture_source,
9470 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009471 [ALC861_UNIWILL_M31] = {
9472 .mixers = { alc861_uniwill_m31_mixer },
9473 .init_verbs = { alc861_uniwill_m31_init_verbs },
9474 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9475 .dac_nids = alc861_dac_nids,
9476 .dig_out_nid = ALC861_DIGOUT_NID,
9477 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9478 .channel_mode = alc861_uniwill_m31_modes,
9479 .need_dac_fix = 1,
9480 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9481 .adc_nids = alc861_adc_nids,
9482 .input_mux = &alc861_capture_source,
9483 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009484 [ALC861_TOSHIBA] = {
9485 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009486 .init_verbs = { alc861_base_init_verbs,
9487 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009488 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9489 .dac_nids = alc861_dac_nids,
9490 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9491 .channel_mode = alc883_3ST_2ch_modes,
9492 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9493 .adc_nids = alc861_adc_nids,
9494 .input_mux = &alc861_capture_source,
9495 .unsol_event = alc861_toshiba_unsol_event,
9496 .init_hook = alc861_toshiba_automute,
9497 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009498 [ALC861_ASUS] = {
9499 .mixers = { alc861_asus_mixer },
9500 .init_verbs = { alc861_asus_init_verbs },
9501 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9502 .dac_nids = alc861_dac_nids,
9503 .dig_out_nid = ALC861_DIGOUT_NID,
9504 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9505 .channel_mode = alc861_asus_modes,
9506 .need_dac_fix = 1,
9507 .hp_nid = 0x06,
9508 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9509 .adc_nids = alc861_adc_nids,
9510 .input_mux = &alc861_capture_source,
9511 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009512 [ALC861_ASUS_LAPTOP] = {
9513 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9514 .init_verbs = { alc861_asus_init_verbs,
9515 alc861_asus_laptop_init_verbs },
9516 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9517 .dac_nids = alc861_dac_nids,
9518 .dig_out_nid = ALC861_DIGOUT_NID,
9519 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9520 .channel_mode = alc883_3ST_2ch_modes,
9521 .need_dac_fix = 1,
9522 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9523 .adc_nids = alc861_adc_nids,
9524 .input_mux = &alc861_capture_source,
9525 },
9526};
Kailang Yangdf694da2005-12-05 19:42:22 +01009527
9528
9529static int patch_alc861(struct hda_codec *codec)
9530{
9531 struct alc_spec *spec;
9532 int board_config;
9533 int err;
9534
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009535 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009536 if (spec == NULL)
9537 return -ENOMEM;
9538
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009539 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009540
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009541 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9542 alc861_models,
9543 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009544
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009545 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009546 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9547 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009548 board_config = ALC861_AUTO;
9549 }
9550
9551 if (board_config == ALC861_AUTO) {
9552 /* automatic parse from the BIOS config */
9553 err = alc861_parse_auto_config(codec);
9554 if (err < 0) {
9555 alc_free(codec);
9556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009557 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009558 printk(KERN_INFO
9559 "hda_codec: Cannot set up configuration "
9560 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009561 board_config = ALC861_3ST_DIG;
9562 }
9563 }
9564
9565 if (board_config != ALC861_AUTO)
9566 setup_preset(spec, &alc861_presets[board_config]);
9567
9568 spec->stream_name_analog = "ALC861 Analog";
9569 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9570 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9571
9572 spec->stream_name_digital = "ALC861 Digital";
9573 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9574 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9575
9576 codec->patch_ops = alc_patch_ops;
9577 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009578 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009579
9580 return 0;
9581}
9582
9583/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009584 * ALC861-VD support
9585 *
9586 * Based on ALC882
9587 *
9588 * In addition, an independent DAC
9589 */
9590#define ALC861VD_DIGOUT_NID 0x06
9591
9592static hda_nid_t alc861vd_dac_nids[4] = {
9593 /* front, surr, clfe, side surr */
9594 0x02, 0x03, 0x04, 0x05
9595};
9596
9597/* dac_nids for ALC660vd are in a different order - according to
9598 * Realtek's driver.
9599 * This should probably tesult in a different mixer for 6stack models
9600 * of ALC660vd codecs, but for now there is only 3stack mixer
9601 * - and it is the same as in 861vd.
9602 * adc_nids in ALC660vd are (is) the same as in 861vd
9603 */
9604static hda_nid_t alc660vd_dac_nids[3] = {
9605 /* front, rear, clfe, rear_surr */
9606 0x02, 0x04, 0x03
9607};
9608
9609static hda_nid_t alc861vd_adc_nids[1] = {
9610 /* ADC0 */
9611 0x09,
9612};
9613
9614/* input MUX */
9615/* FIXME: should be a matrix-type input source selection */
9616static struct hda_input_mux alc861vd_capture_source = {
9617 .num_items = 4,
9618 .items = {
9619 { "Mic", 0x0 },
9620 { "Front Mic", 0x1 },
9621 { "Line", 0x2 },
9622 { "CD", 0x4 },
9623 },
9624};
9625
Kailang Yang272a5272007-05-14 11:00:38 +02009626static struct hda_input_mux alc861vd_dallas_capture_source = {
9627 .num_items = 3,
9628 .items = {
9629 { "Front Mic", 0x0 },
9630 { "ATAPI Mic", 0x1 },
9631 { "Line In", 0x5 },
9632 },
9633};
9634
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009635#define alc861vd_mux_enum_info alc_mux_enum_info
9636#define alc861vd_mux_enum_get alc_mux_enum_get
9637
9638static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9639 struct snd_ctl_elem_value *ucontrol)
9640{
9641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9642 struct alc_spec *spec = codec->spec;
9643 const struct hda_input_mux *imux = spec->input_mux;
9644 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9645 static hda_nid_t capture_mixers[1] = { 0x22 };
9646 hda_nid_t nid = capture_mixers[adc_idx];
9647 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9648 unsigned int i, idx;
9649
9650 idx = ucontrol->value.enumerated.item[0];
9651 if (idx >= imux->num_items)
9652 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009653 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009654 return 0;
9655 for (i = 0; i < imux->num_items; i++) {
9656 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9657 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9658 v | (imux->items[i].index << 8));
9659 }
9660 *cur_val = idx;
9661 return 1;
9662}
9663
9664/*
9665 * 2ch mode
9666 */
9667static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9668 { 2, NULL }
9669};
9670
9671/*
9672 * 6ch mode
9673 */
9674static struct hda_verb alc861vd_6stack_ch6_init[] = {
9675 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9676 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9677 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9678 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9679 { } /* end */
9680};
9681
9682/*
9683 * 8ch mode
9684 */
9685static struct hda_verb alc861vd_6stack_ch8_init[] = {
9686 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9687 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9688 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9689 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9690 { } /* end */
9691};
9692
9693static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9694 { 6, alc861vd_6stack_ch6_init },
9695 { 8, alc861vd_6stack_ch8_init },
9696};
9697
9698static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9699 {
9700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9701 .name = "Channel Mode",
9702 .info = alc_ch_mode_info,
9703 .get = alc_ch_mode_get,
9704 .put = alc_ch_mode_put,
9705 },
9706 { } /* end */
9707};
9708
9709static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9710 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9711 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9712
9713 {
9714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9715 /* The multiple "Capture Source" controls confuse alsamixer
9716 * So call somewhat different..
9717 *FIXME: the controls appear in the "playback" view!
9718 */
9719 /* .name = "Capture Source", */
9720 .name = "Input Source",
9721 .count = 1,
9722 .info = alc861vd_mux_enum_info,
9723 .get = alc861vd_mux_enum_get,
9724 .put = alc861vd_mux_enum_put,
9725 },
9726 { } /* end */
9727};
9728
9729/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9730 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9731 */
9732static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9733 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9734 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9735
9736 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9737 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9738
9739 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9740 HDA_OUTPUT),
9741 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9742 HDA_OUTPUT),
9743 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9744 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9745
9746 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9747 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9748
9749 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9750
9751 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9754
9755 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9756 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9757 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9758
9759 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9760 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9761
9762 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9763 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9764
9765 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9766 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9767
9768 { } /* end */
9769};
9770
9771static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9772 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9773 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9774
9775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9776
9777 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9780
9781 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9782 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9783 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9784
9785 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9786 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9787
9788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9790
9791 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9792 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9793
9794 { } /* end */
9795};
9796
Kailang Yangbdd148a2007-05-08 15:19:08 +02009797static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9798 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9799 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9800 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9801
9802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9803
9804 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9807
9808 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9811
9812 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9813 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9814
9815 { } /* end */
9816};
9817
Kailang Yang272a5272007-05-14 11:00:38 +02009818/* Pin assignment: Front=0x14, HP = 0x15,
9819 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9820 */
9821static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9822 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9823 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9824 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9825 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9828 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9829 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9830 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9831 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9832 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9833 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9834 {
9835 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9836 /* .name = "Capture Source", */
9837 .name = "Input Source",
9838 .count = 1,
9839 .info = alc882_mux_enum_info,
9840 .get = alc882_mux_enum_get,
9841 .put = alc882_mux_enum_put,
9842 },
9843 { } /* end */
9844};
9845
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009846/*
9847 * generic initialization of ADC, input mixers and output mixers
9848 */
9849static struct hda_verb alc861vd_volume_init_verbs[] = {
9850 /*
9851 * Unmute ADC0 and set the default input to mic-in
9852 */
9853 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9854 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9855
9856 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
9857 * the analog-loopback mixer widget
9858 */
9859 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9865
9866 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +02009867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009871
9872 /*
9873 * Set up output mixers (0x02 - 0x05)
9874 */
9875 /* set vol=0 to output mixers */
9876 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9877 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9878 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9879 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9880
9881 /* set up input amps for analog loopback */
9882 /* Amp Indices: DAC = 0, mixer = 1 */
9883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9884 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9885 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9886 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9887 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9888 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9889 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9890 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9891
9892 { }
9893};
9894
9895/*
9896 * 3-stack pin configuration:
9897 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
9898 */
9899static struct hda_verb alc861vd_3stack_init_verbs[] = {
9900 /*
9901 * Set pin mode and muting
9902 */
9903 /* set front pin widgets 0x14 for output */
9904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9906 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9907
9908 /* Mic (rear) pin: input vref at 80% */
9909 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9911 /* Front Mic pin: input vref at 80% */
9912 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9913 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9914 /* Line In pin: input */
9915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9916 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9917 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9919 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9920 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9921 /* CD pin widget for input */
9922 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9923
9924 { }
9925};
9926
9927/*
9928 * 6-stack pin configuration:
9929 */
9930static struct hda_verb alc861vd_6stack_init_verbs[] = {
9931 /*
9932 * Set pin mode and muting
9933 */
9934 /* set front pin widgets 0x14 for output */
9935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9937 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9938
9939 /* Rear Pin: output 1 (0x0d) */
9940 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9941 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9942 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9943 /* CLFE Pin: output 2 (0x0e) */
9944 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9945 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9946 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
9947 /* Side Pin: output 3 (0x0f) */
9948 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9949 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9950 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9951
9952 /* Mic (rear) pin: input vref at 80% */
9953 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9954 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9955 /* Front Mic pin: input vref at 80% */
9956 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9957 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9958 /* Line In pin: input */
9959 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9960 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9961 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9964 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9965 /* CD pin widget for input */
9966 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9967
9968 { }
9969};
9970
Kailang Yangbdd148a2007-05-08 15:19:08 +02009971static struct hda_verb alc861vd_eapd_verbs[] = {
9972 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9973 { }
9974};
9975
9976static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
9977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9980 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9981 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9982 {}
9983};
9984
9985/* toggle speaker-output according to the hp-jack state */
9986static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
9987{
9988 unsigned int present;
9989 unsigned char bits;
9990
9991 present = snd_hda_codec_read(codec, 0x1b, 0,
9992 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9993 bits = present ? 0x80 : 0;
9994 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9995 0x80, bits);
9996 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9997 0x80, bits);
9998}
9999
10000static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10001{
10002 unsigned int present;
10003 unsigned char bits;
10004
10005 present = snd_hda_codec_read(codec, 0x18, 0,
10006 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10007 bits = present ? 0x80 : 0;
10008 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10009 0x80, bits);
10010 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10011 0x80, bits);
10012}
10013
10014static void alc861vd_lenovo_automute(struct hda_codec *codec)
10015{
10016 alc861vd_lenovo_hp_automute(codec);
10017 alc861vd_lenovo_mic_automute(codec);
10018}
10019
10020static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10021 unsigned int res)
10022{
10023 switch (res >> 26) {
10024 case ALC880_HP_EVENT:
10025 alc861vd_lenovo_hp_automute(codec);
10026 break;
10027 case ALC880_MIC_EVENT:
10028 alc861vd_lenovo_mic_automute(codec);
10029 break;
10030 }
10031}
10032
Kailang Yang272a5272007-05-14 11:00:38 +020010033static struct hda_verb alc861vd_dallas_verbs[] = {
10034 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10035 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10036 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10037 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10038
10039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10042 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10043 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10044 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10045 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10046 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10047
10048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10052 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10053 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10054 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10056
10057 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10058 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10059 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10060 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10061 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10063 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10064 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10065
10066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10070
10071 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10072 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10073 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10074
10075 { } /* end */
10076};
10077
10078/* toggle speaker-output according to the hp-jack state */
10079static void alc861vd_dallas_automute(struct hda_codec *codec)
10080{
10081 unsigned int present;
10082
10083 present = snd_hda_codec_read(codec, 0x15, 0,
10084 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10085 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10086 0x80, present ? 0x80 : 0);
10087 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10088 0x80, present ? 0x80 : 0);
10089}
10090
10091static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10092{
10093 if ((res >> 26) == ALC880_HP_EVENT)
10094 alc861vd_dallas_automute(codec);
10095}
10096
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010097/* pcm configuration: identiacal with ALC880 */
10098#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10099#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10100#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10101#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10102
10103/*
10104 * configuration and preset
10105 */
10106static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10107 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +020010108 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010109 [ALC861VD_3ST] = "3stack",
10110 [ALC861VD_3ST_DIG] = "3stack-digout",
10111 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010112 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010113 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010114 [ALC861VD_AUTO] = "auto",
10115};
10116
10117static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010118 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010119 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010120 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010121 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10122 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10123
Kailang Yang272a5272007-05-14 11:00:38 +020010124 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10125 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010126 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10127 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010128 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010129 {}
10130};
10131
10132static struct alc_config_preset alc861vd_presets[] = {
10133 [ALC660VD_3ST] = {
10134 .mixers = { alc861vd_3st_mixer },
10135 .init_verbs = { alc861vd_volume_init_verbs,
10136 alc861vd_3stack_init_verbs },
10137 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10138 .dac_nids = alc660vd_dac_nids,
10139 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10140 .adc_nids = alc861vd_adc_nids,
10141 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10142 .channel_mode = alc861vd_3stack_2ch_modes,
10143 .input_mux = &alc861vd_capture_source,
10144 },
Mike Crash6963f842007-06-25 12:12:51 +020010145 [ALC660VD_3ST_DIG] = {
10146 .mixers = { alc861vd_3st_mixer },
10147 .init_verbs = { alc861vd_volume_init_verbs,
10148 alc861vd_3stack_init_verbs },
10149 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10150 .dac_nids = alc660vd_dac_nids,
10151 .dig_out_nid = ALC861VD_DIGOUT_NID,
10152 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10153 .adc_nids = alc861vd_adc_nids,
10154 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10155 .channel_mode = alc861vd_3stack_2ch_modes,
10156 .input_mux = &alc861vd_capture_source,
10157 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010158 [ALC861VD_3ST] = {
10159 .mixers = { alc861vd_3st_mixer },
10160 .init_verbs = { alc861vd_volume_init_verbs,
10161 alc861vd_3stack_init_verbs },
10162 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10163 .dac_nids = alc861vd_dac_nids,
10164 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10165 .channel_mode = alc861vd_3stack_2ch_modes,
10166 .input_mux = &alc861vd_capture_source,
10167 },
10168 [ALC861VD_3ST_DIG] = {
10169 .mixers = { alc861vd_3st_mixer },
10170 .init_verbs = { alc861vd_volume_init_verbs,
10171 alc861vd_3stack_init_verbs },
10172 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10173 .dac_nids = alc861vd_dac_nids,
10174 .dig_out_nid = ALC861VD_DIGOUT_NID,
10175 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10176 .channel_mode = alc861vd_3stack_2ch_modes,
10177 .input_mux = &alc861vd_capture_source,
10178 },
10179 [ALC861VD_6ST_DIG] = {
10180 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10181 .init_verbs = { alc861vd_volume_init_verbs,
10182 alc861vd_6stack_init_verbs },
10183 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10184 .dac_nids = alc861vd_dac_nids,
10185 .dig_out_nid = ALC861VD_DIGOUT_NID,
10186 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10187 .channel_mode = alc861vd_6stack_modes,
10188 .input_mux = &alc861vd_capture_source,
10189 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010190 [ALC861VD_LENOVO] = {
10191 .mixers = { alc861vd_lenovo_mixer },
10192 .init_verbs = { alc861vd_volume_init_verbs,
10193 alc861vd_3stack_init_verbs,
10194 alc861vd_eapd_verbs,
10195 alc861vd_lenovo_unsol_verbs },
10196 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10197 .dac_nids = alc660vd_dac_nids,
10198 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10199 .adc_nids = alc861vd_adc_nids,
10200 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10201 .channel_mode = alc861vd_3stack_2ch_modes,
10202 .input_mux = &alc861vd_capture_source,
10203 .unsol_event = alc861vd_lenovo_unsol_event,
10204 .init_hook = alc861vd_lenovo_automute,
10205 },
Kailang Yang272a5272007-05-14 11:00:38 +020010206 [ALC861VD_DALLAS] = {
10207 .mixers = { alc861vd_dallas_mixer },
10208 .init_verbs = { alc861vd_dallas_verbs },
10209 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10210 .dac_nids = alc861vd_dac_nids,
10211 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10212 .adc_nids = alc861vd_adc_nids,
10213 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10214 .channel_mode = alc861vd_3stack_2ch_modes,
10215 .input_mux = &alc861vd_dallas_capture_source,
10216 .unsol_event = alc861vd_dallas_unsol_event,
10217 .init_hook = alc861vd_dallas_automute,
10218 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010219};
10220
10221/*
10222 * BIOS auto configuration
10223 */
10224static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10225 hda_nid_t nid, int pin_type, int dac_idx)
10226{
10227 /* set as output */
10228 snd_hda_codec_write(codec, nid, 0,
10229 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10230 snd_hda_codec_write(codec, nid, 0,
10231 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10232}
10233
10234static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10235{
10236 struct alc_spec *spec = codec->spec;
10237 int i;
10238
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010239 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010240 for (i = 0; i <= HDA_SIDE; i++) {
10241 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010242 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010243 if (nid)
10244 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010245 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010246 }
10247}
10248
10249
10250static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10251{
10252 struct alc_spec *spec = codec->spec;
10253 hda_nid_t pin;
10254
10255 pin = spec->autocfg.hp_pins[0];
10256 if (pin) /* connect to front and use dac 0 */
10257 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10258}
10259
10260#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10261#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10262
10263static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10264{
10265 struct alc_spec *spec = codec->spec;
10266 int i;
10267
10268 for (i = 0; i < AUTO_PIN_LAST; i++) {
10269 hda_nid_t nid = spec->autocfg.input_pins[i];
10270 if (alc861vd_is_input_pin(nid)) {
10271 snd_hda_codec_write(codec, nid, 0,
10272 AC_VERB_SET_PIN_WIDGET_CONTROL,
10273 i <= AUTO_PIN_FRONT_MIC ?
10274 PIN_VREF80 : PIN_IN);
10275 if (nid != ALC861VD_PIN_CD_NID)
10276 snd_hda_codec_write(codec, nid, 0,
10277 AC_VERB_SET_AMP_GAIN_MUTE,
10278 AMP_OUT_MUTE);
10279 }
10280 }
10281}
10282
10283#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10284#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10285
10286/* add playback controls from the parsed DAC table */
10287/* Based on ALC880 version. But ALC861VD has separate,
10288 * different NIDs for mute/unmute switch and volume control */
10289static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10290 const struct auto_pin_cfg *cfg)
10291{
10292 char name[32];
10293 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10294 hda_nid_t nid_v, nid_s;
10295 int i, err;
10296
10297 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010298 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010299 continue;
10300 nid_v = alc861vd_idx_to_mixer_vol(
10301 alc880_dac_to_idx(
10302 spec->multiout.dac_nids[i]));
10303 nid_s = alc861vd_idx_to_mixer_switch(
10304 alc880_dac_to_idx(
10305 spec->multiout.dac_nids[i]));
10306
10307 if (i == 2) {
10308 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010309 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10310 "Center Playback Volume",
10311 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10312 HDA_OUTPUT));
10313 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010314 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010315 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10316 "LFE Playback Volume",
10317 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10318 HDA_OUTPUT));
10319 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010320 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010321 err = add_control(spec, ALC_CTL_BIND_MUTE,
10322 "Center Playback Switch",
10323 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10324 HDA_INPUT));
10325 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010326 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010327 err = add_control(spec, ALC_CTL_BIND_MUTE,
10328 "LFE Playback Switch",
10329 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10330 HDA_INPUT));
10331 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010332 return err;
10333 } else {
10334 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010335 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10336 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10337 HDA_OUTPUT));
10338 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010339 return err;
10340 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010341 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010342 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010343 HDA_INPUT));
10344 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010345 return err;
10346 }
10347 }
10348 return 0;
10349}
10350
10351/* add playback controls for speaker and HP outputs */
10352/* Based on ALC880 version. But ALC861VD has separate,
10353 * different NIDs for mute/unmute switch and volume control */
10354static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10355 hda_nid_t pin, const char *pfx)
10356{
10357 hda_nid_t nid_v, nid_s;
10358 int err;
10359 char name[32];
10360
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010361 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010362 return 0;
10363
10364 if (alc880_is_fixed_pin(pin)) {
10365 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10366 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010367 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010368 spec->multiout.hp_nid = nid_v;
10369 else
10370 spec->multiout.extra_out_nid[0] = nid_v;
10371 /* control HP volume/switch on the output mixer amp */
10372 nid_v = alc861vd_idx_to_mixer_vol(
10373 alc880_fixed_pin_idx(pin));
10374 nid_s = alc861vd_idx_to_mixer_switch(
10375 alc880_fixed_pin_idx(pin));
10376
10377 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010378 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10379 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10380 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010381 return err;
10382 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010383 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10384 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10385 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010386 return err;
10387 } else if (alc880_is_multi_pin(pin)) {
10388 /* set manual connection */
10389 /* we have only a switch on HP-out PIN */
10390 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010391 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10392 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10393 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010394 return err;
10395 }
10396 return 0;
10397}
10398
10399/* parse the BIOS configuration and set up the alc_spec
10400 * return 1 if successful, 0 if the proper config is not found,
10401 * or a negative error code
10402 * Based on ALC880 version - had to change it to override
10403 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10404static int alc861vd_parse_auto_config(struct hda_codec *codec)
10405{
10406 struct alc_spec *spec = codec->spec;
10407 int err;
10408 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10409
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010410 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10411 alc861vd_ignore);
10412 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010413 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010414 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010415 return 0; /* can't find valid BIOS pin config */
10416
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010417 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10418 if (err < 0)
10419 return err;
10420 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10421 if (err < 0)
10422 return err;
10423 err = alc861vd_auto_create_extra_out(spec,
10424 spec->autocfg.speaker_pins[0],
10425 "Speaker");
10426 if (err < 0)
10427 return err;
10428 err = alc861vd_auto_create_extra_out(spec,
10429 spec->autocfg.hp_pins[0],
10430 "Headphone");
10431 if (err < 0)
10432 return err;
10433 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10434 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010435 return err;
10436
10437 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10438
10439 if (spec->autocfg.dig_out_pin)
10440 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10441
10442 if (spec->kctl_alloc)
10443 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10444
10445 spec->init_verbs[spec->num_init_verbs++]
10446 = alc861vd_volume_init_verbs;
10447
10448 spec->num_mux_defs = 1;
10449 spec->input_mux = &spec->private_imux;
10450
10451 return 1;
10452}
10453
10454/* additional initialization for auto-configuration model */
10455static void alc861vd_auto_init(struct hda_codec *codec)
10456{
10457 alc861vd_auto_init_multi_out(codec);
10458 alc861vd_auto_init_hp_out(codec);
10459 alc861vd_auto_init_analog_input(codec);
10460}
10461
10462static int patch_alc861vd(struct hda_codec *codec)
10463{
10464 struct alc_spec *spec;
10465 int err, board_config;
10466
10467 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10468 if (spec == NULL)
10469 return -ENOMEM;
10470
10471 codec->spec = spec;
10472
10473 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10474 alc861vd_models,
10475 alc861vd_cfg_tbl);
10476
10477 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10478 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10479 "ALC861VD, trying auto-probe from BIOS...\n");
10480 board_config = ALC861VD_AUTO;
10481 }
10482
10483 if (board_config == ALC861VD_AUTO) {
10484 /* automatic parse from the BIOS config */
10485 err = alc861vd_parse_auto_config(codec);
10486 if (err < 0) {
10487 alc_free(codec);
10488 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010489 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010490 printk(KERN_INFO
10491 "hda_codec: Cannot set up configuration "
10492 "from BIOS. Using base mode...\n");
10493 board_config = ALC861VD_3ST;
10494 }
10495 }
10496
10497 if (board_config != ALC861VD_AUTO)
10498 setup_preset(spec, &alc861vd_presets[board_config]);
10499
10500 spec->stream_name_analog = "ALC861VD Analog";
10501 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10502 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10503
10504 spec->stream_name_digital = "ALC861VD Digital";
10505 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10506 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10507
10508 spec->adc_nids = alc861vd_adc_nids;
10509 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10510
10511 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10512 spec->num_mixers++;
10513
10514 codec->patch_ops = alc_patch_ops;
10515
10516 if (board_config == ALC861VD_AUTO)
10517 spec->init_hook = alc861vd_auto_init;
10518
10519 return 0;
10520}
10521
10522/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010523 * ALC662 support
10524 *
10525 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10526 * configuration. Each pin widget can choose any input DACs and a mixer.
10527 * Each ADC is connected from a mixer of all inputs. This makes possible
10528 * 6-channel independent captures.
10529 *
10530 * In addition, an independent DAC for the multi-playback (not used in this
10531 * driver yet).
10532 */
10533#define ALC662_DIGOUT_NID 0x06
10534#define ALC662_DIGIN_NID 0x0a
10535
10536static hda_nid_t alc662_dac_nids[4] = {
10537 /* front, rear, clfe, rear_surr */
10538 0x02, 0x03, 0x04
10539};
10540
10541static hda_nid_t alc662_adc_nids[1] = {
10542 /* ADC1-2 */
10543 0x09,
10544};
10545/* input MUX */
10546/* FIXME: should be a matrix-type input source selection */
10547
10548static struct hda_input_mux alc662_capture_source = {
10549 .num_items = 4,
10550 .items = {
10551 { "Mic", 0x0 },
10552 { "Front Mic", 0x1 },
10553 { "Line", 0x2 },
10554 { "CD", 0x4 },
10555 },
10556};
10557
10558static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10559 .num_items = 2,
10560 .items = {
10561 { "Mic", 0x1 },
10562 { "Line", 0x2 },
10563 },
10564};
10565#define alc662_mux_enum_info alc_mux_enum_info
10566#define alc662_mux_enum_get alc_mux_enum_get
10567
10568static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10569 struct snd_ctl_elem_value *ucontrol)
10570{
10571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10572 struct alc_spec *spec = codec->spec;
10573 const struct hda_input_mux *imux = spec->input_mux;
10574 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10575 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10576 hda_nid_t nid = capture_mixers[adc_idx];
10577 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10578 unsigned int i, idx;
10579
10580 idx = ucontrol->value.enumerated.item[0];
10581 if (idx >= imux->num_items)
10582 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010583 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010584 return 0;
10585 for (i = 0; i < imux->num_items; i++) {
10586 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10587 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10588 v | (imux->items[i].index << 8));
10589 }
10590 *cur_val = idx;
10591 return 1;
10592}
10593/*
10594 * 2ch mode
10595 */
10596static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10597 { 2, NULL }
10598};
10599
10600/*
10601 * 2ch mode
10602 */
10603static struct hda_verb alc662_3ST_ch2_init[] = {
10604 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10605 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10606 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10607 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10608 { } /* end */
10609};
10610
10611/*
10612 * 6ch mode
10613 */
10614static struct hda_verb alc662_3ST_ch6_init[] = {
10615 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10616 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10617 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10618 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10619 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10620 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10621 { } /* end */
10622};
10623
10624static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10625 { 2, alc662_3ST_ch2_init },
10626 { 6, alc662_3ST_ch6_init },
10627};
10628
10629/*
10630 * 2ch mode
10631 */
10632static struct hda_verb alc662_sixstack_ch6_init[] = {
10633 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10634 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10635 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10636 { } /* end */
10637};
10638
10639/*
10640 * 6ch mode
10641 */
10642static struct hda_verb alc662_sixstack_ch8_init[] = {
10643 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10644 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10645 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10646 { } /* end */
10647};
10648
10649static struct hda_channel_mode alc662_5stack_modes[2] = {
10650 { 2, alc662_sixstack_ch6_init },
10651 { 6, alc662_sixstack_ch8_init },
10652};
10653
10654/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10655 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10656 */
10657
10658static struct snd_kcontrol_new alc662_base_mixer[] = {
10659 /* output mixer control */
10660 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10661 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10662 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10663 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10664 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10665 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10666 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10667 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10669
10670 /*Input mixer control */
10671 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10672 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10673 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10674 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10675 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10676 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10677 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10678 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10679
10680 /* Capture mixer control */
10681 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10682 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10683 {
10684 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10685 .name = "Capture Source",
10686 .count = 1,
10687 .info = alc_mux_enum_info,
10688 .get = alc_mux_enum_get,
10689 .put = alc_mux_enum_put,
10690 },
10691 { } /* end */
10692};
10693
10694static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10695 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10696 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10698 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10699 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10700 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10701 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10703 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10704 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10706 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10707 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10708 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10709 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10710 {
10711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10712 /* .name = "Capture Source", */
10713 .name = "Input Source",
10714 .count = 1,
10715 .info = alc662_mux_enum_info,
10716 .get = alc662_mux_enum_get,
10717 .put = alc662_mux_enum_put,
10718 },
10719 { } /* end */
10720};
10721
10722static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10723 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10724 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10725 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10726 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10727 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10728 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10729 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10730 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10731 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10732 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10733 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10734 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10735 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10736 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10737 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10738 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10739 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10740 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10741 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10742 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10743 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10744 {
10745 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10746 /* .name = "Capture Source", */
10747 .name = "Input Source",
10748 .count = 1,
10749 .info = alc662_mux_enum_info,
10750 .get = alc662_mux_enum_get,
10751 .put = alc662_mux_enum_put,
10752 },
10753 { } /* end */
10754};
10755
10756static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10757 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10758 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10759 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10760 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10761 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10762 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10763 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10766 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10767 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10768 {
10769 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10770 /* .name = "Capture Source", */
10771 .name = "Input Source",
10772 .count = 1,
10773 .info = alc662_mux_enum_info,
10774 .get = alc662_mux_enum_get,
10775 .put = alc662_mux_enum_put,
10776 },
10777 { } /* end */
10778};
10779
10780static struct snd_kcontrol_new alc662_chmode_mixer[] = {
10781 {
10782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10783 .name = "Channel Mode",
10784 .info = alc_ch_mode_info,
10785 .get = alc_ch_mode_get,
10786 .put = alc_ch_mode_put,
10787 },
10788 { } /* end */
10789};
10790
10791static struct hda_verb alc662_init_verbs[] = {
10792 /* ADC: mute amp left and right */
10793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10794 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10795 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10796
10797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10802
10803 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10804 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10805 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10806 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10807 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10808 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10809
10810 /* Front Pin: output 0 (0x0c) */
10811 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10812 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10813
10814 /* Rear Pin: output 1 (0x0d) */
10815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10817
10818 /* CLFE Pin: output 2 (0x0e) */
10819 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10821
10822 /* Mic (rear) pin: input vref at 80% */
10823 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10825 /* Front Mic pin: input vref at 80% */
10826 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10827 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10828 /* Line In pin: input */
10829 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10831 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10832 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10833 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10834 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10835 /* CD pin widget for input */
10836 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10837
10838 /* FIXME: use matrix-type input source selection */
10839 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10840 /* Input mixer */
10841 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10845 { }
10846};
10847
10848static struct hda_verb alc662_sue_init_verbs[] = {
10849 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10850 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10851 {}
10852};
10853
10854/*
10855 * generic initialization of ADC, input mixers and output mixers
10856 */
10857static struct hda_verb alc662_auto_init_verbs[] = {
10858 /*
10859 * Unmute ADC and set the default input to mic-in
10860 */
10861 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10863
10864 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10865 * mixer widget
10866 * Note: PASD motherboards uses the Line In 2 as the input for front
10867 * panel mic (mic 2)
10868 */
10869 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10875
10876 /*
10877 * Set up output mixers (0x0c - 0x0f)
10878 */
10879 /* set vol=0 to output mixers */
10880 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10881 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10882 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10883
10884 /* set up input amps for analog loopback */
10885 /* Amp Indices: DAC = 0, mixer = 1 */
10886 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10887 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10888 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10889 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10890 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10891 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10892
10893
10894 /* FIXME: use matrix-type input source selection */
10895 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10896 /* Input mixer */
10897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10898 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10900 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
10901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10902
10903 { }
10904};
10905
10906/* capture mixer elements */
10907static struct snd_kcontrol_new alc662_capture_mixer[] = {
10908 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10909 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10910 {
10911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10912 /* The multiple "Capture Source" controls confuse alsamixer
10913 * So call somewhat different..
10914 * FIXME: the controls appear in the "playback" view!
10915 */
10916 /* .name = "Capture Source", */
10917 .name = "Input Source",
10918 .count = 1,
10919 .info = alc882_mux_enum_info,
10920 .get = alc882_mux_enum_get,
10921 .put = alc882_mux_enum_put,
10922 },
10923 { } /* end */
10924};
10925
10926static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
10927{
10928 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010929 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010930
10931 present = snd_hda_codec_read(codec, 0x14, 0,
10932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010933 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010934 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010935 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010936 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010937 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010938}
10939
10940static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
10941{
10942 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010943 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010944
10945 present = snd_hda_codec_read(codec, 0x1b, 0,
10946 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010947 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010948 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010949 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010950 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010951 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010952 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010953 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010954 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010955 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010956}
10957
10958static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
10959 unsigned int res)
10960{
10961 if ((res >> 26) == ALC880_HP_EVENT)
10962 alc662_lenovo_101e_all_automute(codec);
10963 if ((res >> 26) == ALC880_FRONT_EVENT)
10964 alc662_lenovo_101e_ispeaker_automute(codec);
10965}
10966
10967
10968/* pcm configuration: identiacal with ALC880 */
10969#define alc662_pcm_analog_playback alc880_pcm_analog_playback
10970#define alc662_pcm_analog_capture alc880_pcm_analog_capture
10971#define alc662_pcm_digital_playback alc880_pcm_digital_playback
10972#define alc662_pcm_digital_capture alc880_pcm_digital_capture
10973
10974/*
10975 * configuration and preset
10976 */
10977static const char *alc662_models[ALC662_MODEL_LAST] = {
10978 [ALC662_3ST_2ch_DIG] = "3stack-dig",
10979 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
10980 [ALC662_3ST_6ch] = "3stack-6ch",
10981 [ALC662_5ST_DIG] = "6stack-dig",
10982 [ALC662_LENOVO_101E] = "lenovo-101e",
10983 [ALC662_AUTO] = "auto",
10984};
10985
10986static struct snd_pci_quirk alc662_cfg_tbl[] = {
10987 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
10988 {}
10989};
10990
10991static struct alc_config_preset alc662_presets[] = {
10992 [ALC662_3ST_2ch_DIG] = {
10993 .mixers = { alc662_3ST_2ch_mixer },
10994 .init_verbs = { alc662_init_verbs },
10995 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10996 .dac_nids = alc662_dac_nids,
10997 .dig_out_nid = ALC662_DIGOUT_NID,
10998 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10999 .adc_nids = alc662_adc_nids,
11000 .dig_in_nid = ALC662_DIGIN_NID,
11001 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11002 .channel_mode = alc662_3ST_2ch_modes,
11003 .input_mux = &alc662_capture_source,
11004 },
11005 [ALC662_3ST_6ch_DIG] = {
11006 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11007 .init_verbs = { alc662_init_verbs },
11008 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11009 .dac_nids = alc662_dac_nids,
11010 .dig_out_nid = ALC662_DIGOUT_NID,
11011 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11012 .adc_nids = alc662_adc_nids,
11013 .dig_in_nid = ALC662_DIGIN_NID,
11014 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11015 .channel_mode = alc662_3ST_6ch_modes,
11016 .need_dac_fix = 1,
11017 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011018 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011019 [ALC662_3ST_6ch] = {
11020 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11021 .init_verbs = { alc662_init_verbs },
11022 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11023 .dac_nids = alc662_dac_nids,
11024 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11025 .adc_nids = alc662_adc_nids,
11026 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11027 .channel_mode = alc662_3ST_6ch_modes,
11028 .need_dac_fix = 1,
11029 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011030 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011031 [ALC662_5ST_DIG] = {
11032 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11033 .init_verbs = { alc662_init_verbs },
11034 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11035 .dac_nids = alc662_dac_nids,
11036 .dig_out_nid = ALC662_DIGOUT_NID,
11037 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11038 .adc_nids = alc662_adc_nids,
11039 .dig_in_nid = ALC662_DIGIN_NID,
11040 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11041 .channel_mode = alc662_5stack_modes,
11042 .input_mux = &alc662_capture_source,
11043 },
11044 [ALC662_LENOVO_101E] = {
11045 .mixers = { alc662_lenovo_101e_mixer },
11046 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11047 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11048 .dac_nids = alc662_dac_nids,
11049 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11050 .adc_nids = alc662_adc_nids,
11051 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11052 .channel_mode = alc662_3ST_2ch_modes,
11053 .input_mux = &alc662_lenovo_101e_capture_source,
11054 .unsol_event = alc662_lenovo_101e_unsol_event,
11055 .init_hook = alc662_lenovo_101e_all_automute,
11056 },
11057
11058};
11059
11060
11061/*
11062 * BIOS auto configuration
11063 */
11064
11065/* add playback controls from the parsed DAC table */
11066static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11067 const struct auto_pin_cfg *cfg)
11068{
11069 char name[32];
11070 static const char *chname[4] = {
11071 "Front", "Surround", NULL /*CLFE*/, "Side"
11072 };
11073 hda_nid_t nid;
11074 int i, err;
11075
11076 for (i = 0; i < cfg->line_outs; i++) {
11077 if (!spec->multiout.dac_nids[i])
11078 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011079 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011080 if (i == 2) {
11081 /* Center/LFE */
11082 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11083 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011084 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11085 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011086 if (err < 0)
11087 return err;
11088 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11089 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011090 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11091 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011092 if (err < 0)
11093 return err;
11094 err = add_control(spec, ALC_CTL_BIND_MUTE,
11095 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011096 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11097 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011098 if (err < 0)
11099 return err;
11100 err = add_control(spec, ALC_CTL_BIND_MUTE,
11101 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011102 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11103 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011104 if (err < 0)
11105 return err;
11106 } else {
11107 sprintf(name, "%s Playback Volume", chname[i]);
11108 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011109 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11110 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011111 if (err < 0)
11112 return err;
11113 sprintf(name, "%s Playback Switch", chname[i]);
11114 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011115 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11116 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011117 if (err < 0)
11118 return err;
11119 }
11120 }
11121 return 0;
11122}
11123
11124/* add playback controls for speaker and HP outputs */
11125static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11126 const char *pfx)
11127{
11128 hda_nid_t nid;
11129 int err;
11130 char name[32];
11131
11132 if (!pin)
11133 return 0;
11134
11135 if (alc880_is_fixed_pin(pin)) {
11136 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11137 /* printk("DAC nid=%x\n",nid); */
11138 /* specify the DAC as the extra output */
11139 if (!spec->multiout.hp_nid)
11140 spec->multiout.hp_nid = nid;
11141 else
11142 spec->multiout.extra_out_nid[0] = nid;
11143 /* control HP volume/switch on the output mixer amp */
11144 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11145 sprintf(name, "%s Playback Volume", pfx);
11146 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11147 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11148 if (err < 0)
11149 return err;
11150 sprintf(name, "%s Playback Switch", pfx);
11151 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11152 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11153 if (err < 0)
11154 return err;
11155 } else if (alc880_is_multi_pin(pin)) {
11156 /* set manual connection */
11157 /* we have only a switch on HP-out PIN */
11158 sprintf(name, "%s Playback Switch", pfx);
11159 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11160 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11161 if (err < 0)
11162 return err;
11163 }
11164 return 0;
11165}
11166
11167/* create playback/capture controls for input pins */
11168static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11169 const struct auto_pin_cfg *cfg)
11170{
11171 struct hda_input_mux *imux = &spec->private_imux;
11172 int i, err, idx;
11173
11174 for (i = 0; i < AUTO_PIN_LAST; i++) {
11175 if (alc880_is_input_pin(cfg->input_pins[i])) {
11176 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11177 err = new_analog_input(spec, cfg->input_pins[i],
11178 auto_pin_cfg_labels[i],
11179 idx, 0x0b);
11180 if (err < 0)
11181 return err;
11182 imux->items[imux->num_items].label =
11183 auto_pin_cfg_labels[i];
11184 imux->items[imux->num_items].index =
11185 alc880_input_pin_idx(cfg->input_pins[i]);
11186 imux->num_items++;
11187 }
11188 }
11189 return 0;
11190}
11191
11192static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11193 hda_nid_t nid, int pin_type,
11194 int dac_idx)
11195{
11196 /* set as output */
11197 snd_hda_codec_write(codec, nid, 0,
11198 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11199 snd_hda_codec_write(codec, nid, 0,
11200 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11201 /* need the manual connection? */
11202 if (alc880_is_multi_pin(nid)) {
11203 struct alc_spec *spec = codec->spec;
11204 int idx = alc880_multi_pin_idx(nid);
11205 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11206 AC_VERB_SET_CONNECT_SEL,
11207 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11208 }
11209}
11210
11211static void alc662_auto_init_multi_out(struct hda_codec *codec)
11212{
11213 struct alc_spec *spec = codec->spec;
11214 int i;
11215
11216 for (i = 0; i <= HDA_SIDE; i++) {
11217 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011218 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011219 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011220 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011221 i);
11222 }
11223}
11224
11225static void alc662_auto_init_hp_out(struct hda_codec *codec)
11226{
11227 struct alc_spec *spec = codec->spec;
11228 hda_nid_t pin;
11229
11230 pin = spec->autocfg.hp_pins[0];
11231 if (pin) /* connect to front */
11232 /* use dac 0 */
11233 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11234}
11235
11236#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11237#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11238
11239static void alc662_auto_init_analog_input(struct hda_codec *codec)
11240{
11241 struct alc_spec *spec = codec->spec;
11242 int i;
11243
11244 for (i = 0; i < AUTO_PIN_LAST; i++) {
11245 hda_nid_t nid = spec->autocfg.input_pins[i];
11246 if (alc662_is_input_pin(nid)) {
11247 snd_hda_codec_write(codec, nid, 0,
11248 AC_VERB_SET_PIN_WIDGET_CONTROL,
11249 (i <= AUTO_PIN_FRONT_MIC ?
11250 PIN_VREF80 : PIN_IN));
11251 if (nid != ALC662_PIN_CD_NID)
11252 snd_hda_codec_write(codec, nid, 0,
11253 AC_VERB_SET_AMP_GAIN_MUTE,
11254 AMP_OUT_MUTE);
11255 }
11256 }
11257}
11258
11259static int alc662_parse_auto_config(struct hda_codec *codec)
11260{
11261 struct alc_spec *spec = codec->spec;
11262 int err;
11263 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11264
11265 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11266 alc662_ignore);
11267 if (err < 0)
11268 return err;
11269 if (!spec->autocfg.line_outs)
11270 return 0; /* can't find valid BIOS pin config */
11271
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011272 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11273 if (err < 0)
11274 return err;
11275 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11276 if (err < 0)
11277 return err;
11278 err = alc662_auto_create_extra_out(spec,
11279 spec->autocfg.speaker_pins[0],
11280 "Speaker");
11281 if (err < 0)
11282 return err;
11283 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11284 "Headphone");
11285 if (err < 0)
11286 return err;
11287 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11288 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011289 return err;
11290
11291 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11292
11293 if (spec->autocfg.dig_out_pin)
11294 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11295
11296 if (spec->kctl_alloc)
11297 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11298
11299 spec->num_mux_defs = 1;
11300 spec->input_mux = &spec->private_imux;
11301
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011302 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011303 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11304 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011305 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011306}
11307
11308/* additional initialization for auto-configuration model */
11309static void alc662_auto_init(struct hda_codec *codec)
11310{
11311 alc662_auto_init_multi_out(codec);
11312 alc662_auto_init_hp_out(codec);
11313 alc662_auto_init_analog_input(codec);
11314}
11315
11316static int patch_alc662(struct hda_codec *codec)
11317{
11318 struct alc_spec *spec;
11319 int err, board_config;
11320
11321 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11322 if (!spec)
11323 return -ENOMEM;
11324
11325 codec->spec = spec;
11326
11327 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11328 alc662_models,
11329 alc662_cfg_tbl);
11330 if (board_config < 0) {
11331 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11332 "trying auto-probe from BIOS...\n");
11333 board_config = ALC662_AUTO;
11334 }
11335
11336 if (board_config == ALC662_AUTO) {
11337 /* automatic parse from the BIOS config */
11338 err = alc662_parse_auto_config(codec);
11339 if (err < 0) {
11340 alc_free(codec);
11341 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011342 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011343 printk(KERN_INFO
11344 "hda_codec: Cannot set up configuration "
11345 "from BIOS. Using base mode...\n");
11346 board_config = ALC662_3ST_2ch_DIG;
11347 }
11348 }
11349
11350 if (board_config != ALC662_AUTO)
11351 setup_preset(spec, &alc662_presets[board_config]);
11352
11353 spec->stream_name_analog = "ALC662 Analog";
11354 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11355 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11356
11357 spec->stream_name_digital = "ALC662 Digital";
11358 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11359 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11360
11361 if (!spec->adc_nids && spec->input_mux) {
11362 spec->adc_nids = alc662_adc_nids;
11363 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11364 }
11365
11366 codec->patch_ops = alc_patch_ops;
11367 if (board_config == ALC662_AUTO)
11368 spec->init_hook = alc662_auto_init;
11369
11370 return 0;
11371}
11372
11373/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011374 * patch entries
11375 */
11376struct hda_codec_preset snd_hda_preset_realtek[] = {
11377 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011378 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011379 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011380 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011381 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011382 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11383 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11384 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011385 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11386 .patch = patch_alc883 },
11387 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11388 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011389 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011390 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011391 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011392 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011393 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011394 {} /* terminator */
11395};