blob: 63011133e3fb29bee32ad22248f4662749aceaa2 [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,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200156 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200157 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100158 ALC882_MODEL_LAST,
159};
160
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200161/* ALC883 models */
162enum {
163 ALC883_3ST_2ch_DIG,
164 ALC883_3ST_6ch_DIG,
165 ALC883_3ST_6ch,
166 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200167 ALC883_TARGA_DIG,
168 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200169 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200170 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200171 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200172 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100173 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200174 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200175 ALC883_LENOVO_NB0763,
176 ALC888_LENOVO_MS7195_DIG,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200177 ALC888_6ST_HP,
178 ALC888_3ST_HP,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200179 ALC883_AUTO,
180 ALC883_MODEL_LAST,
181};
182
Kailang Yangdf694da2005-12-05 19:42:22 +0100183/* for GPIO Poll */
184#define GPIO_MASK 0x03
185
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186struct alc_spec {
187 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100188 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 unsigned int num_mixers;
190
Kailang Yangdf694da2005-12-05 19:42:22 +0100191 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200192 * don't forget NULL
193 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200194 */
195 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
Takashi Iwai16ded522005-06-10 19:58:24 +0200197 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 struct hda_pcm_stream *stream_analog_playback;
199 struct hda_pcm_stream *stream_analog_capture;
200
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200201 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 struct hda_pcm_stream *stream_digital_playback;
203 struct hda_pcm_stream *stream_digital_capture;
204
205 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200206 struct hda_multi_out multiout; /* playback set-up
207 * max_channels, dacs must be set
208 * dig_out_nid and hp_nid are optional
209 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
211 /* capture */
212 unsigned int num_adc_nids;
213 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200214 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
216 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200217 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 const struct hda_input_mux *input_mux;
219 unsigned int cur_mux[3];
220
221 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100222 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200224 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100227 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200228
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200229 /* dynamic controls, init_verbs and input_mux */
230 struct auto_pin_cfg autocfg;
231 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100232 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200233 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100234 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100235
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100236 /* hooks */
237 void (*init_hook)(struct hda_codec *codec);
238 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
239
Takashi Iwai834be882006-03-01 14:16:17 +0100240 /* for pin sensing */
241 unsigned int sense_updated: 1;
242 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100243};
244
245/*
246 * configuration template - to be copied to the spec instance
247 */
248struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200249 struct snd_kcontrol_new *mixers[5]; /* should be identical size
250 * with spec
251 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100252 const struct hda_verb *init_verbs[5];
253 unsigned int num_dacs;
254 hda_nid_t *dac_nids;
255 hda_nid_t dig_out_nid; /* optional */
256 hda_nid_t hp_nid; /* optional */
257 unsigned int num_adc_nids;
258 hda_nid_t *adc_nids;
259 hda_nid_t dig_in_nid;
260 unsigned int num_channel_mode;
261 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200262 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200263 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100264 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100265 void (*unsol_event)(struct hda_codec *, unsigned int);
266 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267};
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270/*
271 * input MUX handling
272 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200273static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
274 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275{
276 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
277 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200278 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
279 if (mux_idx >= spec->num_mux_defs)
280 mux_idx = 0;
281 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282}
283
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200284static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
285 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286{
287 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
288 struct alc_spec *spec = codec->spec;
289 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
290
291 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
292 return 0;
293}
294
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200295static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
296 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297{
298 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
299 struct alc_spec *spec = codec->spec;
300 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200301 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
302 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200303 spec->adc_nids[adc_idx],
304 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305}
306
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200307
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308/*
309 * channel mode setting
310 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200311static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
312 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313{
314 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
315 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100316 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
317 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318}
319
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200320static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
321 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322{
323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
324 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100325 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200326 spec->num_channel_mode,
327 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328}
329
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200330static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
331 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
334 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200335 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
336 spec->num_channel_mode,
337 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200338 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200339 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
340 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341}
342
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100344 * Control the mode of pin widget settings via the mixer. "pc" is used
345 * instead of "%" to avoid consequences of accidently treating the % as
346 * being part of a format specifier. Maximum allowed length of a value is
347 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100348 *
349 * Note: some retasking pin complexes seem to ignore requests for input
350 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
351 * are requested. Therefore order this list so that this behaviour will not
352 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200353 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
354 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200355 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100357 "Mic 50pc bias", "Mic 80pc bias",
358 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100359};
360static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100361 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100362};
363/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200364 * in the pin being assumed to be exclusively an input or an output pin. In
365 * addition, "input" pins may or may not process the mic bias option
366 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
367 * accept requests for bias as of chip versions up to March 2006) and/or
368 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100369 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200370#define ALC_PIN_DIR_IN 0x00
371#define ALC_PIN_DIR_OUT 0x01
372#define ALC_PIN_DIR_INOUT 0x02
373#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
374#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100375
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200376/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100377 * For each direction the minimum and maximum values are given.
378 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200379static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100380 { 0, 2 }, /* ALC_PIN_DIR_IN */
381 { 3, 4 }, /* ALC_PIN_DIR_OUT */
382 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200383 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
384 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100385};
386#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
387#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
388#define alc_pin_mode_n_items(_dir) \
389 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
390
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200393{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100394 unsigned int item_num = uinfo->value.enumerated.item;
395 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
396
397 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200398 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100399 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
400
401 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
402 item_num = alc_pin_mode_min(dir);
403 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200404 return 0;
405}
406
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200407static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200409{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100410 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
412 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200414 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200415 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
416 AC_VERB_GET_PIN_WIDGET_CONTROL,
417 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200418
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100419 /* Find enumerated value for current pinctl setting */
420 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200421 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100422 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200423 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100424 return 0;
425}
426
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100429{
430 signed int change;
431 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
432 hda_nid_t nid = kcontrol->private_value & 0xffff;
433 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
434 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
436 AC_VERB_GET_PIN_WIDGET_CONTROL,
437 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100438
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200439 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100440 val = alc_pin_mode_min(dir);
441
442 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100443 if (change) {
444 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200445 snd_hda_codec_write_cache(codec, nid, 0,
446 AC_VERB_SET_PIN_WIDGET_CONTROL,
447 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100448
449 /* Also enable the retasking pin's input/output as required
450 * for the requested pin mode. Enum values of 2 or less are
451 * input modes.
452 *
453 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200454 * reduces noise slightly (particularly on input) so we'll
455 * do it. However, having both input and output buffers
456 * enabled simultaneously doesn't seem to be problematic if
457 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100458 */
459 if (val <= 2) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200460 snd_hda_codec_amp_update(codec, nid, 0, HDA_OUTPUT, 0,
461 0x80, 0x80);
462 snd_hda_codec_amp_update(codec, nid, 1, HDA_OUTPUT, 0,
463 0x80, 0x80);
464 snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, 0,
465 0x80, 0x00);
466 snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT, 0,
467 0x80, 0x00);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100468 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200469 snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT, 0,
470 0x80, 0x80);
471 snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT, 0,
472 0x80, 0x80);
473 snd_hda_codec_amp_update(codec, nid, 0, HDA_OUTPUT, 0,
474 0x80, 0x00);
475 snd_hda_codec_amp_update(codec, nid, 1, HDA_OUTPUT, 0,
476 0x80, 0x00);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100477 }
478 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200479 return change;
480}
481
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200483 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100484 .info = alc_pin_mode_info, \
485 .get = alc_pin_mode_get, \
486 .put = alc_pin_mode_put, \
487 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100488
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100489/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
490 * together using a mask with more than one bit set. This control is
491 * currently used only by the ALC260 test model. At this stage they are not
492 * needed for any "production" models.
493 */
494#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200495#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200496
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 Iwai82beb8f2007-08-10 17:09:26 +0200528 snd_hda_codec_write_cache(codec, nid, 0,
529 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100530
531 return change;
532}
533#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
534 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
535 .info = alc_gpio_data_info, \
536 .get = alc_gpio_data_get, \
537 .put = alc_gpio_data_put, \
538 .private_value = nid | (mask<<16) }
539#endif /* CONFIG_SND_DEBUG */
540
Jonathan Woithe92621f12006-02-28 11:47:47 +0100541/* A switch control to allow the enabling of the digital IO pins on the
542 * ALC260. This is incredibly simplistic; the intention of this control is
543 * to provide something in the test model allowing digital outputs to be
544 * identified if present. If models are found which can utilise these
545 * outputs a more complete mixer control can be devised for those models if
546 * necessary.
547 */
548#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200549#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200550
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100553{
554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
555 hda_nid_t nid = kcontrol->private_value & 0xffff;
556 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
557 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558 unsigned int val = snd_hda_codec_read(codec, nid, 0,
559 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100560
561 *valp = (val & mask) != 0;
562 return 0;
563}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
565 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100566{
567 signed int change;
568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
569 hda_nid_t nid = kcontrol->private_value & 0xffff;
570 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
571 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200572 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
573 AC_VERB_GET_DIGI_CONVERT,
574 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100575
576 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200577 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100578 if (val==0)
579 ctrl_data &= ~mask;
580 else
581 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200582 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
583 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100584
585 return change;
586}
587#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
588 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
589 .info = alc_spdif_ctrl_info, \
590 .get = alc_spdif_ctrl_get, \
591 .put = alc_spdif_ctrl_put, \
592 .private_value = nid | (mask<<16) }
593#endif /* CONFIG_SND_DEBUG */
594
Kailang Yangdf694da2005-12-05 19:42:22 +0100595/*
596 * set up from the preset table
597 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598static void setup_preset(struct alc_spec *spec,
599 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100600{
601 int i;
602
603 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
604 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
606 i++)
607 spec->init_verbs[spec->num_init_verbs++] =
608 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100609
610 spec->channel_mode = preset->channel_mode;
611 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200612 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100613
614 spec->multiout.max_channels = spec->channel_mode[0].channels;
615
616 spec->multiout.num_dacs = preset->num_dacs;
617 spec->multiout.dac_nids = preset->dac_nids;
618 spec->multiout.dig_out_nid = preset->dig_out_nid;
619 spec->multiout.hp_nid = preset->hp_nid;
620
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200621 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200622 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200623 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100624 spec->input_mux = preset->input_mux;
625
626 spec->num_adc_nids = preset->num_adc_nids;
627 spec->adc_nids = preset->adc_nids;
628 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100629
630 spec->unsol_event = preset->unsol_event;
631 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100632}
633
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200634/* Enable GPIO mask and set output */
635static struct hda_verb alc_gpio1_init_verbs[] = {
636 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
637 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
638 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
639 { }
640};
641
642static struct hda_verb alc_gpio2_init_verbs[] = {
643 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
644 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
645 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
646 { }
647};
648
Kailang Yangbdd148a2007-05-08 15:19:08 +0200649static struct hda_verb alc_gpio3_init_verbs[] = {
650 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
651 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
652 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
653 { }
654};
655
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200656/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
657 * 31 ~ 16 : Manufacture ID
658 * 15 ~ 8 : SKU ID
659 * 7 ~ 0 : Assembly ID
660 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
661 */
662static void alc_subsystem_id(struct hda_codec *codec,
663 unsigned int porta, unsigned int porte,
664 unsigned int portd)
665{
666 unsigned int ass, tmp;
667
668 ass = codec->subsystem_id;
669 if (!(ass & 1))
670 return;
671
672 /* Override */
673 tmp = (ass & 0x38) >> 3; /* external Amp control */
674 switch (tmp) {
675 case 1:
676 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
677 break;
678 case 3:
679 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
680 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200681 case 7:
682 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
683 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200684 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200685 switch (codec->vendor_id) {
686 case 0x10ec0862:
687 case 0x10ec0660:
688 case 0x10ec0662:
689 case 0x10ec0267:
690 case 0x10ec0268:
691 snd_hda_codec_write(codec, 0x14, 0,
692 AC_VERB_SET_EAPD_BTLENABLE, 2);
693 snd_hda_codec_write(codec, 0x15, 0,
694 AC_VERB_SET_EAPD_BTLENABLE, 2);
695 return;
696 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200697 case 6:
698 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
699 hda_nid_t port = 0;
700 tmp = (ass & 0x1800) >> 11;
701 switch (tmp) {
702 case 0: port = porta; break;
703 case 1: port = porte; break;
704 case 2: port = portd; break;
705 }
706 if (port)
707 snd_hda_codec_write(codec, port, 0,
708 AC_VERB_SET_EAPD_BTLENABLE,
709 2);
710 }
711 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
712 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
713 (tmp == 5 ? 0x3040 : 0x3050));
714 break;
715 }
716}
717
Takashi Iwai41e41f12005-06-08 14:48:49 +0200718/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200719 * Fix-up pin default configurations
720 */
721
722struct alc_pincfg {
723 hda_nid_t nid;
724 u32 val;
725};
726
727static void alc_fix_pincfg(struct hda_codec *codec,
728 const struct snd_pci_quirk *quirk,
729 const struct alc_pincfg **pinfix)
730{
731 const struct alc_pincfg *cfg;
732
733 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
734 if (!quirk)
735 return;
736
737 cfg = pinfix[quirk->value];
738 for (; cfg->nid; cfg++) {
739 int i;
740 u32 val = cfg->val;
741 for (i = 0; i < 4; i++) {
742 snd_hda_codec_write(codec, cfg->nid, 0,
743 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
744 val & 0xff);
745 val >>= 8;
746 }
747 }
748}
749
750/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200751 * ALC880 3-stack model
752 *
753 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200754 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
755 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 */
757
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200758static hda_nid_t alc880_dac_nids[4] = {
759 /* front, rear, clfe, rear_surr */
760 0x02, 0x05, 0x04, 0x03
761};
762
763static hda_nid_t alc880_adc_nids[3] = {
764 /* ADC0-2 */
765 0x07, 0x08, 0x09,
766};
767
768/* The datasheet says the node 0x07 is connected from inputs,
769 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100770 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200772static hda_nid_t alc880_adc_nids_alt[2] = {
773 /* ADC1-2 */
774 0x08, 0x09,
775};
776
777#define ALC880_DIGOUT_NID 0x06
778#define ALC880_DIGIN_NID 0x0a
779
780static struct hda_input_mux alc880_capture_source = {
781 .num_items = 4,
782 .items = {
783 { "Mic", 0x0 },
784 { "Front Mic", 0x3 },
785 { "Line", 0x2 },
786 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200788};
789
790/* channel source setting (2/6 channel selection for 3-stack) */
791/* 2ch mode */
792static struct hda_verb alc880_threestack_ch2_init[] = {
793 /* set line-in to input, mute it */
794 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
795 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
796 /* set mic-in to input vref 80%, mute it */
797 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
798 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 { } /* end */
800};
801
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200802/* 6ch mode */
803static struct hda_verb alc880_threestack_ch6_init[] = {
804 /* set line-in to output, unmute it */
805 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
806 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
807 /* set mic-in to output, unmute it */
808 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
809 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
810 { } /* end */
811};
812
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100813static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200814 { 2, alc880_threestack_ch2_init },
815 { 6, alc880_threestack_ch6_init },
816};
817
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100818static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200819 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100820 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200821 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100822 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200823 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
824 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100825 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
826 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
828 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
833 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
834 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
835 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
836 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200838 {
839 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
840 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100841 .info = alc_ch_mode_info,
842 .get = alc_ch_mode_get,
843 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200844 },
845 { } /* end */
846};
847
848/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100849static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200850 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
851 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
852 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
853 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
854 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
855 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
856 {
857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
858 /* The multiple "Capture Source" controls confuse alsamixer
859 * So call somewhat different..
860 * FIXME: the controls appear in the "playback" view!
861 */
862 /* .name = "Capture Source", */
863 .name = "Input Source",
864 .count = 3,
865 .info = alc_mux_enum_info,
866 .get = alc_mux_enum_get,
867 .put = alc_mux_enum_put,
868 },
869 { } /* end */
870};
871
872/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100873static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200874 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
875 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
876 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
877 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 {
879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
880 /* The multiple "Capture Source" controls confuse alsamixer
881 * So call somewhat different..
882 * FIXME: the controls appear in the "playback" view!
883 */
884 /* .name = "Capture Source", */
885 .name = "Input Source",
886 .count = 2,
887 .info = alc_mux_enum_info,
888 .get = alc_mux_enum_get,
889 .put = alc_mux_enum_put,
890 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 { } /* end */
892};
893
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200894
895
896/*
897 * ALC880 5-stack model
898 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200899 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
900 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200901 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
902 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
903 */
904
905/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100906static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200907 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100908 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 { } /* end */
910};
911
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200912/* channel source setting (6/8 channel selection for 5-stack) */
913/* 6ch mode */
914static struct hda_verb alc880_fivestack_ch6_init[] = {
915 /* set line-in to input, mute it */
916 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
917 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200918 { } /* end */
919};
920
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200921/* 8ch mode */
922static struct hda_verb alc880_fivestack_ch8_init[] = {
923 /* set line-in to output, unmute it */
924 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
925 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
926 { } /* end */
927};
928
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100929static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200930 { 6, alc880_fivestack_ch6_init },
931 { 8, alc880_fivestack_ch8_init },
932};
933
934
935/*
936 * ALC880 6-stack model
937 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200938 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
939 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200940 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
941 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
942 */
943
944static hda_nid_t alc880_6st_dac_nids[4] = {
945 /* front, rear, clfe, rear_surr */
946 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200947};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200948
949static struct hda_input_mux alc880_6stack_capture_source = {
950 .num_items = 4,
951 .items = {
952 { "Mic", 0x0 },
953 { "Front Mic", 0x1 },
954 { "Line", 0x2 },
955 { "CD", 0x4 },
956 },
957};
958
959/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100960static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200961 { 8, NULL },
962};
963
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100964static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200965 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100966 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200967 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100968 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200969 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
970 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100971 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
972 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200973 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100974 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200975 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
976 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
977 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
978 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
981 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
982 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
983 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
984 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200985 {
986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
987 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100988 .info = alc_ch_mode_info,
989 .get = alc_ch_mode_get,
990 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200991 },
992 { } /* end */
993};
994
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200995
996/*
997 * ALC880 W810 model
998 *
999 * W810 has rear IO for:
1000 * Front (DAC 02)
1001 * Surround (DAC 03)
1002 * Center/LFE (DAC 04)
1003 * Digital out (06)
1004 *
1005 * The system also has a pair of internal speakers, and a headphone jack.
1006 * These are both connected to Line2 on the codec, hence to DAC 02.
1007 *
1008 * There is a variable resistor to control the speaker or headphone
1009 * volume. This is a hardware-only device without a software API.
1010 *
1011 * Plugging headphones in will disable the internal speakers. This is
1012 * implemented in hardware, not via the driver using jack sense. In
1013 * a similar fashion, plugging into the rear socket marked "front" will
1014 * disable both the speakers and headphones.
1015 *
1016 * For input, there's a microphone jack, and an "audio in" jack.
1017 * These may not do anything useful with this driver yet, because I
1018 * haven't setup any initialization verbs for these yet...
1019 */
1020
1021static hda_nid_t alc880_w810_dac_nids[3] = {
1022 /* front, rear/surround, clfe */
1023 0x02, 0x03, 0x04
1024};
1025
1026/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001027static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001028 { 6, NULL }
1029};
1030
1031/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001032static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001033 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001034 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001035 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001036 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001037 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1038 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001039 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1040 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1042 { } /* end */
1043};
1044
1045
1046/*
1047 * Z710V model
1048 *
1049 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001050 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1051 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001052 */
1053
1054static hda_nid_t alc880_z71v_dac_nids[1] = {
1055 0x02
1056};
1057#define ALC880_Z71V_HP_DAC 0x03
1058
1059/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001060static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001061 { 2, NULL }
1062};
1063
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001064static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001065 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001066 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001067 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001068 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001069 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1070 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1073 { } /* end */
1074};
1075
1076
1077/* FIXME! */
1078/*
1079 * ALC880 F1734 model
1080 *
1081 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1082 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1083 */
1084
1085static hda_nid_t alc880_f1734_dac_nids[1] = {
1086 0x03
1087};
1088#define ALC880_F1734_HP_DAC 0x02
1089
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001090static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001091 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001092 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001093 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001094 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001099 { } /* end */
1100};
1101
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001102
1103/* FIXME! */
1104/*
1105 * ALC880 ASUS model
1106 *
1107 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1108 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1109 * Mic = 0x18, Line = 0x1a
1110 */
1111
1112#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1113#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1114
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001115static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001117 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001118 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001119 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001120 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001122 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1123 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001124 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1125 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1126 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1127 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001130 {
1131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1132 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001133 .info = alc_ch_mode_info,
1134 .get = alc_ch_mode_get,
1135 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001136 },
1137 { } /* end */
1138};
1139
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001140/* FIXME! */
1141/*
1142 * ALC880 ASUS W1V model
1143 *
1144 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1145 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1146 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1147 */
1148
1149/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001150static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001151 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1152 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001153 { } /* end */
1154};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001156/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001157static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001158 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1159 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1160 { } /* end */
1161};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001162
Kailang Yangdf694da2005-12-05 19:42:22 +01001163/* TCL S700 */
1164static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1166 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1167 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1168 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1169 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1172 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1174 {
1175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1176 /* The multiple "Capture Source" controls confuse alsamixer
1177 * So call somewhat different..
1178 * FIXME: the controls appear in the "playback" view!
1179 */
1180 /* .name = "Capture Source", */
1181 .name = "Input Source",
1182 .count = 1,
1183 .info = alc_mux_enum_info,
1184 .get = alc_mux_enum_get,
1185 .put = alc_mux_enum_put,
1186 },
1187 { } /* end */
1188};
1189
Kailang Yangccc656c2006-10-17 12:32:26 +02001190/* Uniwill */
1191static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1192 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1193 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1194 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1195 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1196 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1197 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1198 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1199 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1206 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1207 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1208 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1209 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1210 {
1211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1212 .name = "Channel Mode",
1213 .info = alc_ch_mode_info,
1214 .get = alc_ch_mode_get,
1215 .put = alc_ch_mode_put,
1216 },
1217 { } /* end */
1218};
1219
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001220static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1221 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1222 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1223 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1224 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1225 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1226 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1227 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1228 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1229 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1230 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1231 { } /* end */
1232};
1233
Kailang Yangccc656c2006-10-17 12:32:26 +02001234static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1235 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1236 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1237 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1238 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1240 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1241 { } /* end */
1242};
1243
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001245 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 */
1247static int alc_build_controls(struct hda_codec *codec)
1248{
1249 struct alc_spec *spec = codec->spec;
1250 int err;
1251 int i;
1252
1253 for (i = 0; i < spec->num_mixers; i++) {
1254 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1255 if (err < 0)
1256 return err;
1257 }
1258
1259 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001260 err = snd_hda_create_spdif_out_ctls(codec,
1261 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262 if (err < 0)
1263 return err;
1264 }
1265 if (spec->dig_in_nid) {
1266 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1267 if (err < 0)
1268 return err;
1269 }
1270 return 0;
1271}
1272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001273
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274/*
1275 * initialize the codec volumes, etc
1276 */
1277
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001278/*
1279 * generic initialization of ADC, input mixers and output mixers
1280 */
1281static struct hda_verb alc880_volume_init_verbs[] = {
1282 /*
1283 * Unmute ADC0-2 and set the default input to mic-in
1284 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001285 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001287 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001288 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001289 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1293 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001294 * Note: PASD motherboards uses the Line In 2 as the input for front
1295 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001297 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001304 /*
1305 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001306 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001307 /* set vol=0 to output mixers */
1308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1312 /* set up input amps for analog loopback */
1313 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322
1323 { }
1324};
1325
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001326/*
1327 * 3-stack pin configuration:
1328 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1329 */
1330static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1331 /*
1332 * preset connection lists of input pins
1333 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1334 */
1335 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1336 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1337 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1338
1339 /*
1340 * Set pin mode and muting
1341 */
1342 /* set front pin widgets 0x14 for output */
1343 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1344 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1345 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1346 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1348 /* Mic2 (as headphone out) for HP output */
1349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 /* Line In pin widget for input */
1352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1354 /* Line2 (as front mic) pin widget for input and vref at 80% */
1355 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1356 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1357 /* CD pin widget for input */
1358 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1359
1360 { }
1361};
1362
1363/*
1364 * 5-stack pin configuration:
1365 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1366 * line-in/side = 0x1a, f-mic = 0x1b
1367 */
1368static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1369 /*
1370 * preset connection lists of input pins
1371 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1372 */
1373 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1374 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1375
1376 /*
1377 * Set pin mode and muting
1378 */
1379 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001380 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1382 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1383 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001384 /* unmute pins for output (no gain on this amp) */
1385 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1387 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1388 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1389
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001392 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1393 /* Mic2 (as headphone out) for HP output */
1394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001396 /* Line In pin widget for input */
1397 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1398 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1399 /* Line2 (as front mic) pin widget for input and vref at 80% */
1400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1401 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1402 /* CD pin widget for input */
1403 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404
1405 { }
1406};
1407
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001408/*
1409 * W810 pin configuration:
1410 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1411 */
1412static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 /* hphone/speaker input selector: front DAC */
1414 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1415
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1417 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1420 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1421 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1422
1423 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001424 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425
Linus Torvalds1da177e2005-04-16 15:20:36 -07001426 { }
1427};
1428
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001429/*
1430 * Z71V pin configuration:
1431 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1432 */
1433static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001435 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001436 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001437 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001438
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 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001443
1444 { }
1445};
1446
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001447/*
1448 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001449 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1450 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001451 */
1452static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1453 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1454
Takashi Iwai16ded522005-06-10 19:58:24 +02001455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001456 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001457 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001458 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001459 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001460 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001461 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001462 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1463
Takashi Iwai16ded522005-06-10 19:58:24 +02001464 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001465 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001466 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001468 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001469 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001471 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001472 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1473
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001474 { }
1475};
Takashi Iwai16ded522005-06-10 19:58:24 +02001476
Kailang Yangccc656c2006-10-17 12:32:26 +02001477/*
1478 * Uniwill pin configuration:
1479 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1480 * line = 0x1a
1481 */
1482static struct hda_verb alc880_uniwill_init_verbs[] = {
1483 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1484
1485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1488 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1490 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1492 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1499
1500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1506 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1507 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1508 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1509
1510 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1511 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1512
1513 { }
1514};
1515
1516/*
1517* Uniwill P53
1518* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1519 */
1520static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1521 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1522
1523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1525 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1526 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1527 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1528 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1534 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1535
1536 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1538 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1539 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1542
1543 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1544 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1545
1546 { }
1547};
1548
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001549static struct hda_verb alc880_beep_init_verbs[] = {
1550 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1551 { }
1552};
1553
Kailang Yangccc656c2006-10-17 12:32:26 +02001554/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001555static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001556{
1557 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001558 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001559
1560 present = snd_hda_codec_read(codec, 0x14, 0,
1561 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001562 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001563 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001564 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001565 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001566 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001567 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001568 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001569 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001570 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001571}
1572
1573/* auto-toggle front mic */
1574static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1575{
1576 unsigned int present;
1577 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001578
1579 present = snd_hda_codec_read(codec, 0x18, 0,
1580 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001581 bits = present ? 0x80 : 0;
1582 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1583 0x80, bits);
1584 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1585 0x80, bits);
1586}
1587
1588static void alc880_uniwill_automute(struct hda_codec *codec)
1589{
1590 alc880_uniwill_hp_automute(codec);
1591 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001592}
1593
1594static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1595 unsigned int res)
1596{
1597 /* Looks like the unsol event is incompatible with the standard
1598 * definition. 4bit tag is placed at 28 bit!
1599 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001600 switch (res >> 28) {
1601 case ALC880_HP_EVENT:
1602 alc880_uniwill_hp_automute(codec);
1603 break;
1604 case ALC880_MIC_EVENT:
1605 alc880_uniwill_mic_automute(codec);
1606 break;
1607 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001608}
1609
1610static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1611{
1612 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001613 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001614
1615 present = snd_hda_codec_read(codec, 0x14, 0,
1616 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001617 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001618 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001619 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001620 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001621 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001622}
1623
1624static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1625{
1626 unsigned int present;
1627
1628 present = snd_hda_codec_read(codec, 0x21, 0,
1629 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1630
1631 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1632 0x7f, present);
1633 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1634 0x7f, present);
1635
1636 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1637 0x7f, present);
1638 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1639 0x7f, present);
1640
1641}
1642static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1643 unsigned int res)
1644{
1645 /* Looks like the unsol event is incompatible with the standard
1646 * definition. 4bit tag is placed at 28 bit!
1647 */
1648 if ((res >> 28) == ALC880_HP_EVENT)
1649 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001650 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001651 alc880_uniwill_p53_dcvol_automute(codec);
1652}
1653
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001654/* FIXME! */
1655/*
1656 * F1734 pin configuration:
1657 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1658 */
1659static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1660 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1661 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1662 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1663 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1664
1665 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1666 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1669
1670 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1671 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1672 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1673 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1674 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1675 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1676 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1677 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1678 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001679
1680 { }
1681};
1682
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001683/* FIXME! */
1684/*
1685 * ASUS pin configuration:
1686 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1687 */
1688static struct hda_verb alc880_pin_asus_init_verbs[] = {
1689 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1690 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1691 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1692 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1693
1694 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1695 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1697 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1698 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1700 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1702
1703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1705 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1709 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1711 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1712
1713 { }
1714};
1715
1716/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001717#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1718#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001719
Kailang Yangdf694da2005-12-05 19:42:22 +01001720/* Clevo m520g init */
1721static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1722 /* headphone output */
1723 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1724 /* line-out */
1725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1726 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1727 /* Line-in */
1728 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1729 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1730 /* CD */
1731 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1732 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733 /* Mic1 (rear panel) */
1734 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1735 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1736 /* Mic2 (front panel) */
1737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1738 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1739 /* headphone */
1740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1742 /* change to EAPD mode */
1743 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1744 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1745
1746 { }
1747};
1748
1749static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001750 /* change to EAPD mode */
1751 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1752 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1753
Kailang Yangdf694da2005-12-05 19:42:22 +01001754 /* Headphone output */
1755 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1756 /* Front output*/
1757 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1758 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1759
1760 /* Line In pin widget for input */
1761 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1762 /* CD pin widget for input */
1763 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1764 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1766
1767 /* change to EAPD mode */
1768 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1769 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1770
1771 { }
1772};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001773
1774/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001775 * LG m1 express dual
1776 *
1777 * Pin assignment:
1778 * Rear Line-In/Out (blue): 0x14
1779 * Build-in Mic-In: 0x15
1780 * Speaker-out: 0x17
1781 * HP-Out (green): 0x1b
1782 * Mic-In/Out (red): 0x19
1783 * SPDIF-Out: 0x1e
1784 */
1785
1786/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1787static hda_nid_t alc880_lg_dac_nids[3] = {
1788 0x05, 0x02, 0x03
1789};
1790
1791/* seems analog CD is not working */
1792static struct hda_input_mux alc880_lg_capture_source = {
1793 .num_items = 3,
1794 .items = {
1795 { "Mic", 0x1 },
1796 { "Line", 0x5 },
1797 { "Internal Mic", 0x6 },
1798 },
1799};
1800
1801/* 2,4,6 channel modes */
1802static struct hda_verb alc880_lg_ch2_init[] = {
1803 /* set line-in and mic-in to input */
1804 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1805 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1806 { }
1807};
1808
1809static struct hda_verb alc880_lg_ch4_init[] = {
1810 /* set line-in to out and mic-in to input */
1811 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1812 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1813 { }
1814};
1815
1816static struct hda_verb alc880_lg_ch6_init[] = {
1817 /* set line-in and mic-in to output */
1818 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1819 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1820 { }
1821};
1822
1823static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1824 { 2, alc880_lg_ch2_init },
1825 { 4, alc880_lg_ch4_init },
1826 { 6, alc880_lg_ch6_init },
1827};
1828
1829static struct snd_kcontrol_new alc880_lg_mixer[] = {
1830 /* FIXME: it's not really "master" but front channels */
1831 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1832 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1834 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1835 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1836 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1837 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1838 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1841 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1842 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1843 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1844 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1845 {
1846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1847 .name = "Channel Mode",
1848 .info = alc_ch_mode_info,
1849 .get = alc_ch_mode_get,
1850 .put = alc_ch_mode_put,
1851 },
1852 { } /* end */
1853};
1854
1855static struct hda_verb alc880_lg_init_verbs[] = {
1856 /* set capture source to mic-in */
1857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1860 /* mute all amp mixer inputs */
1861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1864 /* line-in to input */
1865 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1866 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 /* built-in mic */
1868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1870 /* speaker-out */
1871 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1872 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1873 /* mic-in to input */
1874 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1875 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1876 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1877 /* HP-out */
1878 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1879 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1880 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1881 /* jack sense */
1882 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1883 { }
1884};
1885
1886/* toggle speaker-output according to the hp-jack state */
1887static void alc880_lg_automute(struct hda_codec *codec)
1888{
1889 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001890 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001891
1892 present = snd_hda_codec_read(codec, 0x1b, 0,
1893 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001894 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001895 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001896 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001897 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001898 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001899}
1900
1901static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1902{
1903 /* Looks like the unsol event is incompatible with the standard
1904 * definition. 4bit tag is placed at 28 bit!
1905 */
1906 if ((res >> 28) == 0x01)
1907 alc880_lg_automute(codec);
1908}
1909
1910/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001911 * LG LW20
1912 *
1913 * Pin assignment:
1914 * Speaker-out: 0x14
1915 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001916 * Built-in Mic-In: 0x19
1917 * Line-In: 0x1b
1918 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01001919 * SPDIF-Out: 0x1e
1920 */
1921
Takashi Iwaid6815182006-03-23 16:06:23 +01001922static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001923 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01001924 .items = {
1925 { "Mic", 0x0 },
1926 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001927 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001928 },
1929};
1930
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001931#define alc880_lg_lw_modes alc880_threestack_modes
1932
Takashi Iwaid6815182006-03-23 16:06:23 +01001933static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1936 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1937 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1940 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1941 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1942 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1943 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1946 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1947 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001948 {
1949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1950 .name = "Channel Mode",
1951 .info = alc_ch_mode_info,
1952 .get = alc_ch_mode_get,
1953 .put = alc_ch_mode_put,
1954 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001955 { } /* end */
1956};
1957
1958static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001959 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1960 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1961 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1962
Takashi Iwaid6815182006-03-23 16:06:23 +01001963 /* set capture source to mic-in */
1964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1965 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1966 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1967 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1968 /* speaker-out */
1969 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001972 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1973 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1974 /* mic-in to input */
1975 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1977 /* built-in mic */
1978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1979 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1980 /* jack sense */
1981 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1982 { }
1983};
1984
1985/* toggle speaker-output according to the hp-jack state */
1986static void alc880_lg_lw_automute(struct hda_codec *codec)
1987{
1988 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001989 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001990
1991 present = snd_hda_codec_read(codec, 0x1b, 0,
1992 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001993 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001994 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001995 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001996 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001997 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001998}
1999
2000static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2001{
2002 /* Looks like the unsol event is incompatible with the standard
2003 * definition. 4bit tag is placed at 28 bit!
2004 */
2005 if ((res >> 28) == 0x01)
2006 alc880_lg_lw_automute(codec);
2007}
2008
2009/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002010 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002011 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002012
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013static int alc_init(struct hda_codec *codec)
2014{
2015 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002016 unsigned int i;
2017
2018 for (i = 0; i < spec->num_init_verbs; i++)
2019 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002020
2021 if (spec->init_hook)
2022 spec->init_hook(codec);
2023
Linus Torvalds1da177e2005-04-16 15:20:36 -07002024 return 0;
2025}
2026
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002027static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2028{
2029 struct alc_spec *spec = codec->spec;
2030
2031 if (spec->unsol_event)
2032 spec->unsol_event(codec, res);
2033}
2034
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035/*
2036 * Analog playback callbacks
2037 */
2038static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2039 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002040 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002041{
2042 struct alc_spec *spec = codec->spec;
2043 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2044}
2045
2046static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2047 struct hda_codec *codec,
2048 unsigned int stream_tag,
2049 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002050 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051{
2052 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002053 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2054 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055}
2056
2057static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2058 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002059 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060{
2061 struct alc_spec *spec = codec->spec;
2062 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2063}
2064
2065/*
2066 * Digital out
2067 */
2068static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2069 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002070 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071{
2072 struct alc_spec *spec = codec->spec;
2073 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2074}
2075
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002076static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2077 struct hda_codec *codec,
2078 unsigned int stream_tag,
2079 unsigned int format,
2080 struct snd_pcm_substream *substream)
2081{
2082 struct alc_spec *spec = codec->spec;
2083 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2084 stream_tag, format, substream);
2085}
2086
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2088 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002089 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002090{
2091 struct alc_spec *spec = codec->spec;
2092 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2093}
2094
2095/*
2096 * Analog capture
2097 */
2098static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2099 struct hda_codec *codec,
2100 unsigned int stream_tag,
2101 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002102 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103{
2104 struct alc_spec *spec = codec->spec;
2105
2106 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2107 stream_tag, 0, format);
2108 return 0;
2109}
2110
2111static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2112 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002113 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114{
2115 struct alc_spec *spec = codec->spec;
2116
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002117 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2118 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119 return 0;
2120}
2121
2122
2123/*
2124 */
2125static struct hda_pcm_stream alc880_pcm_analog_playback = {
2126 .substreams = 1,
2127 .channels_min = 2,
2128 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002129 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130 .ops = {
2131 .open = alc880_playback_pcm_open,
2132 .prepare = alc880_playback_pcm_prepare,
2133 .cleanup = alc880_playback_pcm_cleanup
2134 },
2135};
2136
2137static struct hda_pcm_stream alc880_pcm_analog_capture = {
2138 .substreams = 2,
2139 .channels_min = 2,
2140 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002141 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142 .ops = {
2143 .prepare = alc880_capture_pcm_prepare,
2144 .cleanup = alc880_capture_pcm_cleanup
2145 },
2146};
2147
2148static struct hda_pcm_stream alc880_pcm_digital_playback = {
2149 .substreams = 1,
2150 .channels_min = 2,
2151 .channels_max = 2,
2152 /* NID is set in alc_build_pcms */
2153 .ops = {
2154 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002155 .close = alc880_dig_playback_pcm_close,
2156 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157 },
2158};
2159
2160static struct hda_pcm_stream alc880_pcm_digital_capture = {
2161 .substreams = 1,
2162 .channels_min = 2,
2163 .channels_max = 2,
2164 /* NID is set in alc_build_pcms */
2165};
2166
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002167/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2168static struct hda_pcm_stream alc_pcm_null_playback = {
2169 .substreams = 0,
2170 .channels_min = 0,
2171 .channels_max = 0,
2172};
2173
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174static int alc_build_pcms(struct hda_codec *codec)
2175{
2176 struct alc_spec *spec = codec->spec;
2177 struct hda_pcm *info = spec->pcm_rec;
2178 int i;
2179
2180 codec->num_pcms = 1;
2181 codec->pcm_info = info;
2182
2183 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002184 if (spec->stream_analog_playback) {
2185 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2186 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2187 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2188 }
2189 if (spec->stream_analog_capture) {
2190 snd_assert(spec->adc_nids, return -EINVAL);
2191 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2192 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2193 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194
Takashi Iwai4a471b72005-12-07 13:56:29 +01002195 if (spec->channel_mode) {
2196 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2197 for (i = 0; i < spec->num_channel_mode; i++) {
2198 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2199 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2200 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 }
2202 }
2203
Takashi Iwaie08a0072006-09-07 17:52:14 +02002204 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002206 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002207 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002209 if (spec->multiout.dig_out_nid &&
2210 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2212 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2213 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002214 if (spec->dig_in_nid &&
2215 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2217 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2218 }
2219 }
2220
Takashi Iwaie08a0072006-09-07 17:52:14 +02002221 /* If the use of more than one ADC is requested for the current
2222 * model, configure a second analog capture-only PCM.
2223 */
2224 /* Additional Analaog capture for index #2 */
2225 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2226 spec->adc_nids) {
2227 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002228 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002229 info->name = spec->stream_name_analog;
2230 /* No playback stream for second PCM */
2231 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2232 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2233 if (spec->stream_analog_capture) {
2234 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2235 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2236 }
2237 }
2238
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 return 0;
2240}
2241
2242static void alc_free(struct hda_codec *codec)
2243{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002244 struct alc_spec *spec = codec->spec;
2245 unsigned int i;
2246
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002247 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002248 return;
2249
2250 if (spec->kctl_alloc) {
2251 for (i = 0; i < spec->num_kctl_used; i++)
2252 kfree(spec->kctl_alloc[i].name);
2253 kfree(spec->kctl_alloc);
2254 }
2255 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256}
2257
2258/*
2259 */
2260static struct hda_codec_ops alc_patch_ops = {
2261 .build_controls = alc_build_controls,
2262 .build_pcms = alc_build_pcms,
2263 .init = alc_init,
2264 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002265 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266};
2267
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002268
2269/*
2270 * Test configuration for debugging
2271 *
2272 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2273 * enum controls.
2274 */
2275#ifdef CONFIG_SND_DEBUG
2276static hda_nid_t alc880_test_dac_nids[4] = {
2277 0x02, 0x03, 0x04, 0x05
2278};
2279
2280static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002281 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002282 .items = {
2283 { "In-1", 0x0 },
2284 { "In-2", 0x1 },
2285 { "In-3", 0x2 },
2286 { "In-4", 0x3 },
2287 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002288 { "Front", 0x5 },
2289 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002290 },
2291};
2292
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002293static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002294 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002295 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002296 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002297 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002298};
2299
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002300static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2301 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002302{
2303 static char *texts[] = {
2304 "N/A", "Line Out", "HP Out",
2305 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2306 };
2307 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2308 uinfo->count = 1;
2309 uinfo->value.enumerated.items = 8;
2310 if (uinfo->value.enumerated.item >= 8)
2311 uinfo->value.enumerated.item = 7;
2312 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2313 return 0;
2314}
2315
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002316static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2317 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002318{
2319 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2320 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2321 unsigned int pin_ctl, item = 0;
2322
2323 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2324 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2325 if (pin_ctl & AC_PINCTL_OUT_EN) {
2326 if (pin_ctl & AC_PINCTL_HP_EN)
2327 item = 2;
2328 else
2329 item = 1;
2330 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2331 switch (pin_ctl & AC_PINCTL_VREFEN) {
2332 case AC_PINCTL_VREF_HIZ: item = 3; break;
2333 case AC_PINCTL_VREF_50: item = 4; break;
2334 case AC_PINCTL_VREF_GRD: item = 5; break;
2335 case AC_PINCTL_VREF_80: item = 6; break;
2336 case AC_PINCTL_VREF_100: item = 7; break;
2337 }
2338 }
2339 ucontrol->value.enumerated.item[0] = item;
2340 return 0;
2341}
2342
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002343static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2344 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002345{
2346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2347 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2348 static unsigned int ctls[] = {
2349 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2350 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2351 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2352 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2353 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2354 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2355 };
2356 unsigned int old_ctl, new_ctl;
2357
2358 old_ctl = snd_hda_codec_read(codec, nid, 0,
2359 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2360 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2361 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002362 int val;
2363 snd_hda_codec_write_cache(codec, nid, 0,
2364 AC_VERB_SET_PIN_WIDGET_CONTROL,
2365 new_ctl);
2366 val = ucontrol->value.enumerated.item[0] >= 3 ? 0x80 : 0x00;
2367 snd_hda_codec_amp_update(codec, nid, 0, HDA_OUTPUT, 0,
2368 0x80, val);
2369 snd_hda_codec_amp_update(codec, nid, 1, HDA_OUTPUT, 0,
2370 0x80, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002371 return 1;
2372 }
2373 return 0;
2374}
2375
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002376static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2377 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002378{
2379 static char *texts[] = {
2380 "Front", "Surround", "CLFE", "Side"
2381 };
2382 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2383 uinfo->count = 1;
2384 uinfo->value.enumerated.items = 4;
2385 if (uinfo->value.enumerated.item >= 4)
2386 uinfo->value.enumerated.item = 3;
2387 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2388 return 0;
2389}
2390
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002391static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2392 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002393{
2394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2395 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2396 unsigned int sel;
2397
2398 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2399 ucontrol->value.enumerated.item[0] = sel & 3;
2400 return 0;
2401}
2402
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002403static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2404 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002405{
2406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2407 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2408 unsigned int sel;
2409
2410 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2411 if (ucontrol->value.enumerated.item[0] != sel) {
2412 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002413 snd_hda_codec_write_cache(codec, nid, 0,
2414 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002415 return 1;
2416 }
2417 return 0;
2418}
2419
2420#define PIN_CTL_TEST(xname,nid) { \
2421 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2422 .name = xname, \
2423 .info = alc_test_pin_ctl_info, \
2424 .get = alc_test_pin_ctl_get, \
2425 .put = alc_test_pin_ctl_put, \
2426 .private_value = nid \
2427 }
2428
2429#define PIN_SRC_TEST(xname,nid) { \
2430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2431 .name = xname, \
2432 .info = alc_test_pin_src_info, \
2433 .get = alc_test_pin_src_get, \
2434 .put = alc_test_pin_src_put, \
2435 .private_value = nid \
2436 }
2437
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002438static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002439 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2440 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2441 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2442 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002443 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2444 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2445 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2446 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002447 PIN_CTL_TEST("Front Pin Mode", 0x14),
2448 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2449 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2450 PIN_CTL_TEST("Side Pin Mode", 0x17),
2451 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2452 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2453 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2454 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2455 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2456 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2457 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2458 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2459 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2460 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2461 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2462 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2463 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2464 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2465 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2466 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2467 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2468 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002469 {
2470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2471 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002472 .info = alc_ch_mode_info,
2473 .get = alc_ch_mode_get,
2474 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002475 },
2476 { } /* end */
2477};
2478
2479static struct hda_verb alc880_test_init_verbs[] = {
2480 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2487 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2488 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002489 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002494 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2497 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2498 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002499 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2502 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2503 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002504 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2506 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2508 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2509 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002510 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2514 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002515 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002517 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002519 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002521 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002522 /* Analog input/passthru */
2523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002528 { }
2529};
2530#endif
2531
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532/*
2533 */
2534
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002535static const char *alc880_models[ALC880_MODEL_LAST] = {
2536 [ALC880_3ST] = "3stack",
2537 [ALC880_TCL_S700] = "tcl",
2538 [ALC880_3ST_DIG] = "3stack-digout",
2539 [ALC880_CLEVO] = "clevo",
2540 [ALC880_5ST] = "5stack",
2541 [ALC880_5ST_DIG] = "5stack-digout",
2542 [ALC880_W810] = "w810",
2543 [ALC880_Z71V] = "z71v",
2544 [ALC880_6ST] = "6stack",
2545 [ALC880_6ST_DIG] = "6stack-digout",
2546 [ALC880_ASUS] = "asus",
2547 [ALC880_ASUS_W1V] = "asus-w1v",
2548 [ALC880_ASUS_DIG] = "asus-dig",
2549 [ALC880_ASUS_DIG2] = "asus-dig2",
2550 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002551 [ALC880_UNIWILL_P53] = "uniwill-p53",
2552 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002553 [ALC880_F1734] = "F1734",
2554 [ALC880_LG] = "lg",
2555 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002556#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002557 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002558#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002559 [ALC880_AUTO] = "auto",
2560};
2561
2562static struct snd_pci_quirk alc880_cfg_tbl[] = {
2563 /* Broken BIOS configuration */
2564 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2565 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2566
2567 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2568 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002569 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002570 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2571 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2572 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2573 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2574 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2575 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2576
2577 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2578 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2579
2580 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2581 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2582 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2583 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2584 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2585 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2586 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2587 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2588 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2589 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002590 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002591 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2592 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2593 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2594 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2595
2596 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2597 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2598 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2599 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2600 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2601 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2602 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2603 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2604 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2605 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2606 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2607 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2608 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2609 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2610 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2611 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2612 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2613 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2614
2615 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2616 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2617 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2618 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2619
2620 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2621 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2622 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002623 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002624
2625 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2626 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2627 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2628 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2629
2630 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2631 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2632 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2633 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2634 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2635 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2636 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2637 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2638 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2639 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2640 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002641
Linus Torvalds1da177e2005-04-16 15:20:36 -07002642 {}
2643};
2644
Takashi Iwai16ded522005-06-10 19:58:24 +02002645/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002646 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002647 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002648static struct alc_config_preset alc880_presets[] = {
2649 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002651 .init_verbs = { alc880_volume_init_verbs,
2652 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002653 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002654 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002655 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2656 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002657 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 .input_mux = &alc880_capture_source,
2659 },
2660 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002662 .init_verbs = { alc880_volume_init_verbs,
2663 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002664 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002665 .dac_nids = alc880_dac_nids,
2666 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2668 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002669 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 .input_mux = &alc880_capture_source,
2671 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002672 [ALC880_TCL_S700] = {
2673 .mixers = { alc880_tcl_s700_mixer },
2674 .init_verbs = { alc880_volume_init_verbs,
2675 alc880_pin_tcl_S700_init_verbs,
2676 alc880_gpio2_init_verbs },
2677 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2678 .dac_nids = alc880_dac_nids,
2679 .hp_nid = 0x03,
2680 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2681 .channel_mode = alc880_2_jack_modes,
2682 .input_mux = &alc880_capture_source,
2683 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002685 .mixers = { alc880_three_stack_mixer,
2686 alc880_five_stack_mixer},
2687 .init_verbs = { alc880_volume_init_verbs,
2688 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002689 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2690 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002691 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2692 .channel_mode = alc880_fivestack_modes,
2693 .input_mux = &alc880_capture_source,
2694 },
2695 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002696 .mixers = { alc880_three_stack_mixer,
2697 alc880_five_stack_mixer },
2698 .init_verbs = { alc880_volume_init_verbs,
2699 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002700 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2701 .dac_nids = alc880_dac_nids,
2702 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002703 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2704 .channel_mode = alc880_fivestack_modes,
2705 .input_mux = &alc880_capture_source,
2706 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002707 [ALC880_6ST] = {
2708 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002709 .init_verbs = { alc880_volume_init_verbs,
2710 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002711 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2712 .dac_nids = alc880_6st_dac_nids,
2713 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2714 .channel_mode = alc880_sixstack_modes,
2715 .input_mux = &alc880_6stack_capture_source,
2716 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002717 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002719 .init_verbs = { alc880_volume_init_verbs,
2720 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002721 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2722 .dac_nids = alc880_6st_dac_nids,
2723 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002724 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2725 .channel_mode = alc880_sixstack_modes,
2726 .input_mux = &alc880_6stack_capture_source,
2727 },
2728 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002729 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002730 .init_verbs = { alc880_volume_init_verbs,
2731 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002732 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2734 .dac_nids = alc880_w810_dac_nids,
2735 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002736 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2737 .channel_mode = alc880_w810_modes,
2738 .input_mux = &alc880_capture_source,
2739 },
2740 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002741 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002742 .init_verbs = { alc880_volume_init_verbs,
2743 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002744 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2745 .dac_nids = alc880_z71v_dac_nids,
2746 .dig_out_nid = ALC880_DIGOUT_NID,
2747 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002748 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2749 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002750 .input_mux = &alc880_capture_source,
2751 },
2752 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002753 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002754 .init_verbs = { alc880_volume_init_verbs,
2755 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002756 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2757 .dac_nids = alc880_f1734_dac_nids,
2758 .hp_nid = 0x02,
2759 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2760 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002761 .input_mux = &alc880_capture_source,
2762 },
2763 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002764 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002765 .init_verbs = { alc880_volume_init_verbs,
2766 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002767 alc880_gpio1_init_verbs },
2768 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2769 .dac_nids = alc880_asus_dac_nids,
2770 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2771 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002772 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002773 .input_mux = &alc880_capture_source,
2774 },
2775 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002777 .init_verbs = { alc880_volume_init_verbs,
2778 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002779 alc880_gpio1_init_verbs },
2780 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2781 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002782 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2784 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002785 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002786 .input_mux = &alc880_capture_source,
2787 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002788 [ALC880_ASUS_DIG2] = {
2789 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002790 .init_verbs = { alc880_volume_init_verbs,
2791 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002792 alc880_gpio2_init_verbs }, /* use GPIO2 */
2793 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2794 .dac_nids = alc880_asus_dac_nids,
2795 .dig_out_nid = ALC880_DIGOUT_NID,
2796 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2797 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002798 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002799 .input_mux = &alc880_capture_source,
2800 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002803 .init_verbs = { alc880_volume_init_verbs,
2804 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002805 alc880_gpio1_init_verbs },
2806 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2807 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002808 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002809 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2810 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002811 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002812 .input_mux = &alc880_capture_source,
2813 },
2814 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002815 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002816 .init_verbs = { alc880_volume_init_verbs,
2817 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002818 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2819 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002820 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002821 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2822 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002823 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002824 .input_mux = &alc880_capture_source,
2825 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002826 [ALC880_UNIWILL] = {
2827 .mixers = { alc880_uniwill_mixer },
2828 .init_verbs = { alc880_volume_init_verbs,
2829 alc880_uniwill_init_verbs },
2830 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2831 .dac_nids = alc880_asus_dac_nids,
2832 .dig_out_nid = ALC880_DIGOUT_NID,
2833 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2834 .channel_mode = alc880_threestack_modes,
2835 .need_dac_fix = 1,
2836 .input_mux = &alc880_capture_source,
2837 .unsol_event = alc880_uniwill_unsol_event,
2838 .init_hook = alc880_uniwill_automute,
2839 },
2840 [ALC880_UNIWILL_P53] = {
2841 .mixers = { alc880_uniwill_p53_mixer },
2842 .init_verbs = { alc880_volume_init_verbs,
2843 alc880_uniwill_p53_init_verbs },
2844 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2845 .dac_nids = alc880_asus_dac_nids,
2846 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002847 .channel_mode = alc880_threestack_modes,
2848 .input_mux = &alc880_capture_source,
2849 .unsol_event = alc880_uniwill_p53_unsol_event,
2850 .init_hook = alc880_uniwill_p53_hp_automute,
2851 },
2852 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002853 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002854 alc880_pcbeep_mixer, },
2855 .init_verbs = { alc880_volume_init_verbs,
2856 alc880_uniwill_p53_init_verbs,
2857 alc880_beep_init_verbs },
2858 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2859 .dac_nids = alc880_dac_nids,
2860 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2861 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002862 .input_mux = &alc880_capture_source,
2863 .unsol_event = alc880_uniwill_p53_unsol_event,
2864 .init_hook = alc880_uniwill_p53_hp_automute,
2865 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002866 [ALC880_CLEVO] = {
2867 .mixers = { alc880_three_stack_mixer },
2868 .init_verbs = { alc880_volume_init_verbs,
2869 alc880_pin_clevo_init_verbs },
2870 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2871 .dac_nids = alc880_dac_nids,
2872 .hp_nid = 0x03,
2873 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2874 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002875 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002876 .input_mux = &alc880_capture_source,
2877 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002878 [ALC880_LG] = {
2879 .mixers = { alc880_lg_mixer },
2880 .init_verbs = { alc880_volume_init_verbs,
2881 alc880_lg_init_verbs },
2882 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2883 .dac_nids = alc880_lg_dac_nids,
2884 .dig_out_nid = ALC880_DIGOUT_NID,
2885 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2886 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002887 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002888 .input_mux = &alc880_lg_capture_source,
2889 .unsol_event = alc880_lg_unsol_event,
2890 .init_hook = alc880_lg_automute,
2891 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002892 [ALC880_LG_LW] = {
2893 .mixers = { alc880_lg_lw_mixer },
2894 .init_verbs = { alc880_volume_init_verbs,
2895 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002896 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002897 .dac_nids = alc880_dac_nids,
2898 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002899 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2900 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002901 .input_mux = &alc880_lg_lw_capture_source,
2902 .unsol_event = alc880_lg_lw_unsol_event,
2903 .init_hook = alc880_lg_lw_automute,
2904 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002905#ifdef CONFIG_SND_DEBUG
2906 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002907 .mixers = { alc880_test_mixer },
2908 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002909 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2910 .dac_nids = alc880_test_dac_nids,
2911 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002912 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2913 .channel_mode = alc880_test_modes,
2914 .input_mux = &alc880_test_capture_source,
2915 },
2916#endif
2917};
2918
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002919/*
2920 * Automatic parse of I/O pins from the BIOS configuration
2921 */
2922
2923#define NUM_CONTROL_ALLOC 32
2924#define NUM_VERB_ALLOC 32
2925
2926enum {
2927 ALC_CTL_WIDGET_VOL,
2928 ALC_CTL_WIDGET_MUTE,
2929 ALC_CTL_BIND_MUTE,
2930};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002931static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002932 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2933 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002934 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002935};
2936
2937/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002938static int add_control(struct alc_spec *spec, int type, const char *name,
2939 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002940{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002941 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002942
2943 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2944 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2945
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002946 /* array + terminator */
2947 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2948 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002949 return -ENOMEM;
2950 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002951 memcpy(knew, spec->kctl_alloc,
2952 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002953 kfree(spec->kctl_alloc);
2954 }
2955 spec->kctl_alloc = knew;
2956 spec->num_kctl_alloc = num;
2957 }
2958
2959 knew = &spec->kctl_alloc[spec->num_kctl_used];
2960 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002961 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002962 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002963 return -ENOMEM;
2964 knew->private_value = val;
2965 spec->num_kctl_used++;
2966 return 0;
2967}
2968
2969#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2970#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2971#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2972#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2973#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2974#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2975#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2976#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2977#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2978#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2979#define ALC880_PIN_CD_NID 0x1c
2980
2981/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002982static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2983 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002984{
2985 hda_nid_t nid;
2986 int assigned[4];
2987 int i, j;
2988
2989 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002990 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002991
2992 /* check the pins hardwired to audio widget */
2993 for (i = 0; i < cfg->line_outs; i++) {
2994 nid = cfg->line_out_pins[i];
2995 if (alc880_is_fixed_pin(nid)) {
2996 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002997 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998 assigned[idx] = 1;
2999 }
3000 }
3001 /* left pins can be connect to any audio widget */
3002 for (i = 0; i < cfg->line_outs; i++) {
3003 nid = cfg->line_out_pins[i];
3004 if (alc880_is_fixed_pin(nid))
3005 continue;
3006 /* search for an empty channel */
3007 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003008 if (!assigned[j]) {
3009 spec->multiout.dac_nids[i] =
3010 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003011 assigned[j] = 1;
3012 break;
3013 }
3014 }
3015 }
3016 spec->multiout.num_dacs = cfg->line_outs;
3017 return 0;
3018}
3019
3020/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003021static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3022 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003023{
3024 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003025 static const char *chname[4] = {
3026 "Front", "Surround", NULL /*CLFE*/, "Side"
3027 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003028 hda_nid_t nid;
3029 int i, err;
3030
3031 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003032 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003033 continue;
3034 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3035 if (i == 2) {
3036 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003037 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3038 "Center Playback Volume",
3039 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3040 HDA_OUTPUT));
3041 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003042 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003043 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3044 "LFE Playback Volume",
3045 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3046 HDA_OUTPUT));
3047 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003048 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003049 err = add_control(spec, ALC_CTL_BIND_MUTE,
3050 "Center Playback Switch",
3051 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3052 HDA_INPUT));
3053 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003054 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003055 err = add_control(spec, ALC_CTL_BIND_MUTE,
3056 "LFE Playback Switch",
3057 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3058 HDA_INPUT));
3059 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 return err;
3061 } else {
3062 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003063 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3064 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3065 HDA_OUTPUT));
3066 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003067 return err;
3068 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003069 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3070 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3071 HDA_INPUT));
3072 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073 return err;
3074 }
3075 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076 return 0;
3077}
3078
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003079/* add playback controls for speaker and HP outputs */
3080static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3081 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082{
3083 hda_nid_t nid;
3084 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003085 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003087 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 return 0;
3089
3090 if (alc880_is_fixed_pin(pin)) {
3091 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003092 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003093 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003094 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003095 else
3096 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097 /* control HP volume/switch on the output mixer amp */
3098 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003099 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003100 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3101 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3102 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003103 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003104 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003105 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3106 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3107 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 return err;
3109 } else if (alc880_is_multi_pin(pin)) {
3110 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003111 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003112 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003113 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3114 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3115 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116 return err;
3117 }
3118 return 0;
3119}
3120
3121/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003122static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3123 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003124 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003125{
3126 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003127 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003128
3129 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003130 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3131 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3132 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003133 return err;
3134 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003135 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3136 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3137 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003138 return err;
3139 return 0;
3140}
3141
3142/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003143static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3144 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003145{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003147 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003148
3149 for (i = 0; i < AUTO_PIN_LAST; i++) {
3150 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003151 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003152 err = new_analog_input(spec, cfg->input_pins[i],
3153 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003154 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003155 if (err < 0)
3156 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003157 imux->items[imux->num_items].label =
3158 auto_pin_cfg_labels[i];
3159 imux->items[imux->num_items].index =
3160 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161 imux->num_items++;
3162 }
3163 }
3164 return 0;
3165}
3166
Kailang Yangdf694da2005-12-05 19:42:22 +01003167static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3168 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003169 int dac_idx)
3170{
3171 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003172 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3173 pin_type);
3174 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3175 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003176 /* need the manual connection? */
3177 if (alc880_is_multi_pin(nid)) {
3178 struct alc_spec *spec = codec->spec;
3179 int idx = alc880_multi_pin_idx(nid);
3180 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3181 AC_VERB_SET_CONNECT_SEL,
3182 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3183 }
3184}
3185
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003186static int get_pin_type(int line_out_type)
3187{
3188 if (line_out_type == AUTO_PIN_HP_OUT)
3189 return PIN_HP;
3190 else
3191 return PIN_OUT;
3192}
3193
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003194static void alc880_auto_init_multi_out(struct hda_codec *codec)
3195{
3196 struct alc_spec *spec = codec->spec;
3197 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003198
3199 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003200 for (i = 0; i < spec->autocfg.line_outs; i++) {
3201 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003202 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3203 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003204 }
3205}
3206
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003207static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003208{
3209 struct alc_spec *spec = codec->spec;
3210 hda_nid_t pin;
3211
Takashi Iwai82bc9552006-03-21 11:24:42 +01003212 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003213 if (pin) /* connect to front */
3214 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003215 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003216 if (pin) /* connect to front */
3217 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3218}
3219
3220static void alc880_auto_init_analog_input(struct hda_codec *codec)
3221{
3222 struct alc_spec *spec = codec->spec;
3223 int i;
3224
3225 for (i = 0; i < AUTO_PIN_LAST; i++) {
3226 hda_nid_t nid = spec->autocfg.input_pins[i];
3227 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003228 snd_hda_codec_write(codec, nid, 0,
3229 AC_VERB_SET_PIN_WIDGET_CONTROL,
3230 i <= AUTO_PIN_FRONT_MIC ?
3231 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003232 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003233 snd_hda_codec_write(codec, nid, 0,
3234 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 AMP_OUT_MUTE);
3236 }
3237 }
3238}
3239
3240/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003241/* return 1 if successful, 0 if the proper config is not found,
3242 * or a negative error code
3243 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003244static int alc880_parse_auto_config(struct hda_codec *codec)
3245{
3246 struct alc_spec *spec = codec->spec;
3247 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003248 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003249
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003250 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3251 alc880_ignore);
3252 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003253 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003254 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003255 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003256
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003257 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3258 if (err < 0)
3259 return err;
3260 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3261 if (err < 0)
3262 return err;
3263 err = alc880_auto_create_extra_out(spec,
3264 spec->autocfg.speaker_pins[0],
3265 "Speaker");
3266 if (err < 0)
3267 return err;
3268 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3269 "Headphone");
3270 if (err < 0)
3271 return err;
3272 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3273 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 return err;
3275
3276 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3277
3278 if (spec->autocfg.dig_out_pin)
3279 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3280 if (spec->autocfg.dig_in_pin)
3281 spec->dig_in_nid = ALC880_DIGIN_NID;
3282
3283 if (spec->kctl_alloc)
3284 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3285
3286 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3287
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003288 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003289 spec->input_mux = &spec->private_imux;
3290
3291 return 1;
3292}
3293
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003294/* additional initialization for auto-configuration model */
3295static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003296{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003297 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003298 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003299 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003300}
3301
3302/*
3303 * OK, here we have finally the patch for ALC880
3304 */
3305
Linus Torvalds1da177e2005-04-16 15:20:36 -07003306static int patch_alc880(struct hda_codec *codec)
3307{
3308 struct alc_spec *spec;
3309 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003310 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003311
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003312 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313 if (spec == NULL)
3314 return -ENOMEM;
3315
3316 codec->spec = spec;
3317
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003318 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3319 alc880_models,
3320 alc880_cfg_tbl);
3321 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003322 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3323 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003324 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325 }
3326
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003327 if (board_config == ALC880_AUTO) {
3328 /* automatic parse from the BIOS config */
3329 err = alc880_parse_auto_config(codec);
3330 if (err < 0) {
3331 alc_free(codec);
3332 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003333 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003334 printk(KERN_INFO
3335 "hda_codec: Cannot set up configuration "
3336 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003337 board_config = ALC880_3ST;
3338 }
3339 }
3340
Kailang Yangdf694da2005-12-05 19:42:22 +01003341 if (board_config != ALC880_AUTO)
3342 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003343
3344 spec->stream_name_analog = "ALC880 Analog";
3345 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3346 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3347
3348 spec->stream_name_digital = "ALC880 Digital";
3349 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3350 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3351
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003352 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003353 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003354 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003355 /* get type */
3356 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003357 if (wcap != AC_WID_AUD_IN) {
3358 spec->adc_nids = alc880_adc_nids_alt;
3359 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003360 spec->mixers[spec->num_mixers] =
3361 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003362 spec->num_mixers++;
3363 } else {
3364 spec->adc_nids = alc880_adc_nids;
3365 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3366 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3367 spec->num_mixers++;
3368 }
3369 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003370
3371 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003372 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003373 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374
3375 return 0;
3376}
3377
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003378
Linus Torvalds1da177e2005-04-16 15:20:36 -07003379/*
3380 * ALC260 support
3381 */
3382
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003383static hda_nid_t alc260_dac_nids[1] = {
3384 /* front */
3385 0x02,
3386};
3387
3388static hda_nid_t alc260_adc_nids[1] = {
3389 /* ADC0 */
3390 0x04,
3391};
3392
Kailang Yangdf694da2005-12-05 19:42:22 +01003393static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003394 /* ADC1 */
3395 0x05,
3396};
3397
Kailang Yangdf694da2005-12-05 19:42:22 +01003398static hda_nid_t alc260_hp_adc_nids[2] = {
3399 /* ADC1, 0 */
3400 0x05, 0x04
3401};
3402
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003403/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3404 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3405 */
3406static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003407 /* ADC0, ADC1 */
3408 0x04, 0x05
3409};
3410
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411#define ALC260_DIGOUT_NID 0x03
3412#define ALC260_DIGIN_NID 0x06
3413
3414static struct hda_input_mux alc260_capture_source = {
3415 .num_items = 4,
3416 .items = {
3417 { "Mic", 0x0 },
3418 { "Front Mic", 0x1 },
3419 { "Line", 0x2 },
3420 { "CD", 0x4 },
3421 },
3422};
3423
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003424/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003425 * headphone jack and the internal CD lines since these are the only pins at
3426 * which audio can appear. For flexibility, also allow the option of
3427 * recording the mixer output on the second ADC (ADC0 doesn't have a
3428 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003429 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003430static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3431 {
3432 .num_items = 3,
3433 .items = {
3434 { "Mic/Line", 0x0 },
3435 { "CD", 0x4 },
3436 { "Headphone", 0x2 },
3437 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003438 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003439 {
3440 .num_items = 4,
3441 .items = {
3442 { "Mic/Line", 0x0 },
3443 { "CD", 0x4 },
3444 { "Headphone", 0x2 },
3445 { "Mixer", 0x5 },
3446 },
3447 },
3448
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003449};
3450
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003451/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3452 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003453 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003454static struct hda_input_mux alc260_acer_capture_sources[2] = {
3455 {
3456 .num_items = 4,
3457 .items = {
3458 { "Mic", 0x0 },
3459 { "Line", 0x2 },
3460 { "CD", 0x4 },
3461 { "Headphone", 0x5 },
3462 },
3463 },
3464 {
3465 .num_items = 5,
3466 .items = {
3467 { "Mic", 0x0 },
3468 { "Line", 0x2 },
3469 { "CD", 0x4 },
3470 { "Headphone", 0x6 },
3471 { "Mixer", 0x5 },
3472 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003473 },
3474};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003475/*
3476 * This is just place-holder, so there's something for alc_build_pcms to look
3477 * at when it calculates the maximum number of channels. ALC260 has no mixer
3478 * element which allows changing the channel mode, so the verb list is
3479 * never used.
3480 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003481static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003482 { 2, NULL },
3483};
3484
Kailang Yangdf694da2005-12-05 19:42:22 +01003485
3486/* Mixer combinations
3487 *
3488 * basic: base_output + input + pc_beep + capture
3489 * HP: base_output + input + capture_alt
3490 * HP_3013: hp_3013 + input + capture
3491 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003492 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003493 */
3494
3495static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003496 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003497 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003498 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3499 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3500 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3501 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3502 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003503};
Kailang Yangdf694da2005-12-05 19:42:22 +01003504
3505static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003506 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3507 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3508 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3509 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3510 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3511 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3512 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3513 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003514 { } /* end */
3515};
3516
Kailang Yangdf694da2005-12-05 19:42:22 +01003517static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3518 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3519 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3520 { } /* end */
3521};
3522
3523static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3524 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3525 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3526 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3527 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3528 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3530 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3531 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003532 { } /* end */
3533};
3534
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003535/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3536 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3537 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003538static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003539 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003540 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003541 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003542 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3543 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3544 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3545 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003546 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003547 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3548 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3549 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003550 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003551 { } /* end */
3552};
3553
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003554/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3555 * versions of the ALC260 don't act on requests to enable mic bias from NID
3556 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3557 * datasheet doesn't mention this restriction. At this stage it's not clear
3558 * whether this behaviour is intentional or is a hardware bug in chip
3559 * revisions available in early 2006. Therefore for now allow the
3560 * "Headphone Jack Mode" control to span all choices, but if it turns out
3561 * that the lack of mic bias for this NID is intentional we could change the
3562 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3563 *
3564 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3565 * don't appear to make the mic bias available from the "line" jack, even
3566 * though the NID used for this jack (0x14) can supply it. The theory is
3567 * that perhaps Acer have included blocking capacitors between the ALC260
3568 * and the output jack. If this turns out to be the case for all such
3569 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3570 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003571 *
3572 * The C20x Tablet series have a mono internal speaker which is controlled
3573 * via the chip's Mono sum widget and pin complex, so include the necessary
3574 * controls for such models. On models without a "mono speaker" the control
3575 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003576 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003577static struct snd_kcontrol_new alc260_acer_mixer[] = {
3578 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3579 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003580 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003581 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3582 HDA_OUTPUT),
3583 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3584 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003585 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3586 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3588 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3589 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3590 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3591 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3592 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3593 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3594 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3595 { } /* end */
3596};
3597
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003598/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3599 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3600 */
3601static struct snd_kcontrol_new alc260_will_mixer[] = {
3602 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3603 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3605 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3606 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3607 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3608 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3609 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3610 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3611 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3612 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3613 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3614 { } /* end */
3615};
3616
3617/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3618 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3619 */
3620static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3621 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3622 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3624 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3625 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3626 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3627 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3628 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3629 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3630 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3631 { } /* end */
3632};
3633
Kailang Yangdf694da2005-12-05 19:42:22 +01003634/* capture mixer elements */
3635static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003636 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3637 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003638 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3639 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003640 {
3641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003642 /* The multiple "Capture Source" controls confuse alsamixer
3643 * So call somewhat different..
3644 * FIXME: the controls appear in the "playback" view!
3645 */
3646 /* .name = "Capture Source", */
3647 .name = "Input Source",
3648 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003649 .info = alc_mux_enum_info,
3650 .get = alc_mux_enum_get,
3651 .put = alc_mux_enum_put,
3652 },
3653 { } /* end */
3654};
3655
Kailang Yangdf694da2005-12-05 19:42:22 +01003656static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3657 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3658 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3659 {
3660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3661 /* The multiple "Capture Source" controls confuse alsamixer
3662 * So call somewhat different..
3663 * FIXME: the controls appear in the "playback" view!
3664 */
3665 /* .name = "Capture Source", */
3666 .name = "Input Source",
3667 .count = 1,
3668 .info = alc_mux_enum_info,
3669 .get = alc_mux_enum_get,
3670 .put = alc_mux_enum_put,
3671 },
3672 { } /* end */
3673};
3674
3675/*
3676 * initialization verbs
3677 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003678static struct hda_verb alc260_init_verbs[] = {
3679 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003680 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003681 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003682 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003683 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003684 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003685 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003686 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003687 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003689 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003690 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003691 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003692 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003693 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003694 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003695 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003696 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3697 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003698 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003699 /* set connection select to line in (default select for this ADC) */
3700 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003701 /* mute capture amp left and right */
3702 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3703 /* set connection select to line in (default select for this ADC) */
3704 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003705 /* set vol=0 Line-Out mixer amp left and right */
3706 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3707 /* unmute pin widget amp left and right (no gain on this amp) */
3708 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3709 /* set vol=0 HP mixer amp left and right */
3710 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3711 /* unmute pin widget amp left and right (no gain on this amp) */
3712 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3713 /* set vol=0 Mono mixer amp left and right */
3714 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3715 /* unmute pin widget amp left and right (no gain on this amp) */
3716 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3717 /* unmute LINE-2 out pin */
3718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003719 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3720 * Line In 2 = 0x03
3721 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003722 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003724 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003725 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003726 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003728 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003729 /* mute Front out path */
3730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3731 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3732 /* mute Headphone out path */
3733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3735 /* mute Mono out path */
3736 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3737 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003738 { }
3739};
3740
Takashi Iwai474167d2006-05-17 17:17:43 +02003741#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003742static struct hda_verb alc260_hp_init_verbs[] = {
3743 /* Headphone and output */
3744 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3745 /* mono output */
3746 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3747 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3748 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3749 /* Mic2 (front panel) pin widget for input and vref at 80% */
3750 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3751 /* Line In pin widget for input */
3752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3753 /* Line-2 pin widget for output */
3754 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3755 /* CD pin widget for input */
3756 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3757 /* unmute amp left and right */
3758 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3759 /* set connection select to line in (default select for this ADC) */
3760 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3761 /* unmute Line-Out mixer amp left and right (volume = 0) */
3762 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3763 /* mute pin widget amp left and right (no gain on this amp) */
3764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3765 /* unmute HP mixer amp left and right (volume = 0) */
3766 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3767 /* mute pin widget amp left and right (no gain on this amp) */
3768 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003769 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3770 * Line In 2 = 0x03
3771 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003772 /* unmute CD */
3773 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3774 /* unmute Line In */
3775 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3776 /* unmute Mic */
3777 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3778 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3779 /* Unmute Front out path */
3780 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3782 /* Unmute Headphone out path */
3783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3784 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3785 /* Unmute Mono out path */
3786 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3787 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3788 { }
3789};
Takashi Iwai474167d2006-05-17 17:17:43 +02003790#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003791
3792static struct hda_verb alc260_hp_3013_init_verbs[] = {
3793 /* Line out and output */
3794 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3795 /* mono output */
3796 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3797 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3798 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3799 /* Mic2 (front panel) pin widget for input and vref at 80% */
3800 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3801 /* Line In pin widget for input */
3802 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3803 /* Headphone pin widget for output */
3804 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3805 /* CD pin widget for input */
3806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3807 /* unmute amp left and right */
3808 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3809 /* set connection select to line in (default select for this ADC) */
3810 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3811 /* unmute Line-Out mixer amp left and right (volume = 0) */
3812 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3813 /* mute pin widget amp left and right (no gain on this amp) */
3814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3815 /* unmute HP mixer amp left and right (volume = 0) */
3816 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3817 /* mute pin widget amp left and right (no gain on this amp) */
3818 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003819 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3820 * Line In 2 = 0x03
3821 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003822 /* unmute CD */
3823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3824 /* unmute Line In */
3825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3826 /* unmute Mic */
3827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3828 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3829 /* Unmute Front out path */
3830 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3832 /* Unmute Headphone out path */
3833 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3834 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3835 /* Unmute Mono out path */
3836 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3837 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3838 { }
3839};
3840
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003841/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003842 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3843 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003844 */
3845static struct hda_verb alc260_fujitsu_init_verbs[] = {
3846 /* Disable all GPIOs */
3847 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3848 /* Internal speaker is connected to headphone pin */
3849 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3850 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3851 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003852 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3853 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3854 /* Ensure all other unused pins are disabled and muted. */
3855 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3856 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003857 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003858 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003859 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003860 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3861 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003863
Jonathan Woithef7ace402006-02-28 11:46:14 +01003864 /* Disable digital (SPDIF) pins */
3865 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3866 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003867
Jonathan Woithef7ace402006-02-28 11:46:14 +01003868 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3869 * when acting as an output.
3870 */
3871 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3872
3873 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003874 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3875 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3876 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3877 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3878 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3880 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3881 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3882 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003883
Jonathan Woithef7ace402006-02-28 11:46:14 +01003884 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3885 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3886 /* Unmute Line1 pin widget output buffer since it starts as an output.
3887 * If the pin mode is changed by the user the pin mode control will
3888 * take care of enabling the pin's input/output buffers as needed.
3889 * Therefore there's no need to enable the input buffer at this
3890 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003891 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003893 /* Unmute input buffer of pin widget used for Line-in (no equiv
3894 * mixer ctrl)
3895 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003896 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003897
Jonathan Woithef7ace402006-02-28 11:46:14 +01003898 /* Mute capture amp left and right */
3899 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3900 /* Set ADC connection select to match default mixer setting - line
3901 * in (on mic1 pin)
3902 */
3903 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003904
Jonathan Woithef7ace402006-02-28 11:46:14 +01003905 /* Do the same for the second ADC: mute capture input amp and
3906 * set ADC connection to line in (on mic1 pin)
3907 */
3908 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3909 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003910
Jonathan Woithef7ace402006-02-28 11:46:14 +01003911 /* Mute all inputs to mixer widget (even unconnected ones) */
3912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3917 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003920
3921 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003922};
3923
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003924/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3925 * similar laptops (adapted from Fujitsu init verbs).
3926 */
3927static struct hda_verb alc260_acer_init_verbs[] = {
3928 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3929 * the headphone jack. Turn this on and rely on the standard mute
3930 * methods whenever the user wants to turn these outputs off.
3931 */
3932 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3933 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3934 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3935 /* Internal speaker/Headphone jack is connected to Line-out pin */
3936 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3937 /* Internal microphone/Mic jack is connected to Mic1 pin */
3938 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3939 /* Line In jack is connected to Line1 pin */
3940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003941 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3942 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003943 /* Ensure all other unused pins are disabled and muted. */
3944 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3945 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003946 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3947 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3948 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3949 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3950 /* Disable digital (SPDIF) pins */
3951 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3952 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3953
3954 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3955 * bus when acting as outputs.
3956 */
3957 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3958 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3959
3960 /* Start with output sum widgets muted and their output gains at min */
3961 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3962 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3963 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3964 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3965 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3966 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3967 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3968 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3969 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3970
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003971 /* Unmute Line-out pin widget amp left and right
3972 * (no equiv mixer ctrl)
3973 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003974 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003975 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3976 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003977 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3978 * inputs. If the pin mode is changed by the user the pin mode control
3979 * will take care of enabling the pin's input/output buffers as needed.
3980 * Therefore there's no need to enable the input buffer at this
3981 * stage.
3982 */
3983 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3985
3986 /* Mute capture amp left and right */
3987 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3988 /* Set ADC connection select to match default mixer setting - mic
3989 * (on mic1 pin)
3990 */
3991 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3992
3993 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003994 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003995 */
3996 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003997 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003998
3999 /* Mute all inputs to mixer widget (even unconnected ones) */
4000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4007 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4008
4009 { }
4010};
4011
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004012static struct hda_verb alc260_will_verbs[] = {
4013 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4014 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4015 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4016 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4017 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4018 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4019 {}
4020};
4021
4022static struct hda_verb alc260_replacer_672v_verbs[] = {
4023 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4024 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4025 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4026
4027 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4028 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4029 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4030
4031 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4032 {}
4033};
4034
4035/* toggle speaker-output according to the hp-jack state */
4036static void alc260_replacer_672v_automute(struct hda_codec *codec)
4037{
4038 unsigned int present;
4039
4040 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4041 present = snd_hda_codec_read(codec, 0x0f, 0,
4042 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4043 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004044 snd_hda_codec_write_cache(codec, 0x01, 0,
4045 AC_VERB_SET_GPIO_DATA, 1);
4046 snd_hda_codec_write_cache(codec, 0x0f, 0,
4047 AC_VERB_SET_PIN_WIDGET_CONTROL,
4048 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004049 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004050 snd_hda_codec_write_cache(codec, 0x01, 0,
4051 AC_VERB_SET_GPIO_DATA, 0);
4052 snd_hda_codec_write_cache(codec, 0x0f, 0,
4053 AC_VERB_SET_PIN_WIDGET_CONTROL,
4054 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004055 }
4056}
4057
4058static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4059 unsigned int res)
4060{
4061 if ((res >> 26) == ALC880_HP_EVENT)
4062 alc260_replacer_672v_automute(codec);
4063}
4064
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004065/* Test configuration for debugging, modelled after the ALC880 test
4066 * configuration.
4067 */
4068#ifdef CONFIG_SND_DEBUG
4069static hda_nid_t alc260_test_dac_nids[1] = {
4070 0x02,
4071};
4072static hda_nid_t alc260_test_adc_nids[2] = {
4073 0x04, 0x05,
4074};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004075/* For testing the ALC260, each input MUX needs its own definition since
4076 * the signal assignments are different. This assumes that the first ADC
4077 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004078 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004079static struct hda_input_mux alc260_test_capture_sources[2] = {
4080 {
4081 .num_items = 7,
4082 .items = {
4083 { "MIC1 pin", 0x0 },
4084 { "MIC2 pin", 0x1 },
4085 { "LINE1 pin", 0x2 },
4086 { "LINE2 pin", 0x3 },
4087 { "CD pin", 0x4 },
4088 { "LINE-OUT pin", 0x5 },
4089 { "HP-OUT pin", 0x6 },
4090 },
4091 },
4092 {
4093 .num_items = 8,
4094 .items = {
4095 { "MIC1 pin", 0x0 },
4096 { "MIC2 pin", 0x1 },
4097 { "LINE1 pin", 0x2 },
4098 { "LINE2 pin", 0x3 },
4099 { "CD pin", 0x4 },
4100 { "Mixer", 0x5 },
4101 { "LINE-OUT pin", 0x6 },
4102 { "HP-OUT pin", 0x7 },
4103 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004104 },
4105};
4106static struct snd_kcontrol_new alc260_test_mixer[] = {
4107 /* Output driver widgets */
4108 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4109 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4110 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4111 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4112 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4113 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4114
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004115 /* Modes for retasking pin widgets
4116 * Note: the ALC260 doesn't seem to act on requests to enable mic
4117 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4118 * mention this restriction. At this stage it's not clear whether
4119 * this behaviour is intentional or is a hardware bug in chip
4120 * revisions available at least up until early 2006. Therefore for
4121 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4122 * choices, but if it turns out that the lack of mic bias for these
4123 * NIDs is intentional we could change their modes from
4124 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4125 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004126 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4127 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4128 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4129 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4130 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4131 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4132
4133 /* Loopback mixer controls */
4134 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4135 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4136 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4137 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4138 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4139 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4140 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4141 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4142 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4143 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4144 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4145 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4146 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4147 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4148 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4149 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004150
4151 /* Controls for GPIO pins, assuming they are configured as outputs */
4152 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4153 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4154 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4155 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4156
Jonathan Woithe92621f12006-02-28 11:47:47 +01004157 /* Switches to allow the digital IO pins to be enabled. The datasheet
4158 * is ambigious as to which NID is which; testing on laptops which
4159 * make this output available should provide clarification.
4160 */
4161 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4162 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4163
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004164 { } /* end */
4165};
4166static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004167 /* Enable all GPIOs as outputs with an initial value of 0 */
4168 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4169 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4170 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4171
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004172 /* Enable retasking pins as output, initially without power amp */
4173 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4174 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4177 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4178 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4179
Jonathan Woithe92621f12006-02-28 11:47:47 +01004180 /* Disable digital (SPDIF) pins initially, but users can enable
4181 * them via a mixer switch. In the case of SPDIF-out, this initverb
4182 * payload also sets the generation to 0, output to be in "consumer"
4183 * PCM format, copyright asserted, no pre-emphasis and no validity
4184 * control.
4185 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004186 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4187 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4188
Jonathan Woithef7ace402006-02-28 11:46:14 +01004189 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004190 * OUT1 sum bus when acting as an output.
4191 */
4192 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4193 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4194 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4195 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4196
4197 /* Start with output sum widgets muted and their output gains at min */
4198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4200 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4203 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4204 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4205 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4206 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4207
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004208 /* Unmute retasking pin widget output buffers since the default
4209 * state appears to be output. As the pin mode is changed by the
4210 * user the pin mode control will take care of enabling the pin's
4211 * input/output buffers as needed.
4212 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004213 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4214 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4216 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4217 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4218 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4219 /* Also unmute the mono-out pin widget */
4220 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4221
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004222 /* Mute capture amp left and right */
4223 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004224 /* Set ADC connection select to match default mixer setting (mic1
4225 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004226 */
4227 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4228
4229 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004230 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004231 */
4232 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4233 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4234
4235 /* Mute all inputs to mixer widget (even unconnected ones) */
4236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4244
4245 { }
4246};
4247#endif
4248
Linus Torvalds1da177e2005-04-16 15:20:36 -07004249static struct hda_pcm_stream alc260_pcm_analog_playback = {
4250 .substreams = 1,
4251 .channels_min = 2,
4252 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004253};
4254
4255static struct hda_pcm_stream alc260_pcm_analog_capture = {
4256 .substreams = 1,
4257 .channels_min = 2,
4258 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004259};
4260
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004261#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4262#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4263
Kailang Yangdf694da2005-12-05 19:42:22 +01004264/*
4265 * for BIOS auto-configuration
4266 */
4267
4268static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4269 const char *pfx)
4270{
4271 hda_nid_t nid_vol;
4272 unsigned long vol_val, sw_val;
4273 char name[32];
4274 int err;
4275
4276 if (nid >= 0x0f && nid < 0x11) {
4277 nid_vol = nid - 0x7;
4278 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4279 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4280 } else if (nid == 0x11) {
4281 nid_vol = nid - 0x7;
4282 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4283 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4284 } else if (nid >= 0x12 && nid <= 0x15) {
4285 nid_vol = 0x08;
4286 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4287 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4288 } else
4289 return 0; /* N/A */
4290
4291 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004292 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4293 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004294 return err;
4295 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004296 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4297 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004298 return err;
4299 return 1;
4300}
4301
4302/* add playback controls from the parsed DAC table */
4303static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4304 const struct auto_pin_cfg *cfg)
4305{
4306 hda_nid_t nid;
4307 int err;
4308
4309 spec->multiout.num_dacs = 1;
4310 spec->multiout.dac_nids = spec->private_dac_nids;
4311 spec->multiout.dac_nids[0] = 0x02;
4312
4313 nid = cfg->line_out_pins[0];
4314 if (nid) {
4315 err = alc260_add_playback_controls(spec, nid, "Front");
4316 if (err < 0)
4317 return err;
4318 }
4319
Takashi Iwai82bc9552006-03-21 11:24:42 +01004320 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004321 if (nid) {
4322 err = alc260_add_playback_controls(spec, nid, "Speaker");
4323 if (err < 0)
4324 return err;
4325 }
4326
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004327 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004328 if (nid) {
4329 err = alc260_add_playback_controls(spec, nid, "Headphone");
4330 if (err < 0)
4331 return err;
4332 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004333 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004334}
4335
4336/* create playback/capture controls for input pins */
4337static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4338 const struct auto_pin_cfg *cfg)
4339{
Kailang Yangdf694da2005-12-05 19:42:22 +01004340 struct hda_input_mux *imux = &spec->private_imux;
4341 int i, err, idx;
4342
4343 for (i = 0; i < AUTO_PIN_LAST; i++) {
4344 if (cfg->input_pins[i] >= 0x12) {
4345 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004346 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004347 auto_pin_cfg_labels[i], idx,
4348 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004349 if (err < 0)
4350 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004351 imux->items[imux->num_items].label =
4352 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004353 imux->items[imux->num_items].index = idx;
4354 imux->num_items++;
4355 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004356 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004357 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004358 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004359 auto_pin_cfg_labels[i], idx,
4360 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004361 if (err < 0)
4362 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004363 imux->items[imux->num_items].label =
4364 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004365 imux->items[imux->num_items].index = idx;
4366 imux->num_items++;
4367 }
4368 }
4369 return 0;
4370}
4371
4372static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4373 hda_nid_t nid, int pin_type,
4374 int sel_idx)
4375{
4376 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004377 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4378 pin_type);
4379 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4380 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004381 /* need the manual connection? */
4382 if (nid >= 0x12) {
4383 int idx = nid - 0x12;
4384 snd_hda_codec_write(codec, idx + 0x0b, 0,
4385 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004386 }
4387}
4388
4389static void alc260_auto_init_multi_out(struct hda_codec *codec)
4390{
4391 struct alc_spec *spec = codec->spec;
4392 hda_nid_t nid;
4393
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004394 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004395 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004396 if (nid) {
4397 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4398 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4399 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004400
Takashi Iwai82bc9552006-03-21 11:24:42 +01004401 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004402 if (nid)
4403 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4404
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004405 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004406 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004407 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004408}
Kailang Yangdf694da2005-12-05 19:42:22 +01004409
4410#define ALC260_PIN_CD_NID 0x16
4411static void alc260_auto_init_analog_input(struct hda_codec *codec)
4412{
4413 struct alc_spec *spec = codec->spec;
4414 int i;
4415
4416 for (i = 0; i < AUTO_PIN_LAST; i++) {
4417 hda_nid_t nid = spec->autocfg.input_pins[i];
4418 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004419 snd_hda_codec_write(codec, nid, 0,
4420 AC_VERB_SET_PIN_WIDGET_CONTROL,
4421 i <= AUTO_PIN_FRONT_MIC ?
4422 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004423 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004424 snd_hda_codec_write(codec, nid, 0,
4425 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004426 AMP_OUT_MUTE);
4427 }
4428 }
4429}
4430
4431/*
4432 * generic initialization of ADC, input mixers and output mixers
4433 */
4434static struct hda_verb alc260_volume_init_verbs[] = {
4435 /*
4436 * Unmute ADC0-1 and set the default input to mic-in
4437 */
4438 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4439 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4440 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4441 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4442
4443 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4444 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004445 * Note: PASD motherboards uses the Line In 2 as the input for
4446 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004447 */
4448 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4454
4455 /*
4456 * Set up output mixers (0x08 - 0x0a)
4457 */
4458 /* set vol=0 to output mixers */
4459 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4461 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4462 /* set up input amps for analog loopback */
4463 /* Amp Indices: DAC = 0, mixer = 1 */
4464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4470
4471 { }
4472};
4473
4474static int alc260_parse_auto_config(struct hda_codec *codec)
4475{
4476 struct alc_spec *spec = codec->spec;
4477 unsigned int wcap;
4478 int err;
4479 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4480
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004481 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4482 alc260_ignore);
4483 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004484 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004485 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4486 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004487 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004488 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004489 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004490 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4491 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004492 return err;
4493
4494 spec->multiout.max_channels = 2;
4495
4496 if (spec->autocfg.dig_out_pin)
4497 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4498 if (spec->kctl_alloc)
4499 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4500
4501 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4502
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004503 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004504 spec->input_mux = &spec->private_imux;
4505
4506 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004507 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004508 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4509 if (wcap != AC_WID_AUD_IN) {
4510 spec->adc_nids = alc260_adc_nids_alt;
4511 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4512 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004513 } else {
4514 spec->adc_nids = alc260_adc_nids;
4515 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4516 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004517 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004518 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004519
4520 return 1;
4521}
4522
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004523/* additional initialization for auto-configuration model */
4524static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004525{
Kailang Yangdf694da2005-12-05 19:42:22 +01004526 alc260_auto_init_multi_out(codec);
4527 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004528}
4529
4530/*
4531 * ALC260 configurations
4532 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004533static const char *alc260_models[ALC260_MODEL_LAST] = {
4534 [ALC260_BASIC] = "basic",
4535 [ALC260_HP] = "hp",
4536 [ALC260_HP_3013] = "hp-3013",
4537 [ALC260_FUJITSU_S702X] = "fujitsu",
4538 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004539 [ALC260_WILL] = "will",
4540 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004541#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004542 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004543#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004544 [ALC260_AUTO] = "auto",
4545};
4546
4547static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004548 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004549 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004550 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004551 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004552 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4553 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4554 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4555 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4556 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4557 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4558 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4559 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4560 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4561 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4562 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4563 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004564 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4565 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004566 {}
4567};
4568
Kailang Yangdf694da2005-12-05 19:42:22 +01004569static struct alc_config_preset alc260_presets[] = {
4570 [ALC260_BASIC] = {
4571 .mixers = { alc260_base_output_mixer,
4572 alc260_input_mixer,
4573 alc260_pc_beep_mixer,
4574 alc260_capture_mixer },
4575 .init_verbs = { alc260_init_verbs },
4576 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4577 .dac_nids = alc260_dac_nids,
4578 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4579 .adc_nids = alc260_adc_nids,
4580 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4581 .channel_mode = alc260_modes,
4582 .input_mux = &alc260_capture_source,
4583 },
4584 [ALC260_HP] = {
4585 .mixers = { alc260_base_output_mixer,
4586 alc260_input_mixer,
4587 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004588 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004589 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4590 .dac_nids = alc260_dac_nids,
4591 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4592 .adc_nids = alc260_hp_adc_nids,
4593 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4594 .channel_mode = alc260_modes,
4595 .input_mux = &alc260_capture_source,
4596 },
4597 [ALC260_HP_3013] = {
4598 .mixers = { alc260_hp_3013_mixer,
4599 alc260_input_mixer,
4600 alc260_capture_alt_mixer },
4601 .init_verbs = { alc260_hp_3013_init_verbs },
4602 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4603 .dac_nids = alc260_dac_nids,
4604 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4605 .adc_nids = alc260_hp_adc_nids,
4606 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4607 .channel_mode = alc260_modes,
4608 .input_mux = &alc260_capture_source,
4609 },
4610 [ALC260_FUJITSU_S702X] = {
4611 .mixers = { alc260_fujitsu_mixer,
4612 alc260_capture_mixer },
4613 .init_verbs = { alc260_fujitsu_init_verbs },
4614 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4615 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004616 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4617 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004618 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4619 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004620 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4621 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004622 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004623 [ALC260_ACER] = {
4624 .mixers = { alc260_acer_mixer,
4625 alc260_capture_mixer },
4626 .init_verbs = { alc260_acer_init_verbs },
4627 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4628 .dac_nids = alc260_dac_nids,
4629 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4630 .adc_nids = alc260_dual_adc_nids,
4631 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4632 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004633 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4634 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004635 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004636 [ALC260_WILL] = {
4637 .mixers = { alc260_will_mixer,
4638 alc260_capture_mixer },
4639 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4640 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4641 .dac_nids = alc260_dac_nids,
4642 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4643 .adc_nids = alc260_adc_nids,
4644 .dig_out_nid = ALC260_DIGOUT_NID,
4645 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4646 .channel_mode = alc260_modes,
4647 .input_mux = &alc260_capture_source,
4648 },
4649 [ALC260_REPLACER_672V] = {
4650 .mixers = { alc260_replacer_672v_mixer,
4651 alc260_capture_mixer },
4652 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4653 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4654 .dac_nids = alc260_dac_nids,
4655 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4656 .adc_nids = alc260_adc_nids,
4657 .dig_out_nid = ALC260_DIGOUT_NID,
4658 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4659 .channel_mode = alc260_modes,
4660 .input_mux = &alc260_capture_source,
4661 .unsol_event = alc260_replacer_672v_unsol_event,
4662 .init_hook = alc260_replacer_672v_automute,
4663 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004664#ifdef CONFIG_SND_DEBUG
4665 [ALC260_TEST] = {
4666 .mixers = { alc260_test_mixer,
4667 alc260_capture_mixer },
4668 .init_verbs = { alc260_test_init_verbs },
4669 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4670 .dac_nids = alc260_test_dac_nids,
4671 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4672 .adc_nids = alc260_test_adc_nids,
4673 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4674 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004675 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4676 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004677 },
4678#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004679};
4680
Linus Torvalds1da177e2005-04-16 15:20:36 -07004681static int patch_alc260(struct hda_codec *codec)
4682{
4683 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004684 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004685
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004686 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004687 if (spec == NULL)
4688 return -ENOMEM;
4689
4690 codec->spec = spec;
4691
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004692 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4693 alc260_models,
4694 alc260_cfg_tbl);
4695 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004696 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4697 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004698 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004699 }
4700
Kailang Yangdf694da2005-12-05 19:42:22 +01004701 if (board_config == ALC260_AUTO) {
4702 /* automatic parse from the BIOS config */
4703 err = alc260_parse_auto_config(codec);
4704 if (err < 0) {
4705 alc_free(codec);
4706 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004707 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004708 printk(KERN_INFO
4709 "hda_codec: Cannot set up configuration "
4710 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004711 board_config = ALC260_BASIC;
4712 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004713 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004714
Kailang Yangdf694da2005-12-05 19:42:22 +01004715 if (board_config != ALC260_AUTO)
4716 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004717
4718 spec->stream_name_analog = "ALC260 Analog";
4719 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4720 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4721
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004722 spec->stream_name_digital = "ALC260 Digital";
4723 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4724 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4725
Linus Torvalds1da177e2005-04-16 15:20:36 -07004726 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004727 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004728 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004729
4730 return 0;
4731}
4732
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004733
Linus Torvalds1da177e2005-04-16 15:20:36 -07004734/*
4735 * ALC882 support
4736 *
4737 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4738 * configuration. Each pin widget can choose any input DACs and a mixer.
4739 * Each ADC is connected from a mixer of all inputs. This makes possible
4740 * 6-channel independent captures.
4741 *
4742 * In addition, an independent DAC for the multi-playback (not used in this
4743 * driver yet).
4744 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004745#define ALC882_DIGOUT_NID 0x06
4746#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004747
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004748static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004749 { 8, NULL }
4750};
4751
4752static hda_nid_t alc882_dac_nids[4] = {
4753 /* front, rear, clfe, rear_surr */
4754 0x02, 0x03, 0x04, 0x05
4755};
4756
Kailang Yangdf694da2005-12-05 19:42:22 +01004757/* identical with ALC880 */
4758#define alc882_adc_nids alc880_adc_nids
4759#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004760
4761/* input MUX */
4762/* FIXME: should be a matrix-type input source selection */
4763
4764static struct hda_input_mux alc882_capture_source = {
4765 .num_items = 4,
4766 .items = {
4767 { "Mic", 0x0 },
4768 { "Front Mic", 0x1 },
4769 { "Line", 0x2 },
4770 { "CD", 0x4 },
4771 },
4772};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004773#define alc882_mux_enum_info alc_mux_enum_info
4774#define alc882_mux_enum_get alc_mux_enum_get
4775
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004776static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4777 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004778{
4779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4780 struct alc_spec *spec = codec->spec;
4781 const struct hda_input_mux *imux = spec->input_mux;
4782 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4783 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4784 hda_nid_t nid = capture_mixers[adc_idx];
4785 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4786 unsigned int i, idx;
4787
4788 idx = ucontrol->value.enumerated.item[0];
4789 if (idx >= imux->num_items)
4790 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004791 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004792 return 0;
4793 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004794 unsigned int v = (i == idx) ? 0x00 : 0x80;
4795 snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT,
4796 imux->items[i].index,
4797 0x80, v);
4798 snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT,
4799 imux->items[i].index,
4800 0x80, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004801 }
4802 *cur_val = idx;
4803 return 1;
4804}
4805
Kailang Yangdf694da2005-12-05 19:42:22 +01004806/*
Kailang Yang272a5272007-05-14 11:00:38 +02004807 * 2ch mode
4808 */
4809static struct hda_verb alc882_3ST_ch2_init[] = {
4810 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4811 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4812 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4813 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4814 { } /* end */
4815};
4816
4817/*
4818 * 6ch mode
4819 */
4820static struct hda_verb alc882_3ST_ch6_init[] = {
4821 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4822 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4823 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4824 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4825 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4826 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4827 { } /* end */
4828};
4829
4830static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4831 { 2, alc882_3ST_ch2_init },
4832 { 6, alc882_3ST_ch6_init },
4833};
4834
4835/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004836 * 6ch mode
4837 */
4838static struct hda_verb alc882_sixstack_ch6_init[] = {
4839 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4840 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4841 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4842 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4843 { } /* end */
4844};
4845
4846/*
4847 * 8ch mode
4848 */
4849static struct hda_verb alc882_sixstack_ch8_init[] = {
4850 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4851 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4852 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4853 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4854 { } /* end */
4855};
4856
4857static struct hda_channel_mode alc882_sixstack_modes[2] = {
4858 { 6, alc882_sixstack_ch6_init },
4859 { 8, alc882_sixstack_ch8_init },
4860};
4861
Linus Torvalds1da177e2005-04-16 15:20:36 -07004862/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4863 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4864 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004865static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004867 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004868 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004869 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004870 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4871 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004872 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4873 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004874 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004875 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004876 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004882 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4884 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004885 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004886 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, 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),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004889 { } /* end */
4890};
4891
Kailang Yangbdd148a2007-05-08 15:19:08 +02004892static struct snd_kcontrol_new alc882_w2jc_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_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4896 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4897 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4898 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4900 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4902 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4903 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4904 { } /* end */
4905};
4906
Kailang Yang272a5272007-05-14 11:00:38 +02004907static struct snd_kcontrol_new alc882_targa_mixer[] = {
4908 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4909 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4910 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4911 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4912 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4913 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4914 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4915 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4919 { } /* end */
4920};
4921
4922/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4923 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4924 */
4925static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4926 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4927 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4929 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4930 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4931 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4934 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4935 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4938 { } /* end */
4939};
4940
Kailang Yangdf694da2005-12-05 19:42:22 +01004941static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4942 {
4943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4944 .name = "Channel Mode",
4945 .info = alc_ch_mode_info,
4946 .get = alc_ch_mode_get,
4947 .put = alc_ch_mode_put,
4948 },
4949 { } /* end */
4950};
4951
Linus Torvalds1da177e2005-04-16 15:20:36 -07004952static struct hda_verb alc882_init_verbs[] = {
4953 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004957 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004958 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004961 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004965 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004966 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4967 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4968 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004969
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004970 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004973 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004974 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004977 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004978 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004980 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004981 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004983 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004985 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004986 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004987 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4989 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004990 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4992 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004993 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004994 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4995 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4996 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4997 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4998 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004999 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005000 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005001
5002 /* FIXME: use matrix-type input source selection */
5003 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5004 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005005 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5006 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5007 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5008 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005009 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005010 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5011 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5012 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5013 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005014 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005015 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5016 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5019 /* ADC1: mute amp left and right */
5020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005021 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005022 /* ADC2: mute amp left and right */
5023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005024 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005025 /* ADC3: mute amp left and right */
5026 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005027 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005028
5029 { }
5030};
5031
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005032static struct hda_verb alc882_eapd_verbs[] = {
5033 /* change to EAPD mode */
5034 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005035 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005036 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005037};
5038
Tobin Davis9102cd12006-12-15 10:02:12 +01005039/* Mac Pro test */
5040static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5043 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5046 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5047 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5048 { } /* end */
5049};
5050
5051static struct hda_verb alc882_macpro_init_verbs[] = {
5052 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5056 /* Front Pin: output 0 (0x0c) */
5057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5059 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5060 /* Front Mic pin: input vref at 80% */
5061 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5063 /* Speaker: output */
5064 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5065 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5066 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5067 /* Headphone output (output 0 - 0x0c) */
5068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5070 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5071
5072 /* FIXME: use matrix-type input source selection */
5073 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5074 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5075 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5076 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5077 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5078 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5079 /* Input mixer2 */
5080 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5081 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5084 /* Input mixer3 */
5085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5089 /* ADC1: mute amp left and right */
5090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5091 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5092 /* ADC2: mute amp left and right */
5093 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5094 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5095 /* ADC3: mute amp left and right */
5096 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5097 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5098
5099 { }
5100};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005101
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005102/* iMac 24 mixer. */
5103static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5104 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5105 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5106 { } /* end */
5107};
5108
5109/* iMac 24 init verbs. */
5110static struct hda_verb alc885_imac24_init_verbs[] = {
5111 /* Internal speakers: output 0 (0x0c) */
5112 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5113 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5114 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5115 /* Internal speakers: output 0 (0x0c) */
5116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5118 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5119 /* Headphone: output 0 (0x0c) */
5120 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5121 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5122 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5123 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5124 /* Front Mic: input vref at 80% */
5125 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5126 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5127 { }
5128};
5129
5130/* Toggle speaker-output according to the hp-jack state */
5131static void alc885_imac24_automute(struct hda_codec *codec)
5132{
5133 unsigned int present;
5134
5135 present = snd_hda_codec_read(codec, 0x14, 0,
5136 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5137 snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
5138 0x80, present ? 0x80 : 0);
5139 snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
5140 0x80, present ? 0x80 : 0);
5141 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
5142 0x80, present ? 0x80 : 0);
5143 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
5144 0x80, present ? 0x80 : 0);
5145}
5146
5147/* Processes unsolicited events. */
5148static void alc885_imac24_unsol_event(struct hda_codec *codec,
5149 unsigned int res)
5150{
5151 /* Headphone insertion or removal. */
5152 if ((res >> 26) == ALC880_HP_EVENT)
5153 alc885_imac24_automute(codec);
5154}
5155
Kailang Yang272a5272007-05-14 11:00:38 +02005156static struct hda_verb alc882_targa_verbs[] = {
5157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5159
5160 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5161 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5162
5163 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5164 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5165 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5166
5167 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5168 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5169 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5170 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5171 { } /* end */
5172};
5173
5174/* toggle speaker-output according to the hp-jack state */
5175static void alc882_targa_automute(struct hda_codec *codec)
5176{
5177 unsigned int present;
5178
5179 present = snd_hda_codec_read(codec, 0x14, 0,
5180 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5181 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5182 0x80, present ? 0x80 : 0);
5183 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5184 0x80, present ? 0x80 : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005185 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5186 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005187}
5188
5189static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5190{
5191 /* Looks like the unsol event is incompatible with the standard
5192 * definition. 4bit tag is placed at 26 bit!
5193 */
5194 if (((res >> 26) == ALC880_HP_EVENT)) {
5195 alc882_targa_automute(codec);
5196 }
5197}
5198
5199static struct hda_verb alc882_asus_a7j_verbs[] = {
5200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5202
5203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5204 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5205 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5206
5207 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5208 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5209 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5210
5211 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5212 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5213 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5214 { } /* end */
5215};
5216
Tobin Davis9102cd12006-12-15 10:02:12 +01005217static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5218{
5219 unsigned int gpiostate, gpiomask, gpiodir;
5220
5221 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5222 AC_VERB_GET_GPIO_DATA, 0);
5223
5224 if (!muted)
5225 gpiostate |= (1 << pin);
5226 else
5227 gpiostate &= ~(1 << pin);
5228
5229 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5230 AC_VERB_GET_GPIO_MASK, 0);
5231 gpiomask |= (1 << pin);
5232
5233 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5234 AC_VERB_GET_GPIO_DIRECTION, 0);
5235 gpiodir |= (1 << pin);
5236
5237
5238 snd_hda_codec_write(codec, codec->afg, 0,
5239 AC_VERB_SET_GPIO_MASK, gpiomask);
5240 snd_hda_codec_write(codec, codec->afg, 0,
5241 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5242
5243 msleep(1);
5244
5245 snd_hda_codec_write(codec, codec->afg, 0,
5246 AC_VERB_SET_GPIO_DATA, gpiostate);
5247}
5248
Kailang Yangdf694da2005-12-05 19:42:22 +01005249/*
5250 * generic initialization of ADC, input mixers and output mixers
5251 */
5252static struct hda_verb alc882_auto_init_verbs[] = {
5253 /*
5254 * Unmute ADC0-2 and set the default input to mic-in
5255 */
5256 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5258 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5260 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5261 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5262
5263 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5264 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005265 * Note: PASD motherboards uses the Line In 2 as the input for
5266 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005267 */
5268 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5270 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5271 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5274
5275 /*
5276 * Set up output mixers (0x0c - 0x0f)
5277 */
5278 /* set vol=0 to output mixers */
5279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5283 /* set up input amps for analog loopback */
5284 /* Amp Indices: DAC = 0, mixer = 1 */
5285 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5286 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5287 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5288 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5290 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5292 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5293 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5294 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5295
5296 /* FIXME: use matrix-type input source selection */
5297 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5298 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5303 /* Input mixer2 */
5304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5308 /* Input mixer3 */
5309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5313
5314 { }
5315};
5316
5317/* capture mixer elements */
5318static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5319 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5320 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5321 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5322 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5323 {
5324 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5325 /* The multiple "Capture Source" controls confuse alsamixer
5326 * So call somewhat different..
5327 * FIXME: the controls appear in the "playback" view!
5328 */
5329 /* .name = "Capture Source", */
5330 .name = "Input Source",
5331 .count = 2,
5332 .info = alc882_mux_enum_info,
5333 .get = alc882_mux_enum_get,
5334 .put = alc882_mux_enum_put,
5335 },
5336 { } /* end */
5337};
5338
5339static struct snd_kcontrol_new alc882_capture_mixer[] = {
5340 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5341 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5342 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5343 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5344 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5345 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5346 {
5347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5348 /* The multiple "Capture Source" controls confuse alsamixer
5349 * So call somewhat different..
5350 * FIXME: the controls appear in the "playback" view!
5351 */
5352 /* .name = "Capture Source", */
5353 .name = "Input Source",
5354 .count = 3,
5355 .info = alc882_mux_enum_info,
5356 .get = alc882_mux_enum_get,
5357 .put = alc882_mux_enum_put,
5358 },
5359 { } /* end */
5360};
5361
5362/* pcm configuration: identiacal with ALC880 */
5363#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5364#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5365#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5366#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5367
5368/*
5369 * configuration and preset
5370 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005371static const char *alc882_models[ALC882_MODEL_LAST] = {
5372 [ALC882_3ST_DIG] = "3stack-dig",
5373 [ALC882_6ST_DIG] = "6stack-dig",
5374 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005375 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005376 [ALC885_MACPRO] = "macpro",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005377 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005378 [ALC882_AUTO] = "auto",
5379};
5380
5381static struct snd_pci_quirk alc882_cfg_tbl[] = {
5382 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5383 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5384 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005385 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005386 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005387 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005388 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005389 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005390 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005391 {}
5392};
5393
5394static struct alc_config_preset alc882_presets[] = {
5395 [ALC882_3ST_DIG] = {
5396 .mixers = { alc882_base_mixer },
5397 .init_verbs = { alc882_init_verbs },
5398 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5399 .dac_nids = alc882_dac_nids,
5400 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005401 .dig_in_nid = ALC882_DIGIN_NID,
5402 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5403 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005404 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005405 .input_mux = &alc882_capture_source,
5406 },
5407 [ALC882_6ST_DIG] = {
5408 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5409 .init_verbs = { alc882_init_verbs },
5410 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5411 .dac_nids = alc882_dac_nids,
5412 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005413 .dig_in_nid = ALC882_DIGIN_NID,
5414 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5415 .channel_mode = alc882_sixstack_modes,
5416 .input_mux = &alc882_capture_source,
5417 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005418 [ALC882_ARIMA] = {
5419 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5420 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5421 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5422 .dac_nids = alc882_dac_nids,
5423 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5424 .channel_mode = alc882_sixstack_modes,
5425 .input_mux = &alc882_capture_source,
5426 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005427 [ALC882_W2JC] = {
5428 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5429 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5430 alc880_gpio1_init_verbs },
5431 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5432 .dac_nids = alc882_dac_nids,
5433 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5434 .channel_mode = alc880_threestack_modes,
5435 .need_dac_fix = 1,
5436 .input_mux = &alc882_capture_source,
5437 .dig_out_nid = ALC882_DIGOUT_NID,
5438 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005439 [ALC885_MACPRO] = {
5440 .mixers = { alc882_macpro_mixer },
5441 .init_verbs = { alc882_macpro_init_verbs },
5442 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5443 .dac_nids = alc882_dac_nids,
5444 .dig_out_nid = ALC882_DIGOUT_NID,
5445 .dig_in_nid = ALC882_DIGIN_NID,
5446 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5447 .channel_mode = alc882_ch_modes,
5448 .input_mux = &alc882_capture_source,
5449 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005450 [ALC885_IMAC24] = {
5451 .mixers = { alc885_imac24_mixer },
5452 .init_verbs = { alc885_imac24_init_verbs },
5453 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5454 .dac_nids = alc882_dac_nids,
5455 .dig_out_nid = ALC882_DIGOUT_NID,
5456 .dig_in_nid = ALC882_DIGIN_NID,
5457 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5458 .channel_mode = alc882_ch_modes,
5459 .input_mux = &alc882_capture_source,
5460 .unsol_event = alc885_imac24_unsol_event,
5461 .init_hook = alc885_imac24_automute,
5462 },
Kailang Yang272a5272007-05-14 11:00:38 +02005463 [ALC882_TARGA] = {
5464 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5465 alc882_capture_mixer },
5466 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5467 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5468 .dac_nids = alc882_dac_nids,
5469 .dig_out_nid = ALC882_DIGOUT_NID,
5470 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5471 .adc_nids = alc882_adc_nids,
5472 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5473 .channel_mode = alc882_3ST_6ch_modes,
5474 .need_dac_fix = 1,
5475 .input_mux = &alc882_capture_source,
5476 .unsol_event = alc882_targa_unsol_event,
5477 .init_hook = alc882_targa_automute,
5478 },
5479 [ALC882_ASUS_A7J] = {
5480 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5481 alc882_capture_mixer },
5482 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5483 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5484 .dac_nids = alc882_dac_nids,
5485 .dig_out_nid = ALC882_DIGOUT_NID,
5486 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5487 .adc_nids = alc882_adc_nids,
5488 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5489 .channel_mode = alc882_3ST_6ch_modes,
5490 .need_dac_fix = 1,
5491 .input_mux = &alc882_capture_source,
5492 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005493};
5494
5495
5496/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005497 * Pin config fixes
5498 */
5499enum {
5500 PINFIX_ABIT_AW9D_MAX
5501};
5502
5503static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5504 { 0x15, 0x01080104 }, /* side */
5505 { 0x16, 0x01011012 }, /* rear */
5506 { 0x17, 0x01016011 }, /* clfe */
5507 { }
5508};
5509
5510static const struct alc_pincfg *alc882_pin_fixes[] = {
5511 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5512};
5513
5514static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5515 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5516 {}
5517};
5518
5519/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005520 * BIOS auto configuration
5521 */
5522static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5523 hda_nid_t nid, int pin_type,
5524 int dac_idx)
5525{
5526 /* set as output */
5527 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005528 int idx;
5529
Kailang Yangdf694da2005-12-05 19:42:22 +01005530 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5531 idx = 4;
5532 else
5533 idx = spec->multiout.dac_nids[dac_idx] - 2;
5534
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005535 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5536 pin_type);
5537 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5538 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005539 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5540
5541}
5542
5543static void alc882_auto_init_multi_out(struct hda_codec *codec)
5544{
5545 struct alc_spec *spec = codec->spec;
5546 int i;
5547
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005548 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005549 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005550 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005551 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005552 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005553 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005554 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005555 }
5556}
5557
5558static void alc882_auto_init_hp_out(struct hda_codec *codec)
5559{
5560 struct alc_spec *spec = codec->spec;
5561 hda_nid_t pin;
5562
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005563 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005564 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005565 /* use dac 0 */
5566 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005567}
5568
5569#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5570#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5571
5572static void alc882_auto_init_analog_input(struct hda_codec *codec)
5573{
5574 struct alc_spec *spec = codec->spec;
5575 int i;
5576
5577 for (i = 0; i < AUTO_PIN_LAST; i++) {
5578 hda_nid_t nid = spec->autocfg.input_pins[i];
5579 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005580 snd_hda_codec_write(codec, nid, 0,
5581 AC_VERB_SET_PIN_WIDGET_CONTROL,
5582 i <= AUTO_PIN_FRONT_MIC ?
5583 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005584 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005585 snd_hda_codec_write(codec, nid, 0,
5586 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005587 AMP_OUT_MUTE);
5588 }
5589 }
5590}
5591
5592/* almost identical with ALC880 parser... */
5593static int alc882_parse_auto_config(struct hda_codec *codec)
5594{
5595 struct alc_spec *spec = codec->spec;
5596 int err = alc880_parse_auto_config(codec);
5597
5598 if (err < 0)
5599 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005600 else if (err > 0)
5601 /* hack - override the init verbs */
5602 spec->init_verbs[0] = alc882_auto_init_verbs;
5603 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005604}
5605
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005606/* additional initialization for auto-configuration model */
5607static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005608{
Kailang Yangdf694da2005-12-05 19:42:22 +01005609 alc882_auto_init_multi_out(codec);
5610 alc882_auto_init_hp_out(codec);
5611 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005612}
5613
Linus Torvalds1da177e2005-04-16 15:20:36 -07005614static int patch_alc882(struct hda_codec *codec)
5615{
5616 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005617 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005618
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005619 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005620 if (spec == NULL)
5621 return -ENOMEM;
5622
Linus Torvalds1da177e2005-04-16 15:20:36 -07005623 codec->spec = spec;
5624
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005625 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5626 alc882_models,
5627 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005628
Kailang Yangdf694da2005-12-05 19:42:22 +01005629 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005630 /* Pick up systems that don't supply PCI SSID */
5631 switch (codec->subsystem_id) {
5632 case 0x106b0c00: /* Mac Pro */
5633 board_config = ALC885_MACPRO;
5634 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005635 case 0x106b1000: /* iMac 24 */
5636 board_config = ALC885_IMAC24;
5637 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01005638 default:
5639 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5640 "trying auto-probe from BIOS...\n");
5641 board_config = ALC882_AUTO;
5642 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005643 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005644
Takashi Iwaif95474e2007-07-10 00:47:43 +02005645 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5646
Kailang Yangdf694da2005-12-05 19:42:22 +01005647 if (board_config == ALC882_AUTO) {
5648 /* automatic parse from the BIOS config */
5649 err = alc882_parse_auto_config(codec);
5650 if (err < 0) {
5651 alc_free(codec);
5652 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005653 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005654 printk(KERN_INFO
5655 "hda_codec: Cannot set up configuration "
5656 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005657 board_config = ALC882_3ST_DIG;
5658 }
5659 }
5660
5661 if (board_config != ALC882_AUTO)
5662 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005663
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005664 if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
Tobin Davis9102cd12006-12-15 10:02:12 +01005665 alc882_gpio_mute(codec, 0, 0);
5666 alc882_gpio_mute(codec, 1, 0);
5667 }
5668
Linus Torvalds1da177e2005-04-16 15:20:36 -07005669 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005670 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5671 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005672
5673 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005674 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5675 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005676
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005677 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005678 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005679 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005680 /* get type */
5681 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005682 if (wcap != AC_WID_AUD_IN) {
5683 spec->adc_nids = alc882_adc_nids_alt;
5684 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005685 spec->mixers[spec->num_mixers] =
5686 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005687 spec->num_mixers++;
5688 } else {
5689 spec->adc_nids = alc882_adc_nids;
5690 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5691 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5692 spec->num_mixers++;
5693 }
5694 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005695
5696 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005697 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005698 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005699
5700 return 0;
5701}
5702
5703/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005704 * ALC883 support
5705 *
5706 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5707 * configuration. Each pin widget can choose any input DACs and a mixer.
5708 * Each ADC is connected from a mixer of all inputs. This makes possible
5709 * 6-channel independent captures.
5710 *
5711 * In addition, an independent DAC for the multi-playback (not used in this
5712 * driver yet).
5713 */
5714#define ALC883_DIGOUT_NID 0x06
5715#define ALC883_DIGIN_NID 0x0a
5716
5717static hda_nid_t alc883_dac_nids[4] = {
5718 /* front, rear, clfe, rear_surr */
5719 0x02, 0x04, 0x03, 0x05
5720};
5721
5722static hda_nid_t alc883_adc_nids[2] = {
5723 /* ADC1-2 */
5724 0x08, 0x09,
5725};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005726
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005727/* input MUX */
5728/* FIXME: should be a matrix-type input source selection */
5729
5730static struct hda_input_mux alc883_capture_source = {
5731 .num_items = 4,
5732 .items = {
5733 { "Mic", 0x0 },
5734 { "Front Mic", 0x1 },
5735 { "Line", 0x2 },
5736 { "CD", 0x4 },
5737 },
5738};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005739
5740static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5741 .num_items = 2,
5742 .items = {
5743 { "Mic", 0x1 },
5744 { "Line", 0x2 },
5745 },
5746};
5747
Kailang Yang272a5272007-05-14 11:00:38 +02005748static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5749 .num_items = 4,
5750 .items = {
5751 { "Mic", 0x0 },
5752 { "iMic", 0x1 },
5753 { "Line", 0x2 },
5754 { "CD", 0x4 },
5755 },
5756};
5757
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005758#define alc883_mux_enum_info alc_mux_enum_info
5759#define alc883_mux_enum_get alc_mux_enum_get
5760
5761static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5762 struct snd_ctl_elem_value *ucontrol)
5763{
5764 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5765 struct alc_spec *spec = codec->spec;
5766 const struct hda_input_mux *imux = spec->input_mux;
5767 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5768 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5769 hda_nid_t nid = capture_mixers[adc_idx];
5770 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5771 unsigned int i, idx;
5772
5773 idx = ucontrol->value.enumerated.item[0];
5774 if (idx >= imux->num_items)
5775 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005776 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005777 return 0;
5778 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005779 unsigned int v = (i == idx) ? 0x00 : 0x80;
5780 snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT,
5781 imux->items[i].index,
5782 0x80, v);
5783 snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT,
5784 imux->items[i].index,
5785 0x80, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005786 }
5787 *cur_val = idx;
5788 return 1;
5789}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005790
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005791/*
5792 * 2ch mode
5793 */
5794static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5795 { 2, NULL }
5796};
5797
5798/*
5799 * 2ch mode
5800 */
5801static struct hda_verb alc883_3ST_ch2_init[] = {
5802 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5803 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5804 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5805 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5806 { } /* end */
5807};
5808
5809/*
5810 * 6ch mode
5811 */
5812static struct hda_verb alc883_3ST_ch6_init[] = {
5813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5815 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5816 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5817 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5818 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5819 { } /* end */
5820};
5821
5822static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5823 { 2, alc883_3ST_ch2_init },
5824 { 6, alc883_3ST_ch6_init },
5825};
5826
5827/*
5828 * 6ch mode
5829 */
5830static struct hda_verb alc883_sixstack_ch6_init[] = {
5831 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5832 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5833 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5834 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5835 { } /* end */
5836};
5837
5838/*
5839 * 8ch mode
5840 */
5841static struct hda_verb alc883_sixstack_ch8_init[] = {
5842 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5843 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5844 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5845 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5846 { } /* end */
5847};
5848
5849static struct hda_channel_mode alc883_sixstack_modes[2] = {
5850 { 6, alc883_sixstack_ch6_init },
5851 { 8, alc883_sixstack_ch8_init },
5852};
5853
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005854static struct hda_verb alc883_medion_eapd_verbs[] = {
5855 /* eanable EAPD on medion laptop */
5856 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5857 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5858 { }
5859};
5860
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005861/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5862 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5863 */
5864
5865static struct snd_kcontrol_new alc883_base_mixer[] = {
5866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5867 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5868 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5869 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5870 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5871 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5872 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5873 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5874 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5875 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5876 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005882 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5884 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005885 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005886 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5887 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5888 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5889 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5890 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5891 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5892 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5893 {
5894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5895 /* .name = "Capture Source", */
5896 .name = "Input Source",
5897 .count = 2,
5898 .info = alc883_mux_enum_info,
5899 .get = alc883_mux_enum_get,
5900 .put = alc883_mux_enum_put,
5901 },
5902 { } /* end */
5903};
5904
5905static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5909 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5910 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005914 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005917 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5919 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5920 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5921 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5922 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5923 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5924 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5925 {
5926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5927 /* .name = "Capture Source", */
5928 .name = "Input Source",
5929 .count = 2,
5930 .info = alc883_mux_enum_info,
5931 .get = alc883_mux_enum_get,
5932 .put = alc883_mux_enum_put,
5933 },
5934 { } /* end */
5935};
5936
5937static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5938 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5939 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5940 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5941 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5942 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5943 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5944 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5945 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005952 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5954 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005955 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005956 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5957 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5958 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5959 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5960 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5961 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5962 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5963 {
5964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5965 /* .name = "Capture Source", */
5966 .name = "Input Source",
5967 .count = 2,
5968 .info = alc883_mux_enum_info,
5969 .get = alc883_mux_enum_get,
5970 .put = alc883_mux_enum_put,
5971 },
5972 { } /* end */
5973};
5974
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005975static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005976 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5977 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5978 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5979 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5980 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5981 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5982 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5983 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5984 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005990 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5992 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005993 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005994 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5995 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5996 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5997 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5998 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5999
6000 {
6001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6002 /* .name = "Capture Source", */
6003 .name = "Input Source",
6004 .count = 1,
6005 .info = alc883_mux_enum_info,
6006 .get = alc883_mux_enum_get,
6007 .put = alc883_mux_enum_put,
6008 },
6009 { } /* end */
6010};
6011
Kailang Yangccc656c2006-10-17 12:32:26 +02006012static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6013 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6015 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6016 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6017 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6018 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6019 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6020 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6021 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6022 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6023 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6026 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6029 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6030 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6031 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6032 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6033 {
6034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6035 /* .name = "Capture Source", */
6036 .name = "Input Source",
6037 .count = 2,
6038 .info = alc883_mux_enum_info,
6039 .get = alc883_mux_enum_get,
6040 .put = alc883_mux_enum_put,
6041 },
6042 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006043};
Kailang Yangccc656c2006-10-17 12:32:26 +02006044
6045static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6046 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6048 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6049 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6050 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6054 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6055 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6056 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6057 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6058 {
6059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6060 /* .name = "Capture Source", */
6061 .name = "Input Source",
6062 .count = 2,
6063 .info = alc883_mux_enum_info,
6064 .get = alc883_mux_enum_get,
6065 .put = alc883_mux_enum_put,
6066 },
6067 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006068};
Kailang Yangccc656c2006-10-17 12:32:26 +02006069
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006070static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6071 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6072 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6073 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6074 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6079 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6080 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6081 {
6082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6083 /* .name = "Capture Source", */
6084 .name = "Input Source",
6085 .count = 1,
6086 .info = alc883_mux_enum_info,
6087 .get = alc883_mux_enum_get,
6088 .put = alc883_mux_enum_put,
6089 },
6090 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006091};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006092
Kailang Yang272a5272007-05-14 11:00:38 +02006093static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6094 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6095 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6101 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6102 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6103 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6104 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6105 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6106 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6107 {
6108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6109 /* .name = "Capture Source", */
6110 .name = "Input Source",
6111 .count = 2,
6112 .info = alc883_mux_enum_info,
6113 .get = alc883_mux_enum_get,
6114 .put = alc883_mux_enum_put,
6115 },
6116 { } /* end */
6117};
6118
6119static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6122 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6129 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6130 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6131 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6132 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6133 {
6134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6135 /* .name = "Capture Source", */
6136 .name = "Input Source",
6137 .count = 2,
6138 .info = alc883_mux_enum_info,
6139 .get = alc883_mux_enum_get,
6140 .put = alc883_mux_enum_put,
6141 },
6142 { } /* end */
6143};
6144
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006145static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6147 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6148 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6149 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6150 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6152 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6153 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6154 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6155 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6157 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6158 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6160 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6165 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6166 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6167 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6168 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6169 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6170 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6171 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6172 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6173 {
6174 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6175 /* .name = "Capture Source", */
6176 .name = "Input Source",
6177 .count = 2,
6178 .info = alc883_mux_enum_info,
6179 .get = alc883_mux_enum_get,
6180 .put = alc883_mux_enum_put,
6181 },
6182 { } /* end */
6183};
6184
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006185static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006186 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6187 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6188 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6189 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6190 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6191 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6192 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6193 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6195 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6196 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6200 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6203 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6205 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6206 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6207 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6208 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6209 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6210 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6211 {
6212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6213 /* .name = "Capture Source", */
6214 .name = "Input Source",
6215 .count = 2,
6216 .info = alc883_mux_enum_info,
6217 .get = alc883_mux_enum_get,
6218 .put = alc883_mux_enum_put,
6219 },
6220 { } /* end */
6221};
6222
Tobin Davis2880a862007-08-07 11:50:26 +02006223static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6225 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6232 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6233 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6234 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6235 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6236 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6237 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6238 {
6239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6240 /* .name = "Capture Source", */
6241 .name = "Input Source",
6242 .count = 2,
6243 .info = alc883_mux_enum_info,
6244 .get = alc883_mux_enum_get,
6245 .put = alc883_mux_enum_put,
6246 },
6247 { } /* end */
6248};
6249
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006250static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6251 {
6252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6253 .name = "Channel Mode",
6254 .info = alc_ch_mode_info,
6255 .get = alc_ch_mode_get,
6256 .put = alc_ch_mode_put,
6257 },
6258 { } /* end */
6259};
6260
6261static struct hda_verb alc883_init_verbs[] = {
6262 /* ADC1: mute amp left and right */
6263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6265 /* ADC2: mute amp left and right */
6266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6267 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6268 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6270 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6272 /* Rear mixer */
6273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6275 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6276 /* CLFE mixer */
6277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6279 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6280 /* Side mixer */
6281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6284
6285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6290
6291 /* Front Pin: output 0 (0x0c) */
6292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6294 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6295 /* Rear Pin: output 1 (0x0d) */
6296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6299 /* CLFE Pin: output 2 (0x0e) */
6300 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6301 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6302 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6303 /* Side Pin: output 3 (0x0f) */
6304 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6305 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6306 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6307 /* Mic (rear) pin: input vref at 80% */
6308 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6310 /* Front Mic pin: input vref at 80% */
6311 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6313 /* Line In pin: input */
6314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6316 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6319 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6320 /* CD pin widget for input */
6321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6322
6323 /* FIXME: use matrix-type input source selection */
6324 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6325 /* Input mixer2 */
6326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6330 /* Input mixer3 */
6331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6335 { }
6336};
6337
Kailang Yangccc656c2006-10-17 12:32:26 +02006338static struct hda_verb alc883_tagra_verbs[] = {
6339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6341
6342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6343 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6344
6345 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6346 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6347 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6348
6349 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006350 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6351 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6352 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006353
6354 { } /* end */
6355};
6356
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006357static struct hda_verb alc883_lenovo_101e_verbs[] = {
6358 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6359 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6360 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6361 { } /* end */
6362};
6363
Kailang Yang272a5272007-05-14 11:00:38 +02006364static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6365 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6367 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6368 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6369 { } /* end */
6370};
6371
6372static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6375 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6376 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6377 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6378 { } /* end */
6379};
6380
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006381static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006382 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6384 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6385 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6386 { }
6387};
6388
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006389static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006390 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6391 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6392 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6393 { }
6394};
6395
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006396static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006397 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6398 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6399 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6400 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6401 { }
6402};
6403
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006404static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006405 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6406 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6407 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6408 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6409 { }
6410};
6411
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006412static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6413 { 2, alc888_3st_hp_2ch_init },
6414 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006415};
6416
Kailang Yang272a5272007-05-14 11:00:38 +02006417/* toggle front-jack and RCA according to the hp-jack state */
6418static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6419{
6420 unsigned int present;
6421
6422 present = snd_hda_codec_read(codec, 0x1b, 0,
6423 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6424 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6425 0x80, present ? 0x80 : 0);
6426 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6427 0x80, present ? 0x80 : 0);
6428 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6429 0x80, present ? 0x80 : 0);
6430 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6431 0x80, present ? 0x80 : 0);
6432
6433}
6434
6435/* toggle RCA according to the front-jack state */
6436static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6437{
6438 unsigned int present;
6439
6440 present = snd_hda_codec_read(codec, 0x14, 0,
6441 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6442 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6443 0x80, present ? 0x80 : 0);
6444 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6445 0x80, present ? 0x80 : 0);
6446
6447}
6448static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6449 unsigned int res)
6450{
6451 if ((res >> 26) == ALC880_HP_EVENT)
6452 alc888_lenovo_ms7195_front_automute(codec);
6453 if ((res >> 26) == ALC880_FRONT_EVENT)
6454 alc888_lenovo_ms7195_rca_automute(codec);
6455}
6456
6457static struct hda_verb alc883_medion_md2_verbs[] = {
6458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6460
6461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6462
6463 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6464 { } /* end */
6465};
6466
Tobin Davis2880a862007-08-07 11:50:26 +02006467static struct hda_verb alc883_acer_aspire_verbs[] = {
6468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6472
6473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6474
6475 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6476 { } /* end */
6477};
6478
Kailang Yang272a5272007-05-14 11:00:38 +02006479/* toggle speaker-output according to the hp-jack state */
6480static void alc883_medion_md2_automute(struct hda_codec *codec)
6481{
6482 unsigned int present;
6483
6484 present = snd_hda_codec_read(codec, 0x14, 0,
6485 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6486 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6487 0x80, present ? 0x80 : 0);
6488 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6489 0x80, present ? 0x80 : 0);
6490}
6491
6492static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6493 unsigned int res)
6494{
6495 if ((res >> 26) == ALC880_HP_EVENT)
6496 alc883_medion_md2_automute(codec);
6497}
6498
Kailang Yangccc656c2006-10-17 12:32:26 +02006499/* toggle speaker-output according to the hp-jack state */
6500static void alc883_tagra_automute(struct hda_codec *codec)
6501{
6502 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006503 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006504
6505 present = snd_hda_codec_read(codec, 0x14, 0,
6506 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006507 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006508 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006509 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006510 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006511 0x80, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006512 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6513 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006514}
6515
6516static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6517{
6518 if ((res >> 26) == ALC880_HP_EVENT)
6519 alc883_tagra_automute(codec);
6520}
6521
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006522static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6523{
6524 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006525 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006526
6527 present = snd_hda_codec_read(codec, 0x14, 0,
6528 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006529 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006530 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006531 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006532 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006533 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006534}
6535
6536static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6537{
6538 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006539 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006540
6541 present = snd_hda_codec_read(codec, 0x1b, 0,
6542 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006543 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006544 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006545 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006546 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006547 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006548 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006549 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006550 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006551 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006552}
6553
6554static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6555 unsigned int res)
6556{
6557 if ((res >> 26) == ALC880_HP_EVENT)
6558 alc883_lenovo_101e_all_automute(codec);
6559 if ((res >> 26) == ALC880_FRONT_EVENT)
6560 alc883_lenovo_101e_ispeaker_automute(codec);
6561}
6562
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006563/*
6564 * generic initialization of ADC, input mixers and output mixers
6565 */
6566static struct hda_verb alc883_auto_init_verbs[] = {
6567 /*
6568 * Unmute ADC0-2 and set the default input to mic-in
6569 */
6570 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6572 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6573 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6574
6575 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6576 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006577 * Note: PASD motherboards uses the Line In 2 as the input for
6578 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006579 */
6580 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6584 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6586
6587 /*
6588 * Set up output mixers (0x0c - 0x0f)
6589 */
6590 /* set vol=0 to output mixers */
6591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6595 /* set up input amps for analog loopback */
6596 /* Amp Indices: DAC = 0, mixer = 1 */
6597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6600 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6601 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6602 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6603 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6604 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6605 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6606 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6607
6608 /* FIXME: use matrix-type input source selection */
6609 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6610 /* Input mixer1 */
6611 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006614 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6616 /* Input mixer2 */
6617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006620 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006621 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6622
6623 { }
6624};
6625
6626/* capture mixer elements */
6627static struct snd_kcontrol_new alc883_capture_mixer[] = {
6628 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6629 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6630 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6631 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6632 {
6633 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6634 /* The multiple "Capture Source" controls confuse alsamixer
6635 * So call somewhat different..
6636 * FIXME: the controls appear in the "playback" view!
6637 */
6638 /* .name = "Capture Source", */
6639 .name = "Input Source",
6640 .count = 2,
6641 .info = alc882_mux_enum_info,
6642 .get = alc882_mux_enum_get,
6643 .put = alc882_mux_enum_put,
6644 },
6645 { } /* end */
6646};
6647
6648/* pcm configuration: identiacal with ALC880 */
6649#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6650#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6651#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6652#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6653
6654/*
6655 * configuration and preset
6656 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006657static const char *alc883_models[ALC883_MODEL_LAST] = {
6658 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6659 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6660 [ALC883_3ST_6ch] = "3stack-6ch",
6661 [ALC883_6ST_DIG] = "6stack-dig",
6662 [ALC883_TARGA_DIG] = "targa-dig",
6663 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006664 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02006665 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006666 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006667 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006668 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006669 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006670 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6671 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006672 [ALC888_6ST_HP] = "6stack-hp",
6673 [ALC888_3ST_HP] = "3stack-hp",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006674 [ALC883_AUTO] = "auto",
6675};
6676
6677static struct snd_pci_quirk alc883_cfg_tbl[] = {
6678 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006679 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006680 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6681 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6682 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006683 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006684 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6685 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006686 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006687 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02006688 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006689 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006690 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006691 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006692 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6693 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6694 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6695 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6696 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6697 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6698 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6699 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6700 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Tobin Davis2880a862007-08-07 11:50:26 +02006701 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006702 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006703 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006704 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6705 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6706 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006707 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6708 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6709 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006710 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6711 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6712 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
Kailang Yang272a5272007-05-14 11:00:38 +02006713 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006714 {}
6715};
6716
6717static struct alc_config_preset alc883_presets[] = {
6718 [ALC883_3ST_2ch_DIG] = {
6719 .mixers = { alc883_3ST_2ch_mixer },
6720 .init_verbs = { alc883_init_verbs },
6721 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6722 .dac_nids = alc883_dac_nids,
6723 .dig_out_nid = ALC883_DIGOUT_NID,
6724 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6725 .adc_nids = alc883_adc_nids,
6726 .dig_in_nid = ALC883_DIGIN_NID,
6727 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6728 .channel_mode = alc883_3ST_2ch_modes,
6729 .input_mux = &alc883_capture_source,
6730 },
6731 [ALC883_3ST_6ch_DIG] = {
6732 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6733 .init_verbs = { alc883_init_verbs },
6734 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6735 .dac_nids = alc883_dac_nids,
6736 .dig_out_nid = ALC883_DIGOUT_NID,
6737 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6738 .adc_nids = alc883_adc_nids,
6739 .dig_in_nid = ALC883_DIGIN_NID,
6740 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6741 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006742 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006743 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006744 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006745 [ALC883_3ST_6ch] = {
6746 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6747 .init_verbs = { alc883_init_verbs },
6748 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6749 .dac_nids = alc883_dac_nids,
6750 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6751 .adc_nids = alc883_adc_nids,
6752 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6753 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006754 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006755 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006756 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006757 [ALC883_6ST_DIG] = {
6758 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6759 .init_verbs = { alc883_init_verbs },
6760 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6761 .dac_nids = alc883_dac_nids,
6762 .dig_out_nid = ALC883_DIGOUT_NID,
6763 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6764 .adc_nids = alc883_adc_nids,
6765 .dig_in_nid = ALC883_DIGIN_NID,
6766 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6767 .channel_mode = alc883_sixstack_modes,
6768 .input_mux = &alc883_capture_source,
6769 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006770 [ALC883_TARGA_DIG] = {
6771 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6772 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6773 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6774 .dac_nids = alc883_dac_nids,
6775 .dig_out_nid = ALC883_DIGOUT_NID,
6776 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6777 .adc_nids = alc883_adc_nids,
6778 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6779 .channel_mode = alc883_3ST_6ch_modes,
6780 .need_dac_fix = 1,
6781 .input_mux = &alc883_capture_source,
6782 .unsol_event = alc883_tagra_unsol_event,
6783 .init_hook = alc883_tagra_automute,
6784 },
6785 [ALC883_TARGA_2ch_DIG] = {
6786 .mixers = { alc883_tagra_2ch_mixer},
6787 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6788 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6789 .dac_nids = alc883_dac_nids,
6790 .dig_out_nid = ALC883_DIGOUT_NID,
6791 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6792 .adc_nids = alc883_adc_nids,
6793 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6794 .channel_mode = alc883_3ST_2ch_modes,
6795 .input_mux = &alc883_capture_source,
6796 .unsol_event = alc883_tagra_unsol_event,
6797 .init_hook = alc883_tagra_automute,
6798 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02006799 [ALC883_ACER] = {
6800 .mixers = { alc883_base_mixer,
6801 alc883_chmode_mixer },
6802 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6803 * and the headphone jack. Turn this on and rely on the
6804 * standard mute methods whenever the user wants to turn
6805 * these outputs off.
6806 */
6807 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6808 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6809 .dac_nids = alc883_dac_nids,
6810 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6811 .adc_nids = alc883_adc_nids,
6812 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6813 .channel_mode = alc883_3ST_2ch_modes,
6814 .input_mux = &alc883_capture_source,
6815 },
Tobin Davis2880a862007-08-07 11:50:26 +02006816 [ALC883_ACER_ASPIRE] = {
6817 .mixers = { alc883_acer_aspire_mixer},
6818 .init_verbs = { alc883_init_verbs, alc883_acer_aspire_verbs},
6819 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6820 .dac_nids = alc883_dac_nids,
6821 .dig_out_nid = ALC883_DIGOUT_NID,
6822 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6823 .adc_nids = alc883_adc_nids,
6824 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6825 .channel_mode = alc883_3ST_2ch_modes,
6826 .input_mux = &alc883_capture_source,
6827 .unsol_event = alc883_medion_md2_unsol_event,
6828 .init_hook = alc883_medion_md2_automute,
6829 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006830 [ALC883_MEDION] = {
6831 .mixers = { alc883_fivestack_mixer,
6832 alc883_chmode_mixer },
6833 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006834 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006835 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6836 .dac_nids = alc883_dac_nids,
6837 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6838 .adc_nids = alc883_adc_nids,
6839 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6840 .channel_mode = alc883_sixstack_modes,
6841 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006842 },
Kailang Yang272a5272007-05-14 11:00:38 +02006843 [ALC883_MEDION_MD2] = {
6844 .mixers = { alc883_medion_md2_mixer},
6845 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6846 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6847 .dac_nids = alc883_dac_nids,
6848 .dig_out_nid = ALC883_DIGOUT_NID,
6849 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6850 .adc_nids = alc883_adc_nids,
6851 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6852 .channel_mode = alc883_3ST_2ch_modes,
6853 .input_mux = &alc883_capture_source,
6854 .unsol_event = alc883_medion_md2_unsol_event,
6855 .init_hook = alc883_medion_md2_automute,
6856 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006857 [ALC883_LAPTOP_EAPD] = {
6858 .mixers = { alc883_base_mixer,
6859 alc883_chmode_mixer },
6860 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6861 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6862 .dac_nids = alc883_dac_nids,
6863 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6864 .adc_nids = alc883_adc_nids,
6865 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6866 .channel_mode = alc883_3ST_2ch_modes,
6867 .input_mux = &alc883_capture_source,
6868 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006869 [ALC883_LENOVO_101E_2ch] = {
6870 .mixers = { alc883_lenovo_101e_2ch_mixer},
6871 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6872 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6873 .dac_nids = alc883_dac_nids,
6874 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6875 .adc_nids = alc883_adc_nids,
6876 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6877 .channel_mode = alc883_3ST_2ch_modes,
6878 .input_mux = &alc883_lenovo_101e_capture_source,
6879 .unsol_event = alc883_lenovo_101e_unsol_event,
6880 .init_hook = alc883_lenovo_101e_all_automute,
6881 },
Kailang Yang272a5272007-05-14 11:00:38 +02006882 [ALC883_LENOVO_NB0763] = {
6883 .mixers = { alc883_lenovo_nb0763_mixer },
6884 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6885 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6886 .dac_nids = alc883_dac_nids,
6887 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6888 .adc_nids = alc883_adc_nids,
6889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6890 .channel_mode = alc883_3ST_2ch_modes,
6891 .need_dac_fix = 1,
6892 .input_mux = &alc883_lenovo_nb0763_capture_source,
6893 .unsol_event = alc883_medion_md2_unsol_event,
6894 .init_hook = alc883_medion_md2_automute,
6895 },
6896 [ALC888_LENOVO_MS7195_DIG] = {
6897 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6898 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6899 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6900 .dac_nids = alc883_dac_nids,
6901 .dig_out_nid = ALC883_DIGOUT_NID,
6902 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6903 .adc_nids = alc883_adc_nids,
6904 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6905 .channel_mode = alc883_3ST_6ch_modes,
6906 .need_dac_fix = 1,
6907 .input_mux = &alc883_capture_source,
6908 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6909 .init_hook = alc888_lenovo_ms7195_front_automute,
6910 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006911 [ALC888_6ST_HP] = {
6912 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6913 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006914 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6915 .dac_nids = alc883_dac_nids,
6916 .dig_out_nid = ALC883_DIGOUT_NID,
6917 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6918 .adc_nids = alc883_adc_nids,
6919 .dig_in_nid = ALC883_DIGIN_NID,
6920 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6921 .channel_mode = alc883_sixstack_modes,
6922 .input_mux = &alc883_capture_source,
6923 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006924 [ALC888_3ST_HP] = {
6925 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6926 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006927 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6928 .dac_nids = alc883_dac_nids,
6929 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6930 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006931 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6932 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006933 .need_dac_fix = 1,
6934 .input_mux = &alc883_capture_source,
6935 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006936};
6937
6938
6939/*
6940 * BIOS auto configuration
6941 */
6942static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6943 hda_nid_t nid, int pin_type,
6944 int dac_idx)
6945{
6946 /* set as output */
6947 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006948 int idx;
6949
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006950 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6951 idx = 4;
6952 else
6953 idx = spec->multiout.dac_nids[dac_idx] - 2;
6954
6955 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6956 pin_type);
6957 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6958 AMP_OUT_UNMUTE);
6959 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6960
6961}
6962
6963static void alc883_auto_init_multi_out(struct hda_codec *codec)
6964{
6965 struct alc_spec *spec = codec->spec;
6966 int i;
6967
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006968 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006969 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006970 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006971 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006972 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006973 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006974 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006975 }
6976}
6977
6978static void alc883_auto_init_hp_out(struct hda_codec *codec)
6979{
6980 struct alc_spec *spec = codec->spec;
6981 hda_nid_t pin;
6982
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006983 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006984 if (pin) /* connect to front */
6985 /* use dac 0 */
6986 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6987}
6988
6989#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6990#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6991
6992static void alc883_auto_init_analog_input(struct hda_codec *codec)
6993{
6994 struct alc_spec *spec = codec->spec;
6995 int i;
6996
6997 for (i = 0; i < AUTO_PIN_LAST; i++) {
6998 hda_nid_t nid = spec->autocfg.input_pins[i];
6999 if (alc883_is_input_pin(nid)) {
7000 snd_hda_codec_write(codec, nid, 0,
7001 AC_VERB_SET_PIN_WIDGET_CONTROL,
7002 (i <= AUTO_PIN_FRONT_MIC ?
7003 PIN_VREF80 : PIN_IN));
7004 if (nid != ALC883_PIN_CD_NID)
7005 snd_hda_codec_write(codec, nid, 0,
7006 AC_VERB_SET_AMP_GAIN_MUTE,
7007 AMP_OUT_MUTE);
7008 }
7009 }
7010}
7011
7012/* almost identical with ALC880 parser... */
7013static int alc883_parse_auto_config(struct hda_codec *codec)
7014{
7015 struct alc_spec *spec = codec->spec;
7016 int err = alc880_parse_auto_config(codec);
7017
7018 if (err < 0)
7019 return err;
7020 else if (err > 0)
7021 /* hack - override the init verbs */
7022 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007023 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7024 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007025 return err;
7026}
7027
7028/* additional initialization for auto-configuration model */
7029static void alc883_auto_init(struct hda_codec *codec)
7030{
7031 alc883_auto_init_multi_out(codec);
7032 alc883_auto_init_hp_out(codec);
7033 alc883_auto_init_analog_input(codec);
7034}
7035
7036static int patch_alc883(struct hda_codec *codec)
7037{
7038 struct alc_spec *spec;
7039 int err, board_config;
7040
7041 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7042 if (spec == NULL)
7043 return -ENOMEM;
7044
7045 codec->spec = spec;
7046
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007047 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7048 alc883_models,
7049 alc883_cfg_tbl);
7050 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007051 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7052 "trying auto-probe from BIOS...\n");
7053 board_config = ALC883_AUTO;
7054 }
7055
7056 if (board_config == ALC883_AUTO) {
7057 /* automatic parse from the BIOS config */
7058 err = alc883_parse_auto_config(codec);
7059 if (err < 0) {
7060 alc_free(codec);
7061 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007062 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007063 printk(KERN_INFO
7064 "hda_codec: Cannot set up configuration "
7065 "from BIOS. Using base mode...\n");
7066 board_config = ALC883_3ST_2ch_DIG;
7067 }
7068 }
7069
7070 if (board_config != ALC883_AUTO)
7071 setup_preset(spec, &alc883_presets[board_config]);
7072
7073 spec->stream_name_analog = "ALC883 Analog";
7074 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7075 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7076
7077 spec->stream_name_digital = "ALC883 Digital";
7078 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7079 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7080
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007081 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007082 spec->adc_nids = alc883_adc_nids;
7083 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7084 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007085
7086 codec->patch_ops = alc_patch_ops;
7087 if (board_config == ALC883_AUTO)
7088 spec->init_hook = alc883_auto_init;
7089
7090 return 0;
7091}
7092
7093/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007094 * ALC262 support
7095 */
7096
7097#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7098#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7099
7100#define alc262_dac_nids alc260_dac_nids
7101#define alc262_adc_nids alc882_adc_nids
7102#define alc262_adc_nids_alt alc882_adc_nids_alt
7103
7104#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007105#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007106
7107static struct snd_kcontrol_new alc262_base_mixer[] = {
7108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7109 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7110 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7111 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7113 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007116 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007117 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7118 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007119 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007120 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7121 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7122 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7123 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7124 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7125 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007126 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007127};
7128
Kailang Yangccc656c2006-10-17 12:32:26 +02007129static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7131 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007138 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007139 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7140 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007141 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007142 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7143 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7144 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7146 { } /* end */
7147};
7148
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007149static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7150 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7151 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7153 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7154 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7155
7156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007159 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7160 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007161 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007162 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7163 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7164 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7165 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7166 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7167 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7168 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7169 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7170 { } /* end */
7171};
7172
Kailang Yangcd7509a2007-01-26 18:33:17 +01007173static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7175 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7176 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7178 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7179 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7180 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007182 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007183 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7184 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7185 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7186 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7187 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7188 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7189 { } /* end */
7190};
7191
7192static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7193 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7194 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007195 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007196 { } /* end */
7197};
7198
Takashi Iwai532d5382007-07-27 19:02:40 +02007199static struct hda_bind_ctls alc262_sony_bind_sw = {
7200 .ops = &snd_hda_bind_sw,
7201 .values = {
7202 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7203 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7204 0,
7205 },
7206};
Takashi Iwai5b319542007-07-26 11:49:22 +02007207
Kailang Yang272a5272007-05-14 11:00:38 +02007208static struct snd_kcontrol_new alc262_sony_mixer[] = {
7209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai532d5382007-07-27 19:02:40 +02007210 HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
Kailang Yang272a5272007-05-14 11:00:38 +02007211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7213 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7214 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7215 { } /* end */
7216};
7217
Kailang Yang83c34212007-07-05 11:43:05 +02007218static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7220 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7224 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7225 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7226 { } /* end */
7227};
Kailang Yang272a5272007-05-14 11:00:38 +02007228
Kailang Yangdf694da2005-12-05 19:42:22 +01007229#define alc262_capture_mixer alc882_capture_mixer
7230#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7231
7232/*
7233 * generic initialization of ADC, input mixers and output mixers
7234 */
7235static struct hda_verb alc262_init_verbs[] = {
7236 /*
7237 * Unmute ADC0-2 and set the default input to mic-in
7238 */
7239 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7241 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7243 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7245
7246 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7247 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007248 * Note: PASD motherboards uses the Line In 2 as the input for
7249 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007250 */
7251 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7256 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7257
7258 /*
7259 * Set up output mixers (0x0c - 0x0e)
7260 */
7261 /* set vol=0 to output mixers */
7262 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7263 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7265 /* set up input amps for analog loopback */
7266 /* Amp Indices: DAC = 0, mixer = 1 */
7267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7271 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7272 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7273
7274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7276 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7279 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7280
7281 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7283 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7284 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7285 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7286
7287 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7288 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7289
7290 /* FIXME: use matrix-type input source selection */
7291 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7292 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7297 /* Input mixer2 */
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7301 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7302 /* Input mixer3 */
7303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007307
7308 { }
7309};
7310
Kailang Yangccc656c2006-10-17 12:32:26 +02007311static struct hda_verb alc262_hippo_unsol_verbs[] = {
7312 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7314 {}
7315};
7316
7317static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7318 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7319 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7320 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7321
7322 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7324 {}
7325};
7326
Kailang Yang272a5272007-05-14 11:00:38 +02007327static struct hda_verb alc262_sony_unsol_verbs[] = {
7328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7329 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7330 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7331
7332 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7333 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7334};
7335
Kailang Yangccc656c2006-10-17 12:32:26 +02007336/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02007337static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007338{
7339 struct alc_spec *spec = codec->spec;
7340 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007341 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007342
Takashi Iwai5b319542007-07-26 11:49:22 +02007343 /* need to execute and sync at first */
7344 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7345 present = snd_hda_codec_read(codec, 0x15, 0,
7346 AC_VERB_GET_PIN_SENSE, 0);
7347 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02007348 if (spec->jack_present) {
7349 /* mute internal speaker */
7350 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7351 0x80, 0x80);
7352 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7353 0x80, 0x80);
7354 } else {
7355 /* unmute internal speaker if necessary */
7356 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7357 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7358 0x80, mute & 0x80);
7359 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7360 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7361 0x80, mute & 0x80);
7362 }
7363}
7364
7365/* unsolicited event for HP jack sensing */
7366static void alc262_hippo_unsol_event(struct hda_codec *codec,
7367 unsigned int res)
7368{
7369 if ((res >> 26) != ALC880_HP_EVENT)
7370 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007371 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007372}
7373
Takashi Iwai5b319542007-07-26 11:49:22 +02007374static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007375{
Kailang Yangccc656c2006-10-17 12:32:26 +02007376 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007377 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007378
Takashi Iwai5b319542007-07-26 11:49:22 +02007379 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7380 present = snd_hda_codec_read(codec, 0x1b, 0,
7381 AC_VERB_GET_PIN_SENSE, 0);
7382 present = (present & 0x80000000) != 0;
7383 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007384 /* mute internal speaker */
7385 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7386 0x80, 0x80);
7387 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7388 0x80, 0x80);
7389 } else {
7390 /* unmute internal speaker if necessary */
7391 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7392 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7393 0x80, mute & 0x80);
7394 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7395 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7396 0x80, mute & 0x80);
7397 }
7398}
7399
7400/* unsolicited event for HP jack sensing */
7401static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7402 unsigned int res)
7403{
7404 if ((res >> 26) != ALC880_HP_EVENT)
7405 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007406 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007407}
7408
Takashi Iwai834be882006-03-01 14:16:17 +01007409/*
7410 * fujitsu model
7411 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7412 */
7413
7414#define ALC_HP_EVENT 0x37
7415
7416static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7417 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7419 {}
7420};
7421
7422static struct hda_input_mux alc262_fujitsu_capture_source = {
7423 .num_items = 2,
7424 .items = {
7425 { "Mic", 0x0 },
7426 { "CD", 0x4 },
7427 },
7428};
7429
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007430static struct hda_input_mux alc262_HP_capture_source = {
7431 .num_items = 5,
7432 .items = {
7433 { "Mic", 0x0 },
7434 { "Front Mic", 0x3 },
7435 { "Line", 0x2 },
7436 { "CD", 0x4 },
7437 { "AUX IN", 0x6 },
7438 },
7439};
7440
Takashi Iwai834be882006-03-01 14:16:17 +01007441/* mute/unmute internal speaker according to the hp jack and mute state */
7442static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7443{
7444 struct alc_spec *spec = codec->spec;
7445 unsigned int mute;
7446
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007447 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007448 unsigned int present;
7449 /* need to execute and sync at first */
7450 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7451 present = snd_hda_codec_read(codec, 0x14, 0,
7452 AC_VERB_GET_PIN_SENSE, 0);
7453 spec->jack_present = (present & 0x80000000) != 0;
7454 spec->sense_updated = 1;
7455 }
7456 if (spec->jack_present) {
7457 /* mute internal speaker */
7458 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7459 0x80, 0x80);
7460 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7461 0x80, 0x80);
7462 } else {
7463 /* unmute internal speaker if necessary */
7464 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7465 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7466 0x80, mute & 0x80);
7467 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7468 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7469 0x80, mute & 0x80);
7470 }
7471}
7472
7473/* unsolicited event for HP jack sensing */
7474static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7475 unsigned int res)
7476{
7477 if ((res >> 26) != ALC_HP_EVENT)
7478 return;
7479 alc262_fujitsu_automute(codec, 1);
7480}
7481
7482/* bind volumes of both NID 0x0c and 0x0d */
7483static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7484 struct snd_ctl_elem_value *ucontrol)
7485{
7486 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7487 long *valp = ucontrol->value.integer.value;
7488 int change;
7489
7490 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7491 0x7f, valp[0] & 0x7f);
7492 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7493 0x7f, valp[1] & 0x7f);
7494 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7495 0x7f, valp[0] & 0x7f);
7496 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7497 0x7f, valp[1] & 0x7f);
7498 return change;
7499}
7500
7501/* bind hp and internal speaker mute (with plug check) */
7502static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7503 struct snd_ctl_elem_value *ucontrol)
7504{
7505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7506 long *valp = ucontrol->value.integer.value;
7507 int change;
7508
7509 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7510 0x80, valp[0] ? 0 : 0x80);
7511 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7512 0x80, valp[1] ? 0 : 0x80);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007513 if (change)
7514 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01007515 return change;
7516}
7517
7518static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7519 {
7520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7521 .name = "Master Playback Volume",
7522 .info = snd_hda_mixer_amp_volume_info,
7523 .get = snd_hda_mixer_amp_volume_get,
7524 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007525 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007526 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7527 },
7528 {
7529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7530 .name = "Master Playback Switch",
7531 .info = snd_hda_mixer_amp_switch_info,
7532 .get = snd_hda_mixer_amp_switch_get,
7533 .put = alc262_fujitsu_master_sw_put,
7534 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7535 },
7536 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7537 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7541 { } /* end */
7542};
7543
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007544/* additional init verbs for Benq laptops */
7545static struct hda_verb alc262_EAPD_verbs[] = {
7546 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7547 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7548 {}
7549};
7550
Kailang Yang83c34212007-07-05 11:43:05 +02007551static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7554
7555 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7556 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7557 {}
7558};
7559
Kailang Yangdf694da2005-12-05 19:42:22 +01007560/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007561static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7562 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007563{
7564 hda_nid_t nid;
7565 int err;
7566
7567 spec->multiout.num_dacs = 1; /* only use one dac */
7568 spec->multiout.dac_nids = spec->private_dac_nids;
7569 spec->multiout.dac_nids[0] = 2;
7570
7571 nid = cfg->line_out_pins[0];
7572 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007573 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7574 "Front Playback Volume",
7575 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7576 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007577 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007578 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7579 "Front Playback Switch",
7580 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7581 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007582 return err;
7583 }
7584
Takashi Iwai82bc9552006-03-21 11:24:42 +01007585 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007586 if (nid) {
7587 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007588 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7589 "Speaker Playback Volume",
7590 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7591 HDA_OUTPUT));
7592 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007593 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007594 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7595 "Speaker Playback Switch",
7596 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7597 HDA_OUTPUT));
7598 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007599 return err;
7600 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007601 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7602 "Speaker Playback Switch",
7603 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7604 HDA_OUTPUT));
7605 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007606 return err;
7607 }
7608 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007609 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007610 if (nid) {
7611 /* spec->multiout.hp_nid = 2; */
7612 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007613 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7614 "Headphone Playback Volume",
7615 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7616 HDA_OUTPUT));
7617 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007618 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007619 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7620 "Headphone Playback Switch",
7621 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7622 HDA_OUTPUT));
7623 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007624 return err;
7625 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007626 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7627 "Headphone Playback Switch",
7628 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7629 HDA_OUTPUT));
7630 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007631 return err;
7632 }
7633 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007634 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007635}
7636
7637/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007638#define alc262_auto_create_analog_input_ctls \
7639 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007640
7641/*
7642 * generic initialization of ADC, input mixers and output mixers
7643 */
7644static struct hda_verb alc262_volume_init_verbs[] = {
7645 /*
7646 * Unmute ADC0-2 and set the default input to mic-in
7647 */
7648 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7650 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7651 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7652 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7653 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7654
7655 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7656 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007657 * Note: PASD motherboards uses the Line In 2 as the input for
7658 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007659 */
7660 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7666
7667 /*
7668 * Set up output mixers (0x0c - 0x0f)
7669 */
7670 /* set vol=0 to output mixers */
7671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7672 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7673 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7674
7675 /* set up input amps for analog loopback */
7676 /* Amp Indices: DAC = 0, mixer = 1 */
7677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7683
7684 /* FIXME: use matrix-type input source selection */
7685 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7686 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7687 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7691 /* Input mixer2 */
7692 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7693 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7694 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7695 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7696 /* Input mixer3 */
7697 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7699 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7701
7702 { }
7703};
7704
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007705static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7706 /*
7707 * Unmute ADC0-2 and set the default input to mic-in
7708 */
7709 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7711 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7712 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7713 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7714 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715
7716 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7717 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007718 * Note: PASD motherboards uses the Line In 2 as the input for
7719 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007720 */
7721 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7729
7730 /*
7731 * Set up output mixers (0x0c - 0x0e)
7732 */
7733 /* set vol=0 to output mixers */
7734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7737
7738 /* set up input amps for analog loopback */
7739 /* Amp Indices: DAC = 0, mixer = 1 */
7740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7746
7747 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7750
7751 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7753
7754 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7756
7757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7761 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7762
7763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7766 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7767 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7768 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7769
7770
7771 /* FIXME: use matrix-type input source selection */
7772 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7773 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7778 /* Input mixer2 */
7779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7783 /* Input mixer3 */
7784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7788
7789 { }
7790};
7791
Kailang Yangcd7509a2007-01-26 18:33:17 +01007792static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7793 /*
7794 * Unmute ADC0-2 and set the default input to mic-in
7795 */
7796 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7798 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7800 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7802
7803 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7804 * mixer widget
7805 * Note: PASD motherboards uses the Line In 2 as the input for front
7806 * panel mic (mic 2)
7807 */
7808 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7811 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7817 /*
7818 * Set up output mixers (0x0c - 0x0e)
7819 */
7820 /* set vol=0 to output mixers */
7821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7824
7825 /* set up input amps for analog loopback */
7826 /* Amp Indices: DAC = 0, mixer = 1 */
7827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7830 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7831 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7832 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7833
7834
7835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7839 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7841 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7842
7843 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7845
7846 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7847 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7848
7849 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7853 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7854 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7855
7856 /* FIXME: use matrix-type input source selection */
7857 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7858 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7864 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7866 /* Input mixer2 */
7867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7872 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7874 /* Input mixer3 */
7875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7880 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7882
7883 { }
7884};
7885
Kailang Yangdf694da2005-12-05 19:42:22 +01007886/* pcm configuration: identiacal with ALC880 */
7887#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7888#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7889#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7890#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7891
7892/*
7893 * BIOS auto configuration
7894 */
7895static int alc262_parse_auto_config(struct hda_codec *codec)
7896{
7897 struct alc_spec *spec = codec->spec;
7898 int err;
7899 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7900
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007901 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7902 alc262_ignore);
7903 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007904 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007905 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007906 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007907 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7908 if (err < 0)
7909 return err;
7910 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7911 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007912 return err;
7913
7914 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7915
7916 if (spec->autocfg.dig_out_pin)
7917 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7918 if (spec->autocfg.dig_in_pin)
7919 spec->dig_in_nid = ALC262_DIGIN_NID;
7920
7921 if (spec->kctl_alloc)
7922 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7923
7924 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007925 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007926 spec->input_mux = &spec->private_imux;
7927
7928 return 1;
7929}
7930
7931#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7932#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7933#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7934
7935
7936/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007937static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007938{
Kailang Yangdf694da2005-12-05 19:42:22 +01007939 alc262_auto_init_multi_out(codec);
7940 alc262_auto_init_hp_out(codec);
7941 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007942}
7943
7944/*
7945 * configuration and preset
7946 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007947static const char *alc262_models[ALC262_MODEL_LAST] = {
7948 [ALC262_BASIC] = "basic",
7949 [ALC262_HIPPO] = "hippo",
7950 [ALC262_HIPPO_1] = "hippo_1",
7951 [ALC262_FUJITSU] = "fujitsu",
7952 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007953 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007954 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02007955 [ALC262_BENQ_T31] = "benq-t31",
7956 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007957 [ALC262_AUTO] = "auto",
7958};
7959
7960static struct snd_pci_quirk alc262_cfg_tbl[] = {
7961 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7962 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7963 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007964 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7965 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007966 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007967 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007968 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007969 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007970 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7971 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7972 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7973 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7974 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7975 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7976 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7977 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007978 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7979 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7980 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7981 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02007982 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwai5b319542007-07-26 11:49:22 +02007983 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yang272a5272007-05-14 11:00:38 +02007984 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7985 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7986 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007987 {}
7988};
7989
7990static struct alc_config_preset alc262_presets[] = {
7991 [ALC262_BASIC] = {
7992 .mixers = { alc262_base_mixer },
7993 .init_verbs = { alc262_init_verbs },
7994 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7995 .dac_nids = alc262_dac_nids,
7996 .hp_nid = 0x03,
7997 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7998 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007999 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01008000 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008001 [ALC262_HIPPO] = {
8002 .mixers = { alc262_base_mixer },
8003 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8004 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8005 .dac_nids = alc262_dac_nids,
8006 .hp_nid = 0x03,
8007 .dig_out_nid = ALC262_DIGOUT_NID,
8008 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8009 .channel_mode = alc262_modes,
8010 .input_mux = &alc262_capture_source,
8011 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008012 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008013 },
8014 [ALC262_HIPPO_1] = {
8015 .mixers = { alc262_hippo1_mixer },
8016 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8017 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8018 .dac_nids = alc262_dac_nids,
8019 .hp_nid = 0x02,
8020 .dig_out_nid = ALC262_DIGOUT_NID,
8021 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8022 .channel_mode = alc262_modes,
8023 .input_mux = &alc262_capture_source,
8024 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008025 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008026 },
Takashi Iwai834be882006-03-01 14:16:17 +01008027 [ALC262_FUJITSU] = {
8028 .mixers = { alc262_fujitsu_mixer },
8029 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
8030 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8031 .dac_nids = alc262_dac_nids,
8032 .hp_nid = 0x03,
8033 .dig_out_nid = ALC262_DIGOUT_NID,
8034 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8035 .channel_mode = alc262_modes,
8036 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008037 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01008038 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008039 [ALC262_HP_BPC] = {
8040 .mixers = { alc262_HP_BPC_mixer },
8041 .init_verbs = { alc262_HP_BPC_init_verbs },
8042 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8043 .dac_nids = alc262_dac_nids,
8044 .hp_nid = 0x03,
8045 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8046 .channel_mode = alc262_modes,
8047 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008048 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008049 [ALC262_HP_BPC_D7000_WF] = {
8050 .mixers = { alc262_HP_BPC_WildWest_mixer },
8051 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8052 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8053 .dac_nids = alc262_dac_nids,
8054 .hp_nid = 0x03,
8055 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8056 .channel_mode = alc262_modes,
8057 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008058 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008059 [ALC262_HP_BPC_D7000_WL] = {
8060 .mixers = { alc262_HP_BPC_WildWest_mixer,
8061 alc262_HP_BPC_WildWest_option_mixer },
8062 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8063 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8064 .dac_nids = alc262_dac_nids,
8065 .hp_nid = 0x03,
8066 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8067 .channel_mode = alc262_modes,
8068 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008069 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008070 [ALC262_BENQ_ED8] = {
8071 .mixers = { alc262_base_mixer },
8072 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8073 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8074 .dac_nids = alc262_dac_nids,
8075 .hp_nid = 0x03,
8076 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8077 .channel_mode = alc262_modes,
8078 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008079 },
Kailang Yang272a5272007-05-14 11:00:38 +02008080 [ALC262_SONY_ASSAMD] = {
8081 .mixers = { alc262_sony_mixer },
8082 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8083 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8084 .dac_nids = alc262_dac_nids,
8085 .hp_nid = 0x02,
8086 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8087 .channel_mode = alc262_modes,
8088 .input_mux = &alc262_capture_source,
8089 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008090 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02008091 },
8092 [ALC262_BENQ_T31] = {
8093 .mixers = { alc262_benq_t31_mixer },
8094 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8095 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8096 .dac_nids = alc262_dac_nids,
8097 .hp_nid = 0x03,
8098 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8099 .channel_mode = alc262_modes,
8100 .input_mux = &alc262_capture_source,
8101 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008102 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02008103 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008104};
8105
8106static int patch_alc262(struct hda_codec *codec)
8107{
8108 struct alc_spec *spec;
8109 int board_config;
8110 int err;
8111
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008112 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008113 if (spec == NULL)
8114 return -ENOMEM;
8115
8116 codec->spec = spec;
8117#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008118 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8119 * under-run
8120 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008121 {
8122 int tmp;
8123 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8124 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8125 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8126 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8127 }
8128#endif
8129
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008130 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8131 alc262_models,
8132 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01008133
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008134 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008135 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8136 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008137 board_config = ALC262_AUTO;
8138 }
8139
8140 if (board_config == ALC262_AUTO) {
8141 /* automatic parse from the BIOS config */
8142 err = alc262_parse_auto_config(codec);
8143 if (err < 0) {
8144 alc_free(codec);
8145 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008146 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008147 printk(KERN_INFO
8148 "hda_codec: Cannot set up configuration "
8149 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008150 board_config = ALC262_BASIC;
8151 }
8152 }
8153
8154 if (board_config != ALC262_AUTO)
8155 setup_preset(spec, &alc262_presets[board_config]);
8156
8157 spec->stream_name_analog = "ALC262 Analog";
8158 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8159 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8160
8161 spec->stream_name_digital = "ALC262 Digital";
8162 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8163 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8164
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008165 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008166 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01008167 unsigned int wcap = get_wcaps(codec, 0x07);
8168
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008169 /* get type */
8170 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01008171 if (wcap != AC_WID_AUD_IN) {
8172 spec->adc_nids = alc262_adc_nids_alt;
8173 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008174 spec->mixers[spec->num_mixers] =
8175 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01008176 spec->num_mixers++;
8177 } else {
8178 spec->adc_nids = alc262_adc_nids;
8179 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8180 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8181 spec->num_mixers++;
8182 }
8183 }
8184
8185 codec->patch_ops = alc_patch_ops;
8186 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008187 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01008188
Kailang Yangdf694da2005-12-05 19:42:22 +01008189 return 0;
8190}
8191
Kailang Yangdf694da2005-12-05 19:42:22 +01008192/*
Kailang Yanga361d842007-06-05 12:30:55 +02008193 * ALC268 channel source setting (2 channel)
8194 */
8195#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8196#define alc268_modes alc260_modes
8197
8198static hda_nid_t alc268_dac_nids[2] = {
8199 /* front, hp */
8200 0x02, 0x03
8201};
8202
8203static hda_nid_t alc268_adc_nids[2] = {
8204 /* ADC0-1 */
8205 0x08, 0x07
8206};
8207
8208static hda_nid_t alc268_adc_nids_alt[1] = {
8209 /* ADC0 */
8210 0x08
8211};
8212
8213static struct snd_kcontrol_new alc268_base_mixer[] = {
8214 /* output mixer control */
8215 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8216 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8219 { }
8220};
8221
8222/*
8223 * generic initialization of ADC, input mixers and output mixers
8224 */
8225static struct hda_verb alc268_base_init_verbs[] = {
8226 /* Unmute DAC0-1 and set vol = 0 */
8227 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8228 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8229 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8230 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8231 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8232 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8233
8234 /*
8235 * Set up output mixers (0x0c - 0x0e)
8236 */
8237 /* set vol=0 to output mixers */
8238 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8239 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8240 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8241 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8242
8243 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8244 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8245
8246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8248 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8249 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8251 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8252 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8253 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8254
8255 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8257 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8259 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8260 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8261 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8262 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8263
8264 /* FIXME: use matrix-type input source selection */
8265 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8266 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8267 /* Input mixer2 */
8268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8272
8273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8277 { }
8278};
8279
8280/*
8281 * generic initialization of ADC, input mixers and output mixers
8282 */
8283static struct hda_verb alc268_volume_init_verbs[] = {
8284 /* set output DAC */
8285 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8286 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8287 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8288 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8289
8290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8291 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8292 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8293 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8294 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8295
8296 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8299 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8300 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8301
8302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8303 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8305 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8306
8307 /* set PCBEEP vol = 0 */
8308 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8309
8310 { }
8311};
8312
8313#define alc268_mux_enum_info alc_mux_enum_info
8314#define alc268_mux_enum_get alc_mux_enum_get
8315
8316static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8317 struct snd_ctl_elem_value *ucontrol)
8318{
8319 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8320 struct alc_spec *spec = codec->spec;
8321 const struct hda_input_mux *imux = spec->input_mux;
8322 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8323 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8324 hda_nid_t nid = capture_mixers[adc_idx];
8325 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8326 unsigned int i, idx;
8327
8328 idx = ucontrol->value.enumerated.item[0];
8329 if (idx >= imux->num_items)
8330 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008331 if (*cur_val == idx)
Kailang Yanga361d842007-06-05 12:30:55 +02008332 return 0;
8333 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008334 unsigned int v = (i == idx) ? 0x00 : 0x80;
8335 snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT,
8336 imux->items[i].index, 0x80, v);
8337 snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT,
8338 imux->items[i].index, 0x80, v);
8339 snd_hda_codec_write_cache(codec, nid, 0,
8340 AC_VERB_SET_CONNECT_SEL,
8341 idx );
Kailang Yanga361d842007-06-05 12:30:55 +02008342 }
8343 *cur_val = idx;
8344 return 1;
8345}
8346
8347static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8348 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8349 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8350 {
8351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8352 /* The multiple "Capture Source" controls confuse alsamixer
8353 * So call somewhat different..
8354 * FIXME: the controls appear in the "playback" view!
8355 */
8356 /* .name = "Capture Source", */
8357 .name = "Input Source",
8358 .count = 1,
8359 .info = alc268_mux_enum_info,
8360 .get = alc268_mux_enum_get,
8361 .put = alc268_mux_enum_put,
8362 },
8363 { } /* end */
8364};
8365
8366static struct snd_kcontrol_new alc268_capture_mixer[] = {
8367 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8368 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8369 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8370 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8371 {
8372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8373 /* The multiple "Capture Source" controls confuse alsamixer
8374 * So call somewhat different..
8375 * FIXME: the controls appear in the "playback" view!
8376 */
8377 /* .name = "Capture Source", */
8378 .name = "Input Source",
8379 .count = 2,
8380 .info = alc268_mux_enum_info,
8381 .get = alc268_mux_enum_get,
8382 .put = alc268_mux_enum_put,
8383 },
8384 { } /* end */
8385};
8386
8387static struct hda_input_mux alc268_capture_source = {
8388 .num_items = 4,
8389 .items = {
8390 { "Mic", 0x0 },
8391 { "Front Mic", 0x1 },
8392 { "Line", 0x2 },
8393 { "CD", 0x3 },
8394 },
8395};
8396
8397/* create input playback/capture controls for the given pin */
8398static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8399 const char *ctlname, int idx)
8400{
8401 char name[32];
8402 int err;
8403
8404 sprintf(name, "%s Playback Volume", ctlname);
8405 if (nid == 0x14) {
8406 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8407 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8408 HDA_OUTPUT));
8409 if (err < 0)
8410 return err;
8411 } else if (nid == 0x15) {
8412 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8413 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8414 HDA_OUTPUT));
8415 if (err < 0)
8416 return err;
8417 } else
8418 return -1;
8419 sprintf(name, "%s Playback Switch", ctlname);
8420 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8421 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8422 if (err < 0)
8423 return err;
8424 return 0;
8425}
8426
8427/* add playback controls from the parsed DAC table */
8428static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8429 const struct auto_pin_cfg *cfg)
8430{
8431 hda_nid_t nid;
8432 int err;
8433
8434 spec->multiout.num_dacs = 2; /* only use one dac */
8435 spec->multiout.dac_nids = spec->private_dac_nids;
8436 spec->multiout.dac_nids[0] = 2;
8437 spec->multiout.dac_nids[1] = 3;
8438
8439 nid = cfg->line_out_pins[0];
8440 if (nid)
8441 alc268_new_analog_output(spec, nid, "Front", 0);
8442
8443 nid = cfg->speaker_pins[0];
8444 if (nid == 0x1d) {
8445 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8446 "Speaker Playback Volume",
8447 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8448 if (err < 0)
8449 return err;
8450 }
8451 nid = cfg->hp_pins[0];
8452 if (nid)
8453 alc268_new_analog_output(spec, nid, "Headphone", 0);
8454
8455 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8456 if (nid == 0x16) {
8457 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8458 "Mono Playback Switch",
8459 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8460 if (err < 0)
8461 return err;
8462 }
8463 return 0;
8464}
8465
8466/* create playback/capture controls for input pins */
8467static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8468 const struct auto_pin_cfg *cfg)
8469{
8470 struct hda_input_mux *imux = &spec->private_imux;
8471 int i, idx1;
8472
8473 for (i = 0; i < AUTO_PIN_LAST; i++) {
8474 switch(cfg->input_pins[i]) {
8475 case 0x18:
8476 idx1 = 0; /* Mic 1 */
8477 break;
8478 case 0x19:
8479 idx1 = 1; /* Mic 2 */
8480 break;
8481 case 0x1a:
8482 idx1 = 2; /* Line In */
8483 break;
8484 case 0x1c:
8485 idx1 = 3; /* CD */
8486 break;
8487 default:
8488 continue;
8489 }
8490 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8491 imux->items[imux->num_items].index = idx1;
8492 imux->num_items++;
8493 }
8494 return 0;
8495}
8496
8497static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8498{
8499 struct alc_spec *spec = codec->spec;
8500 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8501 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8502 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8503 unsigned int dac_vol1, dac_vol2;
8504
8505 if (speaker_nid) {
8506 snd_hda_codec_write(codec, speaker_nid, 0,
8507 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8508 snd_hda_codec_write(codec, 0x0f, 0,
8509 AC_VERB_SET_AMP_GAIN_MUTE,
8510 AMP_IN_UNMUTE(1));
8511 snd_hda_codec_write(codec, 0x10, 0,
8512 AC_VERB_SET_AMP_GAIN_MUTE,
8513 AMP_IN_UNMUTE(1));
8514 } else {
8515 snd_hda_codec_write(codec, 0x0f, 0,
8516 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8517 snd_hda_codec_write(codec, 0x10, 0,
8518 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8519 }
8520
8521 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8522 if (line_nid == 0x14)
8523 dac_vol2 = AMP_OUT_ZERO;
8524 else if (line_nid == 0x15)
8525 dac_vol1 = AMP_OUT_ZERO;
8526 if (hp_nid == 0x14)
8527 dac_vol2 = AMP_OUT_ZERO;
8528 else if (hp_nid == 0x15)
8529 dac_vol1 = AMP_OUT_ZERO;
8530 if (line_nid != 0x16 || hp_nid != 0x16 ||
8531 spec->autocfg.line_out_pins[1] != 0x16 ||
8532 spec->autocfg.line_out_pins[2] != 0x16)
8533 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8534
8535 snd_hda_codec_write(codec, 0x02, 0,
8536 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8537 snd_hda_codec_write(codec, 0x03, 0,
8538 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8539}
8540
8541/* pcm configuration: identiacal with ALC880 */
8542#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8543#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8544#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8545
8546/*
8547 * BIOS auto configuration
8548 */
8549static int alc268_parse_auto_config(struct hda_codec *codec)
8550{
8551 struct alc_spec *spec = codec->spec;
8552 int err;
8553 static hda_nid_t alc268_ignore[] = { 0 };
8554
8555 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8556 alc268_ignore);
8557 if (err < 0)
8558 return err;
8559 if (!spec->autocfg.line_outs)
8560 return 0; /* can't find valid BIOS pin config */
8561
8562 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8563 if (err < 0)
8564 return err;
8565 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8566 if (err < 0)
8567 return err;
8568
8569 spec->multiout.max_channels = 2;
8570
8571 /* digital only support output */
8572 if (spec->autocfg.dig_out_pin)
8573 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8574
8575 if (spec->kctl_alloc)
8576 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8577
8578 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8579 spec->num_mux_defs = 1;
8580 spec->input_mux = &spec->private_imux;
8581
8582 return 1;
8583}
8584
8585#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8586#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8587#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8588
8589/* init callback for auto-configuration model -- overriding the default init */
8590static void alc268_auto_init(struct hda_codec *codec)
8591{
8592 alc268_auto_init_multi_out(codec);
8593 alc268_auto_init_hp_out(codec);
8594 alc268_auto_init_mono_speaker_out(codec);
8595 alc268_auto_init_analog_input(codec);
8596}
8597
8598/*
8599 * configuration and preset
8600 */
8601static const char *alc268_models[ALC268_MODEL_LAST] = {
8602 [ALC268_3ST] = "3stack",
8603 [ALC268_AUTO] = "auto",
8604};
8605
8606static struct snd_pci_quirk alc268_cfg_tbl[] = {
8607 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8608 {}
8609};
8610
8611static struct alc_config_preset alc268_presets[] = {
8612 [ALC268_3ST] = {
8613 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8614 .init_verbs = { alc268_base_init_verbs },
8615 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8616 .dac_nids = alc268_dac_nids,
8617 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8618 .adc_nids = alc268_adc_nids_alt,
8619 .hp_nid = 0x03,
8620 .dig_out_nid = ALC268_DIGOUT_NID,
8621 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8622 .channel_mode = alc268_modes,
8623 .input_mux = &alc268_capture_source,
8624 },
8625};
8626
8627static int patch_alc268(struct hda_codec *codec)
8628{
8629 struct alc_spec *spec;
8630 int board_config;
8631 int err;
8632
8633 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8634 if (spec == NULL)
8635 return -ENOMEM;
8636
8637 codec->spec = spec;
8638
8639 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8640 alc268_models,
8641 alc268_cfg_tbl);
8642
8643 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8644 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8645 "trying auto-probe from BIOS...\n");
8646 board_config = ALC268_AUTO;
8647 }
8648
8649 if (board_config == ALC268_AUTO) {
8650 /* automatic parse from the BIOS config */
8651 err = alc268_parse_auto_config(codec);
8652 if (err < 0) {
8653 alc_free(codec);
8654 return err;
8655 } else if (!err) {
8656 printk(KERN_INFO
8657 "hda_codec: Cannot set up configuration "
8658 "from BIOS. Using base mode...\n");
8659 board_config = ALC268_3ST;
8660 }
8661 }
8662
8663 if (board_config != ALC268_AUTO)
8664 setup_preset(spec, &alc268_presets[board_config]);
8665
8666 spec->stream_name_analog = "ALC268 Analog";
8667 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8668 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8669
8670 spec->stream_name_digital = "ALC268 Digital";
8671 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8672
8673 if (board_config == ALC268_AUTO) {
8674 if (!spec->adc_nids && spec->input_mux) {
8675 /* check whether NID 0x07 is valid */
8676 unsigned int wcap = get_wcaps(codec, 0x07);
8677
8678 /* get type */
8679 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8680 if (wcap != AC_WID_AUD_IN) {
8681 spec->adc_nids = alc268_adc_nids_alt;
8682 spec->num_adc_nids =
8683 ARRAY_SIZE(alc268_adc_nids_alt);
8684 spec->mixers[spec->num_mixers] =
8685 alc268_capture_alt_mixer;
8686 spec->num_mixers++;
8687 } else {
8688 spec->adc_nids = alc268_adc_nids;
8689 spec->num_adc_nids =
8690 ARRAY_SIZE(alc268_adc_nids);
8691 spec->mixers[spec->num_mixers] =
8692 alc268_capture_mixer;
8693 spec->num_mixers++;
8694 }
8695 }
8696 }
8697 codec->patch_ops = alc_patch_ops;
8698 if (board_config == ALC268_AUTO)
8699 spec->init_hook = alc268_auto_init;
8700
8701 return 0;
8702}
8703
8704/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008705 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8706 */
8707
8708/*
8709 * set the path ways for 2 channel output
8710 * need to set the codec line out and mic 1 pin widgets to inputs
8711 */
8712static struct hda_verb alc861_threestack_ch2_init[] = {
8713 /* set pin widget 1Ah (line in) for input */
8714 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008715 /* set pin widget 18h (mic1/2) for input, for mic also enable
8716 * the vref
8717 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008718 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8719
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008720 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8721#if 0
8722 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8723 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8724#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008725 { } /* end */
8726};
8727/*
8728 * 6ch mode
8729 * need to set the codec line out and mic 1 pin widgets to outputs
8730 */
8731static struct hda_verb alc861_threestack_ch6_init[] = {
8732 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8733 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8734 /* set pin widget 18h (mic1) for output (CLFE)*/
8735 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8736
8737 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008738 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008739
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008740 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8741#if 0
8742 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8743 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8744#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008745 { } /* end */
8746};
8747
8748static struct hda_channel_mode alc861_threestack_modes[2] = {
8749 { 2, alc861_threestack_ch2_init },
8750 { 6, alc861_threestack_ch6_init },
8751};
Takashi Iwai22309c32006-08-09 16:57:28 +02008752/* Set mic1 as input and unmute the mixer */
8753static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8754 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8755 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8756 { } /* end */
8757};
8758/* Set mic1 as output and mute mixer */
8759static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8760 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8761 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8762 { } /* end */
8763};
8764
8765static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8766 { 2, alc861_uniwill_m31_ch2_init },
8767 { 4, alc861_uniwill_m31_ch4_init },
8768};
Kailang Yangdf694da2005-12-05 19:42:22 +01008769
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008770/* Set mic1 and line-in as input and unmute the mixer */
8771static struct hda_verb alc861_asus_ch2_init[] = {
8772 /* set pin widget 1Ah (line in) for input */
8773 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008774 /* set pin widget 18h (mic1/2) for input, for mic also enable
8775 * the vref
8776 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008777 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8778
8779 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8780#if 0
8781 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8782 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8783#endif
8784 { } /* end */
8785};
8786/* Set mic1 nad line-in as output and mute mixer */
8787static struct hda_verb alc861_asus_ch6_init[] = {
8788 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8789 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8790 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8791 /* set pin widget 18h (mic1) for output (CLFE)*/
8792 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8793 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8794 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8795 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8796
8797 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8798#if 0
8799 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8800 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8801#endif
8802 { } /* end */
8803};
8804
8805static struct hda_channel_mode alc861_asus_modes[2] = {
8806 { 2, alc861_asus_ch2_init },
8807 { 6, alc861_asus_ch6_init },
8808};
8809
Kailang Yangdf694da2005-12-05 19:42:22 +01008810/* patch-ALC861 */
8811
8812static struct snd_kcontrol_new alc861_base_mixer[] = {
8813 /* output mixer control */
8814 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8815 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8816 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8817 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8818 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8819
8820 /*Input mixer control */
8821 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8822 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8823 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8824 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8825 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8826 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8828 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8829 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008831
Kailang Yangdf694da2005-12-05 19:42:22 +01008832 /* Capture mixer control */
8833 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8834 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8835 {
8836 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8837 .name = "Capture Source",
8838 .count = 1,
8839 .info = alc_mux_enum_info,
8840 .get = alc_mux_enum_get,
8841 .put = alc_mux_enum_put,
8842 },
8843 { } /* end */
8844};
8845
8846static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8847 /* output mixer control */
8848 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8849 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8850 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8851 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8852 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8853
8854 /* Input mixer control */
8855 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8856 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8857 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8858 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8859 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8860 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8862 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8863 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8864 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008865
Kailang Yangdf694da2005-12-05 19:42:22 +01008866 /* Capture mixer control */
8867 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8868 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8869 {
8870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8871 .name = "Capture Source",
8872 .count = 1,
8873 .info = alc_mux_enum_info,
8874 .get = alc_mux_enum_get,
8875 .put = alc_mux_enum_put,
8876 },
8877 {
8878 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8879 .name = "Channel Mode",
8880 .info = alc_ch_mode_info,
8881 .get = alc_ch_mode_get,
8882 .put = alc_ch_mode_put,
8883 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8884 },
8885 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008886};
8887
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008888static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008889 /* output mixer control */
8890 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8892 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8893
8894 /*Capture mixer control */
8895 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8896 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8897 {
8898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8899 .name = "Capture Source",
8900 .count = 1,
8901 .info = alc_mux_enum_info,
8902 .get = alc_mux_enum_get,
8903 .put = alc_mux_enum_put,
8904 },
8905
8906 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008907};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008908
Takashi Iwai22309c32006-08-09 16:57:28 +02008909static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8910 /* output mixer control */
8911 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8912 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8913 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8914 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8915 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8916
8917 /* Input mixer control */
8918 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8919 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8920 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8921 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8922 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8923 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8925 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8926 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8927 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008928
Takashi Iwai22309c32006-08-09 16:57:28 +02008929 /* Capture mixer control */
8930 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8931 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8932 {
8933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8934 .name = "Capture Source",
8935 .count = 1,
8936 .info = alc_mux_enum_info,
8937 .get = alc_mux_enum_get,
8938 .put = alc_mux_enum_put,
8939 },
8940 {
8941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8942 .name = "Channel Mode",
8943 .info = alc_ch_mode_info,
8944 .get = alc_ch_mode_get,
8945 .put = alc_ch_mode_put,
8946 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8947 },
8948 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008949};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008950
8951static struct snd_kcontrol_new alc861_asus_mixer[] = {
8952 /* output mixer control */
8953 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8954 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8955 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8956 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8957 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8958
8959 /* Input mixer control */
8960 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8961 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8962 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8963 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8964 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8965 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8966 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8967 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8968 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8970
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008971 /* Capture mixer control */
8972 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8973 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8974 {
8975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8976 .name = "Capture Source",
8977 .count = 1,
8978 .info = alc_mux_enum_info,
8979 .get = alc_mux_enum_get,
8980 .put = alc_mux_enum_put,
8981 },
8982 {
8983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8984 .name = "Channel Mode",
8985 .info = alc_ch_mode_info,
8986 .get = alc_ch_mode_get,
8987 .put = alc_ch_mode_put,
8988 .private_value = ARRAY_SIZE(alc861_asus_modes),
8989 },
8990 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008991};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008992
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008993/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008994static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008995 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8996 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8997 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8998 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8999 { }
9000};
9001
Kailang Yangdf694da2005-12-05 19:42:22 +01009002/*
9003 * generic initialization of ADC, input mixers and output mixers
9004 */
9005static struct hda_verb alc861_base_init_verbs[] = {
9006 /*
9007 * Unmute ADC0 and set the default input to mic-in
9008 */
9009 /* port-A for surround (rear panel) */
9010 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9011 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9012 /* port-B for mic-in (rear panel) with vref */
9013 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9014 /* port-C for line-in (rear panel) */
9015 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9016 /* port-D for Front */
9017 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9018 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9019 /* port-E for HP out (front panel) */
9020 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9021 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009022 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009023 /* port-F for mic-in (front panel) with vref */
9024 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9025 /* port-G for CLFE (rear panel) */
9026 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9027 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9028 /* port-H for side (rear panel) */
9029 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9030 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9031 /* CD-in */
9032 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9033 /* route front mic to ADC1*/
9034 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9035 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9036
9037 /* Unmute DAC0~3 & spdif out*/
9038 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9039 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9040 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9041 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9042 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9043
9044 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9045 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9046 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9047 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9048 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9049
9050 /* Unmute Stereo Mixer 15 */
9051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009055
9056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9057 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9058 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9059 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9061 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9063 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009064 /* hp used DAC 3 (Front) */
9065 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9067
9068 { }
9069};
9070
9071static struct hda_verb alc861_threestack_init_verbs[] = {
9072 /*
9073 * Unmute ADC0 and set the default input to mic-in
9074 */
9075 /* port-A for surround (rear panel) */
9076 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9077 /* port-B for mic-in (rear panel) with vref */
9078 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9079 /* port-C for line-in (rear panel) */
9080 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9081 /* port-D for Front */
9082 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9083 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9084 /* port-E for HP out (front panel) */
9085 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9086 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009087 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009088 /* port-F for mic-in (front panel) with vref */
9089 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9090 /* port-G for CLFE (rear panel) */
9091 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9092 /* port-H for side (rear panel) */
9093 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9094 /* CD-in */
9095 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9096 /* route front mic to ADC1*/
9097 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9099 /* Unmute DAC0~3 & spdif out*/
9100 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9101 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9102 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9103 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9104 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9105
9106 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9107 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9108 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9109 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9110 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9111
9112 /* Unmute Stereo Mixer 15 */
9113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009116 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009117
9118 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9119 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9120 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9121 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9122 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9123 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9124 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9125 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009126 /* hp used DAC 3 (Front) */
9127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009128 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9129 { }
9130};
Takashi Iwai22309c32006-08-09 16:57:28 +02009131
9132static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9133 /*
9134 * Unmute ADC0 and set the default input to mic-in
9135 */
9136 /* port-A for surround (rear panel) */
9137 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9138 /* port-B for mic-in (rear panel) with vref */
9139 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9140 /* port-C for line-in (rear panel) */
9141 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9142 /* port-D for Front */
9143 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9144 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9145 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009146 /* this has to be set to VREF80 */
9147 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009148 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009149 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009150 /* port-F for mic-in (front panel) with vref */
9151 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9152 /* port-G for CLFE (rear panel) */
9153 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9154 /* port-H for side (rear panel) */
9155 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9156 /* CD-in */
9157 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9158 /* route front mic to ADC1*/
9159 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9161 /* Unmute DAC0~3 & spdif out*/
9162 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9163 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9164 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9165 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9167
9168 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9169 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9170 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9171 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9172 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9173
9174 /* Unmute Stereo Mixer 15 */
9175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009178 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02009179
9180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9181 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9182 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9183 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9185 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9187 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009188 /* hp used DAC 3 (Front) */
9189 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9191 { }
9192};
9193
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009194static struct hda_verb alc861_asus_init_verbs[] = {
9195 /*
9196 * Unmute ADC0 and set the default input to mic-in
9197 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009198 /* port-A for surround (rear panel)
9199 * according to codec#0 this is the HP jack
9200 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009201 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9202 /* route front PCM to HP */
9203 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9204 /* port-B for mic-in (rear panel) with vref */
9205 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9206 /* port-C for line-in (rear panel) */
9207 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9208 /* port-D for Front */
9209 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9210 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9211 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009212 /* this has to be set to VREF80 */
9213 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009214 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009215 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009216 /* port-F for mic-in (front panel) with vref */
9217 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9218 /* port-G for CLFE (rear panel) */
9219 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9220 /* port-H for side (rear panel) */
9221 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9222 /* CD-in */
9223 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9224 /* route front mic to ADC1*/
9225 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9226 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9227 /* Unmute DAC0~3 & spdif out*/
9228 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9230 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9231 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9233 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9234 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9235 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9236 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9237 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9238
9239 /* Unmute Stereo Mixer 15 */
9240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009244
9245 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9246 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9247 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9248 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9250 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009253 /* hp used DAC 3 (Front) */
9254 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9256 { }
9257};
9258
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009259/* additional init verbs for ASUS laptops */
9260static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9261 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9262 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9263 { }
9264};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009265
Kailang Yangdf694da2005-12-05 19:42:22 +01009266/*
9267 * generic initialization of ADC, input mixers and output mixers
9268 */
9269static struct hda_verb alc861_auto_init_verbs[] = {
9270 /*
9271 * Unmute ADC0 and set the default input to mic-in
9272 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009273 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009274 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9275
9276 /* Unmute DAC0~3 & spdif out*/
9277 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9278 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9279 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9280 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9282
9283 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9284 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9285 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9286 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9287 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9288
9289 /* Unmute Stereo Mixer 15 */
9290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9291 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9292 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9293 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9294
9295 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9296 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9297 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9298 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9299 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9300 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9301 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9302 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9303
9304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9307 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009310 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009312
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009313 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009314
9315 { }
9316};
9317
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009318static struct hda_verb alc861_toshiba_init_verbs[] = {
9319 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009320
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009321 { }
9322};
9323
9324/* toggle speaker-output according to the hp-jack state */
9325static void alc861_toshiba_automute(struct hda_codec *codec)
9326{
9327 unsigned int present;
9328
9329 present = snd_hda_codec_read(codec, 0x0f, 0,
9330 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9331 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
9332 0x80, present ? 0x80 : 0);
9333 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
9334 0x80, present ? 0x80 : 0);
9335 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
9336 0x80, present ? 0 : 0x80);
9337 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
9338 0x80, present ? 0 : 0x80);
9339}
9340
9341static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9342 unsigned int res)
9343{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009344 if ((res >> 26) == ALC880_HP_EVENT)
9345 alc861_toshiba_automute(codec);
9346}
9347
Kailang Yangdf694da2005-12-05 19:42:22 +01009348/* pcm configuration: identiacal with ALC880 */
9349#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9350#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9351#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9352#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9353
9354
9355#define ALC861_DIGOUT_NID 0x07
9356
9357static struct hda_channel_mode alc861_8ch_modes[1] = {
9358 { 8, NULL }
9359};
9360
9361static hda_nid_t alc861_dac_nids[4] = {
9362 /* front, surround, clfe, side */
9363 0x03, 0x06, 0x05, 0x04
9364};
9365
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009366static hda_nid_t alc660_dac_nids[3] = {
9367 /* front, clfe, surround */
9368 0x03, 0x05, 0x06
9369};
9370
Kailang Yangdf694da2005-12-05 19:42:22 +01009371static hda_nid_t alc861_adc_nids[1] = {
9372 /* ADC0-2 */
9373 0x08,
9374};
9375
9376static struct hda_input_mux alc861_capture_source = {
9377 .num_items = 5,
9378 .items = {
9379 { "Mic", 0x0 },
9380 { "Front Mic", 0x3 },
9381 { "Line", 0x1 },
9382 { "CD", 0x4 },
9383 { "Mixer", 0x5 },
9384 },
9385};
9386
9387/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009388static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9389 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009390{
9391 int i;
9392 hda_nid_t nid;
9393
9394 spec->multiout.dac_nids = spec->private_dac_nids;
9395 for (i = 0; i < cfg->line_outs; i++) {
9396 nid = cfg->line_out_pins[i];
9397 if (nid) {
9398 if (i >= ARRAY_SIZE(alc861_dac_nids))
9399 continue;
9400 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9401 }
9402 }
9403 spec->multiout.num_dacs = cfg->line_outs;
9404 return 0;
9405}
9406
9407/* add playback controls from the parsed DAC table */
9408static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9409 const struct auto_pin_cfg *cfg)
9410{
9411 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009412 static const char *chname[4] = {
9413 "Front", "Surround", NULL /*CLFE*/, "Side"
9414 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009415 hda_nid_t nid;
9416 int i, idx, err;
9417
9418 for (i = 0; i < cfg->line_outs; i++) {
9419 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009420 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009421 continue;
9422 if (nid == 0x05) {
9423 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009424 err = add_control(spec, ALC_CTL_BIND_MUTE,
9425 "Center Playback Switch",
9426 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9427 HDA_OUTPUT));
9428 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009429 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009430 err = add_control(spec, ALC_CTL_BIND_MUTE,
9431 "LFE Playback Switch",
9432 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9433 HDA_OUTPUT));
9434 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009435 return err;
9436 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009437 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9438 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009439 if (nid == alc861_dac_nids[idx])
9440 break;
9441 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009442 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9443 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9444 HDA_OUTPUT));
9445 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009446 return err;
9447 }
9448 }
9449 return 0;
9450}
9451
9452static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9453{
9454 int err;
9455 hda_nid_t nid;
9456
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009457 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009458 return 0;
9459
9460 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9461 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009462 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9463 "Headphone Playback Switch",
9464 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9465 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009466 return err;
9467 spec->multiout.hp_nid = nid;
9468 }
9469 return 0;
9470}
9471
9472/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009473static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9474 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009475{
Kailang Yangdf694da2005-12-05 19:42:22 +01009476 struct hda_input_mux *imux = &spec->private_imux;
9477 int i, err, idx, idx1;
9478
9479 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009480 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009481 case 0x0c:
9482 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009483 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009484 break;
9485 case 0x0f:
9486 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009487 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009488 break;
9489 case 0x0d:
9490 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009491 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009492 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009493 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009494 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009495 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009496 break;
9497 case 0x11:
9498 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009499 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009500 break;
9501 default:
9502 continue;
9503 }
9504
Takashi Iwai4a471b72005-12-07 13:56:29 +01009505 err = new_analog_input(spec, cfg->input_pins[i],
9506 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009507 if (err < 0)
9508 return err;
9509
Takashi Iwai4a471b72005-12-07 13:56:29 +01009510 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009511 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009512 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009513 }
9514 return 0;
9515}
9516
9517static struct snd_kcontrol_new alc861_capture_mixer[] = {
9518 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9519 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9520
9521 {
9522 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9523 /* The multiple "Capture Source" controls confuse alsamixer
9524 * So call somewhat different..
9525 *FIXME: the controls appear in the "playback" view!
9526 */
9527 /* .name = "Capture Source", */
9528 .name = "Input Source",
9529 .count = 1,
9530 .info = alc_mux_enum_info,
9531 .get = alc_mux_enum_get,
9532 .put = alc_mux_enum_put,
9533 },
9534 { } /* end */
9535};
9536
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009537static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9538 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009539 int pin_type, int dac_idx)
9540{
9541 /* set as output */
9542
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009543 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9544 pin_type);
9545 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9546 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009547
9548}
9549
9550static void alc861_auto_init_multi_out(struct hda_codec *codec)
9551{
9552 struct alc_spec *spec = codec->spec;
9553 int i;
9554
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009555 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009556 for (i = 0; i < spec->autocfg.line_outs; i++) {
9557 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009558 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009559 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009560 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009561 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009562 }
9563}
9564
9565static void alc861_auto_init_hp_out(struct hda_codec *codec)
9566{
9567 struct alc_spec *spec = codec->spec;
9568 hda_nid_t pin;
9569
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009570 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009571 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009572 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9573 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009574}
9575
9576static void alc861_auto_init_analog_input(struct hda_codec *codec)
9577{
9578 struct alc_spec *spec = codec->spec;
9579 int i;
9580
9581 for (i = 0; i < AUTO_PIN_LAST; i++) {
9582 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009583 if (nid >= 0x0c && nid <= 0x11) {
9584 snd_hda_codec_write(codec, nid, 0,
9585 AC_VERB_SET_PIN_WIDGET_CONTROL,
9586 i <= AUTO_PIN_FRONT_MIC ?
9587 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009588 }
9589 }
9590}
9591
9592/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009593/* return 1 if successful, 0 if the proper config is not found,
9594 * or a negative error code
9595 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009596static int alc861_parse_auto_config(struct hda_codec *codec)
9597{
9598 struct alc_spec *spec = codec->spec;
9599 int err;
9600 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9601
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009602 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9603 alc861_ignore);
9604 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009605 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009606 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009607 return 0; /* can't find valid BIOS pin config */
9608
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009609 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9610 if (err < 0)
9611 return err;
9612 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9613 if (err < 0)
9614 return err;
9615 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9616 if (err < 0)
9617 return err;
9618 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9619 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009620 return err;
9621
9622 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9623
9624 if (spec->autocfg.dig_out_pin)
9625 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9626
9627 if (spec->kctl_alloc)
9628 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9629
9630 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9631
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009632 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009633 spec->input_mux = &spec->private_imux;
9634
9635 spec->adc_nids = alc861_adc_nids;
9636 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9637 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9638 spec->num_mixers++;
9639
9640 return 1;
9641}
9642
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009643/* additional initialization for auto-configuration model */
9644static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009645{
Kailang Yangdf694da2005-12-05 19:42:22 +01009646 alc861_auto_init_multi_out(codec);
9647 alc861_auto_init_hp_out(codec);
9648 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009649}
9650
9651
9652/*
9653 * configuration and preset
9654 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009655static const char *alc861_models[ALC861_MODEL_LAST] = {
9656 [ALC861_3ST] = "3stack",
9657 [ALC660_3ST] = "3stack-660",
9658 [ALC861_3ST_DIG] = "3stack-dig",
9659 [ALC861_6ST_DIG] = "6stack-dig",
9660 [ALC861_UNIWILL_M31] = "uniwill-m31",
9661 [ALC861_TOSHIBA] = "toshiba",
9662 [ALC861_ASUS] = "asus",
9663 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9664 [ALC861_AUTO] = "auto",
9665};
9666
9667static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009668 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009669 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9670 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009671 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +02009672 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009673 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +02009674 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +01009675 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +02009676 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9677 * Any other models that need this preset?
9678 */
9679 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009680 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009681 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009682 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009683 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009684 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Claudio Matsuokaef64adb2007-07-14 00:26:16 +02009685 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9686 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009687 {}
9688};
9689
9690static struct alc_config_preset alc861_presets[] = {
9691 [ALC861_3ST] = {
9692 .mixers = { alc861_3ST_mixer },
9693 .init_verbs = { alc861_threestack_init_verbs },
9694 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9695 .dac_nids = alc861_dac_nids,
9696 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9697 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009698 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009699 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9700 .adc_nids = alc861_adc_nids,
9701 .input_mux = &alc861_capture_source,
9702 },
9703 [ALC861_3ST_DIG] = {
9704 .mixers = { alc861_base_mixer },
9705 .init_verbs = { alc861_threestack_init_verbs },
9706 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9707 .dac_nids = alc861_dac_nids,
9708 .dig_out_nid = ALC861_DIGOUT_NID,
9709 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9710 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009711 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009712 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9713 .adc_nids = alc861_adc_nids,
9714 .input_mux = &alc861_capture_source,
9715 },
9716 [ALC861_6ST_DIG] = {
9717 .mixers = { alc861_base_mixer },
9718 .init_verbs = { alc861_base_init_verbs },
9719 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9720 .dac_nids = alc861_dac_nids,
9721 .dig_out_nid = ALC861_DIGOUT_NID,
9722 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9723 .channel_mode = alc861_8ch_modes,
9724 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9725 .adc_nids = alc861_adc_nids,
9726 .input_mux = &alc861_capture_source,
9727 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009728 [ALC660_3ST] = {
9729 .mixers = { alc861_3ST_mixer },
9730 .init_verbs = { alc861_threestack_init_verbs },
9731 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9732 .dac_nids = alc660_dac_nids,
9733 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9734 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009735 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009736 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9737 .adc_nids = alc861_adc_nids,
9738 .input_mux = &alc861_capture_source,
9739 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009740 [ALC861_UNIWILL_M31] = {
9741 .mixers = { alc861_uniwill_m31_mixer },
9742 .init_verbs = { alc861_uniwill_m31_init_verbs },
9743 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9744 .dac_nids = alc861_dac_nids,
9745 .dig_out_nid = ALC861_DIGOUT_NID,
9746 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9747 .channel_mode = alc861_uniwill_m31_modes,
9748 .need_dac_fix = 1,
9749 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9750 .adc_nids = alc861_adc_nids,
9751 .input_mux = &alc861_capture_source,
9752 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009753 [ALC861_TOSHIBA] = {
9754 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009755 .init_verbs = { alc861_base_init_verbs,
9756 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009757 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9758 .dac_nids = alc861_dac_nids,
9759 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9760 .channel_mode = alc883_3ST_2ch_modes,
9761 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9762 .adc_nids = alc861_adc_nids,
9763 .input_mux = &alc861_capture_source,
9764 .unsol_event = alc861_toshiba_unsol_event,
9765 .init_hook = alc861_toshiba_automute,
9766 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009767 [ALC861_ASUS] = {
9768 .mixers = { alc861_asus_mixer },
9769 .init_verbs = { alc861_asus_init_verbs },
9770 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9771 .dac_nids = alc861_dac_nids,
9772 .dig_out_nid = ALC861_DIGOUT_NID,
9773 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9774 .channel_mode = alc861_asus_modes,
9775 .need_dac_fix = 1,
9776 .hp_nid = 0x06,
9777 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9778 .adc_nids = alc861_adc_nids,
9779 .input_mux = &alc861_capture_source,
9780 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009781 [ALC861_ASUS_LAPTOP] = {
9782 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9783 .init_verbs = { alc861_asus_init_verbs,
9784 alc861_asus_laptop_init_verbs },
9785 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9786 .dac_nids = alc861_dac_nids,
9787 .dig_out_nid = ALC861_DIGOUT_NID,
9788 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9789 .channel_mode = alc883_3ST_2ch_modes,
9790 .need_dac_fix = 1,
9791 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9792 .adc_nids = alc861_adc_nids,
9793 .input_mux = &alc861_capture_source,
9794 },
9795};
Kailang Yangdf694da2005-12-05 19:42:22 +01009796
9797
9798static int patch_alc861(struct hda_codec *codec)
9799{
9800 struct alc_spec *spec;
9801 int board_config;
9802 int err;
9803
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009804 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009805 if (spec == NULL)
9806 return -ENOMEM;
9807
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009808 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009809
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009810 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9811 alc861_models,
9812 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009813
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009814 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009815 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9816 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009817 board_config = ALC861_AUTO;
9818 }
9819
9820 if (board_config == ALC861_AUTO) {
9821 /* automatic parse from the BIOS config */
9822 err = alc861_parse_auto_config(codec);
9823 if (err < 0) {
9824 alc_free(codec);
9825 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009826 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009827 printk(KERN_INFO
9828 "hda_codec: Cannot set up configuration "
9829 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009830 board_config = ALC861_3ST_DIG;
9831 }
9832 }
9833
9834 if (board_config != ALC861_AUTO)
9835 setup_preset(spec, &alc861_presets[board_config]);
9836
9837 spec->stream_name_analog = "ALC861 Analog";
9838 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9839 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9840
9841 spec->stream_name_digital = "ALC861 Digital";
9842 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9843 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9844
9845 codec->patch_ops = alc_patch_ops;
9846 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009847 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009848
9849 return 0;
9850}
9851
9852/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009853 * ALC861-VD support
9854 *
9855 * Based on ALC882
9856 *
9857 * In addition, an independent DAC
9858 */
9859#define ALC861VD_DIGOUT_NID 0x06
9860
9861static hda_nid_t alc861vd_dac_nids[4] = {
9862 /* front, surr, clfe, side surr */
9863 0x02, 0x03, 0x04, 0x05
9864};
9865
9866/* dac_nids for ALC660vd are in a different order - according to
9867 * Realtek's driver.
9868 * This should probably tesult in a different mixer for 6stack models
9869 * of ALC660vd codecs, but for now there is only 3stack mixer
9870 * - and it is the same as in 861vd.
9871 * adc_nids in ALC660vd are (is) the same as in 861vd
9872 */
9873static hda_nid_t alc660vd_dac_nids[3] = {
9874 /* front, rear, clfe, rear_surr */
9875 0x02, 0x04, 0x03
9876};
9877
9878static hda_nid_t alc861vd_adc_nids[1] = {
9879 /* ADC0 */
9880 0x09,
9881};
9882
9883/* input MUX */
9884/* FIXME: should be a matrix-type input source selection */
9885static struct hda_input_mux alc861vd_capture_source = {
9886 .num_items = 4,
9887 .items = {
9888 { "Mic", 0x0 },
9889 { "Front Mic", 0x1 },
9890 { "Line", 0x2 },
9891 { "CD", 0x4 },
9892 },
9893};
9894
Kailang Yang272a5272007-05-14 11:00:38 +02009895static struct hda_input_mux alc861vd_dallas_capture_source = {
9896 .num_items = 3,
9897 .items = {
9898 { "Front Mic", 0x0 },
9899 { "ATAPI Mic", 0x1 },
9900 { "Line In", 0x5 },
9901 },
9902};
9903
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009904#define alc861vd_mux_enum_info alc_mux_enum_info
9905#define alc861vd_mux_enum_get alc_mux_enum_get
9906
9907static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9908 struct snd_ctl_elem_value *ucontrol)
9909{
9910 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9911 struct alc_spec *spec = codec->spec;
9912 const struct hda_input_mux *imux = spec->input_mux;
9913 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9914 static hda_nid_t capture_mixers[1] = { 0x22 };
9915 hda_nid_t nid = capture_mixers[adc_idx];
9916 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9917 unsigned int i, idx;
9918
9919 idx = ucontrol->value.enumerated.item[0];
9920 if (idx >= imux->num_items)
9921 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009922 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009923 return 0;
9924 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009925 unsigned int v = (i == idx) ? 0x00 : 0x80;
9926 snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT,
9927 imux->items[i].index, 0x80, v);
9928 snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT,
9929 imux->items[i].index, 0x80, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009930 }
9931 *cur_val = idx;
9932 return 1;
9933}
9934
9935/*
9936 * 2ch mode
9937 */
9938static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9939 { 2, NULL }
9940};
9941
9942/*
9943 * 6ch mode
9944 */
9945static struct hda_verb alc861vd_6stack_ch6_init[] = {
9946 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9947 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9948 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9949 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9950 { } /* end */
9951};
9952
9953/*
9954 * 8ch mode
9955 */
9956static struct hda_verb alc861vd_6stack_ch8_init[] = {
9957 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9958 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9959 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9960 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9961 { } /* end */
9962};
9963
9964static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9965 { 6, alc861vd_6stack_ch6_init },
9966 { 8, alc861vd_6stack_ch8_init },
9967};
9968
9969static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9970 {
9971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9972 .name = "Channel Mode",
9973 .info = alc_ch_mode_info,
9974 .get = alc_ch_mode_get,
9975 .put = alc_ch_mode_put,
9976 },
9977 { } /* end */
9978};
9979
9980static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9981 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9982 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9983
9984 {
9985 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9986 /* The multiple "Capture Source" controls confuse alsamixer
9987 * So call somewhat different..
9988 *FIXME: the controls appear in the "playback" view!
9989 */
9990 /* .name = "Capture Source", */
9991 .name = "Input Source",
9992 .count = 1,
9993 .info = alc861vd_mux_enum_info,
9994 .get = alc861vd_mux_enum_get,
9995 .put = alc861vd_mux_enum_put,
9996 },
9997 { } /* end */
9998};
9999
10000/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10001 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10002 */
10003static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10004 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10006
10007 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10008 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10009
10010 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10011 HDA_OUTPUT),
10012 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10013 HDA_OUTPUT),
10014 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10015 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10016
10017 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10018 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10019
10020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10021
10022 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10025
10026 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10029
10030 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10031 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10032
10033 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10034 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10035
10036 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10037 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10038
10039 { } /* end */
10040};
10041
10042static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10043 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10044 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10045
10046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10047
10048 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10051
10052 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10053 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10054 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10055
10056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10058
10059 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10060 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10061
10062 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10063 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10064
10065 { } /* end */
10066};
10067
Kailang Yangbdd148a2007-05-08 15:19:08 +020010068static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10069 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10070 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10071 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10072
10073 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10074
10075 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10078
10079 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10080 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10081 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10082
10083 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10084 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10085
10086 { } /* end */
10087};
10088
Kailang Yang272a5272007-05-14 11:00:38 +020010089/* Pin assignment: Front=0x14, HP = 0x15,
10090 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10091 */
10092static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10093 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10094 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10095 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10096 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10097 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10099 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10100 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10103 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10104 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10105 {
10106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10107 /* .name = "Capture Source", */
10108 .name = "Input Source",
10109 .count = 1,
10110 .info = alc882_mux_enum_info,
10111 .get = alc882_mux_enum_get,
10112 .put = alc882_mux_enum_put,
10113 },
10114 { } /* end */
10115};
10116
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010117/*
10118 * generic initialization of ADC, input mixers and output mixers
10119 */
10120static struct hda_verb alc861vd_volume_init_verbs[] = {
10121 /*
10122 * Unmute ADC0 and set the default input to mic-in
10123 */
10124 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10126
10127 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10128 * the analog-loopback mixer widget
10129 */
10130 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10136
10137 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020010138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10140 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010142
10143 /*
10144 * Set up output mixers (0x02 - 0x05)
10145 */
10146 /* set vol=0 to output mixers */
10147 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10148 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10149 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10150 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10151
10152 /* set up input amps for analog loopback */
10153 /* Amp Indices: DAC = 0, mixer = 1 */
10154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10156 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10157 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10159 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10160 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10161 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10162
10163 { }
10164};
10165
10166/*
10167 * 3-stack pin configuration:
10168 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10169 */
10170static struct hda_verb alc861vd_3stack_init_verbs[] = {
10171 /*
10172 * Set pin mode and muting
10173 */
10174 /* set front pin widgets 0x14 for output */
10175 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10176 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10177 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10178
10179 /* Mic (rear) pin: input vref at 80% */
10180 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10182 /* Front Mic pin: input vref at 80% */
10183 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10184 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10185 /* Line In pin: input */
10186 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10187 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10188 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10189 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10190 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10191 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10192 /* CD pin widget for input */
10193 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10194
10195 { }
10196};
10197
10198/*
10199 * 6-stack pin configuration:
10200 */
10201static struct hda_verb alc861vd_6stack_init_verbs[] = {
10202 /*
10203 * Set pin mode and muting
10204 */
10205 /* set front pin widgets 0x14 for output */
10206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10208 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10209
10210 /* Rear Pin: output 1 (0x0d) */
10211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10213 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10214 /* CLFE Pin: output 2 (0x0e) */
10215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10216 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10217 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10218 /* Side Pin: output 3 (0x0f) */
10219 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10220 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10221 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10222
10223 /* Mic (rear) pin: input vref at 80% */
10224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10225 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10226 /* Front Mic pin: input vref at 80% */
10227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10228 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10229 /* Line In pin: input */
10230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10231 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10232 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10234 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10235 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10236 /* CD pin widget for input */
10237 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10238
10239 { }
10240};
10241
Kailang Yangbdd148a2007-05-08 15:19:08 +020010242static struct hda_verb alc861vd_eapd_verbs[] = {
10243 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10244 { }
10245};
10246
10247static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10251 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10252 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10253 {}
10254};
10255
10256/* toggle speaker-output according to the hp-jack state */
10257static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10258{
10259 unsigned int present;
10260 unsigned char bits;
10261
10262 present = snd_hda_codec_read(codec, 0x1b, 0,
10263 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10264 bits = present ? 0x80 : 0;
10265 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10266 0x80, bits);
10267 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10268 0x80, bits);
10269}
10270
10271static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10272{
10273 unsigned int present;
10274 unsigned char bits;
10275
10276 present = snd_hda_codec_read(codec, 0x18, 0,
10277 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10278 bits = present ? 0x80 : 0;
10279 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10280 0x80, bits);
10281 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10282 0x80, bits);
10283}
10284
10285static void alc861vd_lenovo_automute(struct hda_codec *codec)
10286{
10287 alc861vd_lenovo_hp_automute(codec);
10288 alc861vd_lenovo_mic_automute(codec);
10289}
10290
10291static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10292 unsigned int res)
10293{
10294 switch (res >> 26) {
10295 case ALC880_HP_EVENT:
10296 alc861vd_lenovo_hp_automute(codec);
10297 break;
10298 case ALC880_MIC_EVENT:
10299 alc861vd_lenovo_mic_automute(codec);
10300 break;
10301 }
10302}
10303
Kailang Yang272a5272007-05-14 11:00:38 +020010304static struct hda_verb alc861vd_dallas_verbs[] = {
10305 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10306 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10307 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10308 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10309
10310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10315 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10316 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10317 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10318
10319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10320 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10323 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10324 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10325 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10326 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10327
10328 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10329 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10330 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10331 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10332 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10334 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10335 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10336
10337 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10341
10342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10343 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10344 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10345
10346 { } /* end */
10347};
10348
10349/* toggle speaker-output according to the hp-jack state */
10350static void alc861vd_dallas_automute(struct hda_codec *codec)
10351{
10352 unsigned int present;
10353
10354 present = snd_hda_codec_read(codec, 0x15, 0,
10355 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10356 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10357 0x80, present ? 0x80 : 0);
10358 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10359 0x80, present ? 0x80 : 0);
10360}
10361
10362static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10363{
10364 if ((res >> 26) == ALC880_HP_EVENT)
10365 alc861vd_dallas_automute(codec);
10366}
10367
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010368/* pcm configuration: identiacal with ALC880 */
10369#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10370#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10371#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10372#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10373
10374/*
10375 * configuration and preset
10376 */
10377static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10378 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +020010379 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010380 [ALC861VD_3ST] = "3stack",
10381 [ALC861VD_3ST_DIG] = "3stack-digout",
10382 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010383 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010384 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010385 [ALC861VD_AUTO] = "auto",
10386};
10387
10388static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010389 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010390 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010391 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010392 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10393 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10394
Kailang Yang272a5272007-05-14 11:00:38 +020010395 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10396 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010397 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10398 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010399 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020010400 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010401 {}
10402};
10403
10404static struct alc_config_preset alc861vd_presets[] = {
10405 [ALC660VD_3ST] = {
10406 .mixers = { alc861vd_3st_mixer },
10407 .init_verbs = { alc861vd_volume_init_verbs,
10408 alc861vd_3stack_init_verbs },
10409 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10410 .dac_nids = alc660vd_dac_nids,
10411 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10412 .adc_nids = alc861vd_adc_nids,
10413 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10414 .channel_mode = alc861vd_3stack_2ch_modes,
10415 .input_mux = &alc861vd_capture_source,
10416 },
Mike Crash6963f842007-06-25 12:12:51 +020010417 [ALC660VD_3ST_DIG] = {
10418 .mixers = { alc861vd_3st_mixer },
10419 .init_verbs = { alc861vd_volume_init_verbs,
10420 alc861vd_3stack_init_verbs },
10421 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10422 .dac_nids = alc660vd_dac_nids,
10423 .dig_out_nid = ALC861VD_DIGOUT_NID,
10424 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10425 .adc_nids = alc861vd_adc_nids,
10426 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10427 .channel_mode = alc861vd_3stack_2ch_modes,
10428 .input_mux = &alc861vd_capture_source,
10429 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010430 [ALC861VD_3ST] = {
10431 .mixers = { alc861vd_3st_mixer },
10432 .init_verbs = { alc861vd_volume_init_verbs,
10433 alc861vd_3stack_init_verbs },
10434 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10435 .dac_nids = alc861vd_dac_nids,
10436 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10437 .channel_mode = alc861vd_3stack_2ch_modes,
10438 .input_mux = &alc861vd_capture_source,
10439 },
10440 [ALC861VD_3ST_DIG] = {
10441 .mixers = { alc861vd_3st_mixer },
10442 .init_verbs = { alc861vd_volume_init_verbs,
10443 alc861vd_3stack_init_verbs },
10444 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10445 .dac_nids = alc861vd_dac_nids,
10446 .dig_out_nid = ALC861VD_DIGOUT_NID,
10447 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10448 .channel_mode = alc861vd_3stack_2ch_modes,
10449 .input_mux = &alc861vd_capture_source,
10450 },
10451 [ALC861VD_6ST_DIG] = {
10452 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10453 .init_verbs = { alc861vd_volume_init_verbs,
10454 alc861vd_6stack_init_verbs },
10455 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10456 .dac_nids = alc861vd_dac_nids,
10457 .dig_out_nid = ALC861VD_DIGOUT_NID,
10458 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10459 .channel_mode = alc861vd_6stack_modes,
10460 .input_mux = &alc861vd_capture_source,
10461 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010462 [ALC861VD_LENOVO] = {
10463 .mixers = { alc861vd_lenovo_mixer },
10464 .init_verbs = { alc861vd_volume_init_verbs,
10465 alc861vd_3stack_init_verbs,
10466 alc861vd_eapd_verbs,
10467 alc861vd_lenovo_unsol_verbs },
10468 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10469 .dac_nids = alc660vd_dac_nids,
10470 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10471 .adc_nids = alc861vd_adc_nids,
10472 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10473 .channel_mode = alc861vd_3stack_2ch_modes,
10474 .input_mux = &alc861vd_capture_source,
10475 .unsol_event = alc861vd_lenovo_unsol_event,
10476 .init_hook = alc861vd_lenovo_automute,
10477 },
Kailang Yang272a5272007-05-14 11:00:38 +020010478 [ALC861VD_DALLAS] = {
10479 .mixers = { alc861vd_dallas_mixer },
10480 .init_verbs = { alc861vd_dallas_verbs },
10481 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10482 .dac_nids = alc861vd_dac_nids,
10483 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10484 .adc_nids = alc861vd_adc_nids,
10485 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10486 .channel_mode = alc861vd_3stack_2ch_modes,
10487 .input_mux = &alc861vd_dallas_capture_source,
10488 .unsol_event = alc861vd_dallas_unsol_event,
10489 .init_hook = alc861vd_dallas_automute,
10490 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010491};
10492
10493/*
10494 * BIOS auto configuration
10495 */
10496static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10497 hda_nid_t nid, int pin_type, int dac_idx)
10498{
10499 /* set as output */
10500 snd_hda_codec_write(codec, nid, 0,
10501 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10502 snd_hda_codec_write(codec, nid, 0,
10503 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10504}
10505
10506static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10507{
10508 struct alc_spec *spec = codec->spec;
10509 int i;
10510
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010511 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010512 for (i = 0; i <= HDA_SIDE; i++) {
10513 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010514 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010515 if (nid)
10516 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010517 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010518 }
10519}
10520
10521
10522static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10523{
10524 struct alc_spec *spec = codec->spec;
10525 hda_nid_t pin;
10526
10527 pin = spec->autocfg.hp_pins[0];
10528 if (pin) /* connect to front and use dac 0 */
10529 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10530}
10531
10532#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10533#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10534
10535static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10536{
10537 struct alc_spec *spec = codec->spec;
10538 int i;
10539
10540 for (i = 0; i < AUTO_PIN_LAST; i++) {
10541 hda_nid_t nid = spec->autocfg.input_pins[i];
10542 if (alc861vd_is_input_pin(nid)) {
10543 snd_hda_codec_write(codec, nid, 0,
10544 AC_VERB_SET_PIN_WIDGET_CONTROL,
10545 i <= AUTO_PIN_FRONT_MIC ?
10546 PIN_VREF80 : PIN_IN);
10547 if (nid != ALC861VD_PIN_CD_NID)
10548 snd_hda_codec_write(codec, nid, 0,
10549 AC_VERB_SET_AMP_GAIN_MUTE,
10550 AMP_OUT_MUTE);
10551 }
10552 }
10553}
10554
10555#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10556#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10557
10558/* add playback controls from the parsed DAC table */
10559/* Based on ALC880 version. But ALC861VD has separate,
10560 * different NIDs for mute/unmute switch and volume control */
10561static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10562 const struct auto_pin_cfg *cfg)
10563{
10564 char name[32];
10565 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10566 hda_nid_t nid_v, nid_s;
10567 int i, err;
10568
10569 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010570 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010571 continue;
10572 nid_v = alc861vd_idx_to_mixer_vol(
10573 alc880_dac_to_idx(
10574 spec->multiout.dac_nids[i]));
10575 nid_s = alc861vd_idx_to_mixer_switch(
10576 alc880_dac_to_idx(
10577 spec->multiout.dac_nids[i]));
10578
10579 if (i == 2) {
10580 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010581 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10582 "Center Playback Volume",
10583 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10584 HDA_OUTPUT));
10585 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010586 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010587 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10588 "LFE Playback Volume",
10589 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10590 HDA_OUTPUT));
10591 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010592 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010593 err = add_control(spec, ALC_CTL_BIND_MUTE,
10594 "Center Playback Switch",
10595 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10596 HDA_INPUT));
10597 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010598 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010599 err = add_control(spec, ALC_CTL_BIND_MUTE,
10600 "LFE Playback Switch",
10601 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10602 HDA_INPUT));
10603 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010604 return err;
10605 } else {
10606 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010607 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10608 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10609 HDA_OUTPUT));
10610 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010611 return err;
10612 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010613 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010614 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010615 HDA_INPUT));
10616 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010617 return err;
10618 }
10619 }
10620 return 0;
10621}
10622
10623/* add playback controls for speaker and HP outputs */
10624/* Based on ALC880 version. But ALC861VD has separate,
10625 * different NIDs for mute/unmute switch and volume control */
10626static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10627 hda_nid_t pin, const char *pfx)
10628{
10629 hda_nid_t nid_v, nid_s;
10630 int err;
10631 char name[32];
10632
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010633 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010634 return 0;
10635
10636 if (alc880_is_fixed_pin(pin)) {
10637 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10638 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010639 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010640 spec->multiout.hp_nid = nid_v;
10641 else
10642 spec->multiout.extra_out_nid[0] = nid_v;
10643 /* control HP volume/switch on the output mixer amp */
10644 nid_v = alc861vd_idx_to_mixer_vol(
10645 alc880_fixed_pin_idx(pin));
10646 nid_s = alc861vd_idx_to_mixer_switch(
10647 alc880_fixed_pin_idx(pin));
10648
10649 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010650 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10651 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10652 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010653 return err;
10654 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010655 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10656 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10657 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010658 return err;
10659 } else if (alc880_is_multi_pin(pin)) {
10660 /* set manual connection */
10661 /* we have only a switch on HP-out PIN */
10662 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010663 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10664 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10665 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010666 return err;
10667 }
10668 return 0;
10669}
10670
10671/* parse the BIOS configuration and set up the alc_spec
10672 * return 1 if successful, 0 if the proper config is not found,
10673 * or a negative error code
10674 * Based on ALC880 version - had to change it to override
10675 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10676static int alc861vd_parse_auto_config(struct hda_codec *codec)
10677{
10678 struct alc_spec *spec = codec->spec;
10679 int err;
10680 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10681
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010682 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10683 alc861vd_ignore);
10684 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010685 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010686 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010687 return 0; /* can't find valid BIOS pin config */
10688
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010689 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10690 if (err < 0)
10691 return err;
10692 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10693 if (err < 0)
10694 return err;
10695 err = alc861vd_auto_create_extra_out(spec,
10696 spec->autocfg.speaker_pins[0],
10697 "Speaker");
10698 if (err < 0)
10699 return err;
10700 err = alc861vd_auto_create_extra_out(spec,
10701 spec->autocfg.hp_pins[0],
10702 "Headphone");
10703 if (err < 0)
10704 return err;
10705 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10706 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010707 return err;
10708
10709 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10710
10711 if (spec->autocfg.dig_out_pin)
10712 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10713
10714 if (spec->kctl_alloc)
10715 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10716
10717 spec->init_verbs[spec->num_init_verbs++]
10718 = alc861vd_volume_init_verbs;
10719
10720 spec->num_mux_defs = 1;
10721 spec->input_mux = &spec->private_imux;
10722
10723 return 1;
10724}
10725
10726/* additional initialization for auto-configuration model */
10727static void alc861vd_auto_init(struct hda_codec *codec)
10728{
10729 alc861vd_auto_init_multi_out(codec);
10730 alc861vd_auto_init_hp_out(codec);
10731 alc861vd_auto_init_analog_input(codec);
10732}
10733
10734static int patch_alc861vd(struct hda_codec *codec)
10735{
10736 struct alc_spec *spec;
10737 int err, board_config;
10738
10739 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10740 if (spec == NULL)
10741 return -ENOMEM;
10742
10743 codec->spec = spec;
10744
10745 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10746 alc861vd_models,
10747 alc861vd_cfg_tbl);
10748
10749 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10750 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10751 "ALC861VD, trying auto-probe from BIOS...\n");
10752 board_config = ALC861VD_AUTO;
10753 }
10754
10755 if (board_config == ALC861VD_AUTO) {
10756 /* automatic parse from the BIOS config */
10757 err = alc861vd_parse_auto_config(codec);
10758 if (err < 0) {
10759 alc_free(codec);
10760 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010761 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010762 printk(KERN_INFO
10763 "hda_codec: Cannot set up configuration "
10764 "from BIOS. Using base mode...\n");
10765 board_config = ALC861VD_3ST;
10766 }
10767 }
10768
10769 if (board_config != ALC861VD_AUTO)
10770 setup_preset(spec, &alc861vd_presets[board_config]);
10771
10772 spec->stream_name_analog = "ALC861VD Analog";
10773 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10774 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10775
10776 spec->stream_name_digital = "ALC861VD Digital";
10777 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10778 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10779
10780 spec->adc_nids = alc861vd_adc_nids;
10781 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10782
10783 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10784 spec->num_mixers++;
10785
10786 codec->patch_ops = alc_patch_ops;
10787
10788 if (board_config == ALC861VD_AUTO)
10789 spec->init_hook = alc861vd_auto_init;
10790
10791 return 0;
10792}
10793
10794/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010795 * ALC662 support
10796 *
10797 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10798 * configuration. Each pin widget can choose any input DACs and a mixer.
10799 * Each ADC is connected from a mixer of all inputs. This makes possible
10800 * 6-channel independent captures.
10801 *
10802 * In addition, an independent DAC for the multi-playback (not used in this
10803 * driver yet).
10804 */
10805#define ALC662_DIGOUT_NID 0x06
10806#define ALC662_DIGIN_NID 0x0a
10807
10808static hda_nid_t alc662_dac_nids[4] = {
10809 /* front, rear, clfe, rear_surr */
10810 0x02, 0x03, 0x04
10811};
10812
10813static hda_nid_t alc662_adc_nids[1] = {
10814 /* ADC1-2 */
10815 0x09,
10816};
10817/* input MUX */
10818/* FIXME: should be a matrix-type input source selection */
10819
10820static struct hda_input_mux alc662_capture_source = {
10821 .num_items = 4,
10822 .items = {
10823 { "Mic", 0x0 },
10824 { "Front Mic", 0x1 },
10825 { "Line", 0x2 },
10826 { "CD", 0x4 },
10827 },
10828};
10829
10830static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10831 .num_items = 2,
10832 .items = {
10833 { "Mic", 0x1 },
10834 { "Line", 0x2 },
10835 },
10836};
10837#define alc662_mux_enum_info alc_mux_enum_info
10838#define alc662_mux_enum_get alc_mux_enum_get
10839
10840static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10841 struct snd_ctl_elem_value *ucontrol)
10842{
10843 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10844 struct alc_spec *spec = codec->spec;
10845 const struct hda_input_mux *imux = spec->input_mux;
10846 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10847 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10848 hda_nid_t nid = capture_mixers[adc_idx];
10849 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10850 unsigned int i, idx;
10851
10852 idx = ucontrol->value.enumerated.item[0];
10853 if (idx >= imux->num_items)
10854 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010855 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010856 return 0;
10857 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010858 unsigned int v = (i == idx) ? 0x00 : 0x80;
10859 snd_hda_codec_amp_update(codec, nid, 0, HDA_INPUT,
10860 imux->items[i].index, 0x80, v);
10861 snd_hda_codec_amp_update(codec, nid, 1, HDA_INPUT,
10862 imux->items[i].index, 0x80, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010863 }
10864 *cur_val = idx;
10865 return 1;
10866}
10867/*
10868 * 2ch mode
10869 */
10870static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10871 { 2, NULL }
10872};
10873
10874/*
10875 * 2ch mode
10876 */
10877static struct hda_verb alc662_3ST_ch2_init[] = {
10878 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10879 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10880 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10881 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10882 { } /* end */
10883};
10884
10885/*
10886 * 6ch mode
10887 */
10888static struct hda_verb alc662_3ST_ch6_init[] = {
10889 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10890 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10891 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10892 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10893 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10894 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10895 { } /* end */
10896};
10897
10898static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10899 { 2, alc662_3ST_ch2_init },
10900 { 6, alc662_3ST_ch6_init },
10901};
10902
10903/*
10904 * 2ch mode
10905 */
10906static struct hda_verb alc662_sixstack_ch6_init[] = {
10907 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10908 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10909 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10910 { } /* end */
10911};
10912
10913/*
10914 * 6ch mode
10915 */
10916static struct hda_verb alc662_sixstack_ch8_init[] = {
10917 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10918 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10919 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10920 { } /* end */
10921};
10922
10923static struct hda_channel_mode alc662_5stack_modes[2] = {
10924 { 2, alc662_sixstack_ch6_init },
10925 { 6, alc662_sixstack_ch8_init },
10926};
10927
10928/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10929 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10930 */
10931
10932static struct snd_kcontrol_new alc662_base_mixer[] = {
10933 /* output mixer control */
10934 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10935 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10936 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10937 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10940 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10941 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10943
10944 /*Input mixer control */
10945 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10946 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10947 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10948 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10949 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10950 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10951 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10953
10954 /* Capture mixer control */
10955 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10956 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10957 {
10958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10959 .name = "Capture Source",
10960 .count = 1,
10961 .info = alc_mux_enum_info,
10962 .get = alc_mux_enum_get,
10963 .put = alc_mux_enum_put,
10964 },
10965 { } /* end */
10966};
10967
10968static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10969 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10970 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10978 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10979 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10980 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10981 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10982 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10983 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10984 {
10985 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10986 /* .name = "Capture Source", */
10987 .name = "Input Source",
10988 .count = 1,
10989 .info = alc662_mux_enum_info,
10990 .get = alc662_mux_enum_get,
10991 .put = alc662_mux_enum_put,
10992 },
10993 { } /* end */
10994};
10995
10996static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10997 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10998 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10999 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11000 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11001 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11002 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11003 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11004 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11012 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11013 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11014 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11015 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11016 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11017 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11018 {
11019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11020 /* .name = "Capture Source", */
11021 .name = "Input Source",
11022 .count = 1,
11023 .info = alc662_mux_enum_info,
11024 .get = alc662_mux_enum_get,
11025 .put = alc662_mux_enum_put,
11026 },
11027 { } /* end */
11028};
11029
11030static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11031 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11032 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11033 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11034 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11035 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11036 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11037 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11038 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11039 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11040 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11041 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11042 {
11043 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11044 /* .name = "Capture Source", */
11045 .name = "Input Source",
11046 .count = 1,
11047 .info = alc662_mux_enum_info,
11048 .get = alc662_mux_enum_get,
11049 .put = alc662_mux_enum_put,
11050 },
11051 { } /* end */
11052};
11053
11054static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11055 {
11056 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11057 .name = "Channel Mode",
11058 .info = alc_ch_mode_info,
11059 .get = alc_ch_mode_get,
11060 .put = alc_ch_mode_put,
11061 },
11062 { } /* end */
11063};
11064
11065static struct hda_verb alc662_init_verbs[] = {
11066 /* ADC: mute amp left and right */
11067 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11068 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11069 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11070
11071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11076
11077 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11078 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11079 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11080 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11081 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11082 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11083
11084 /* Front Pin: output 0 (0x0c) */
11085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11086 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11087
11088 /* Rear Pin: output 1 (0x0d) */
11089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11091
11092 /* CLFE Pin: output 2 (0x0e) */
11093 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11094 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11095
11096 /* Mic (rear) pin: input vref at 80% */
11097 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11098 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11099 /* Front Mic pin: input vref at 80% */
11100 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11102 /* Line In pin: input */
11103 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11105 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11106 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11107 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11108 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11109 /* CD pin widget for input */
11110 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11111
11112 /* FIXME: use matrix-type input source selection */
11113 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11114 /* Input mixer */
11115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11119 { }
11120};
11121
11122static struct hda_verb alc662_sue_init_verbs[] = {
11123 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11124 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11125 {}
11126};
11127
11128/*
11129 * generic initialization of ADC, input mixers and output mixers
11130 */
11131static struct hda_verb alc662_auto_init_verbs[] = {
11132 /*
11133 * Unmute ADC and set the default input to mic-in
11134 */
11135 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11136 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11137
11138 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11139 * mixer widget
11140 * Note: PASD motherboards uses the Line In 2 as the input for front
11141 * panel mic (mic 2)
11142 */
11143 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11149
11150 /*
11151 * Set up output mixers (0x0c - 0x0f)
11152 */
11153 /* set vol=0 to output mixers */
11154 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11155 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11156 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11157
11158 /* set up input amps for analog loopback */
11159 /* Amp Indices: DAC = 0, mixer = 1 */
11160 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11161 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11162 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11163 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11164 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11165 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11166
11167
11168 /* FIXME: use matrix-type input source selection */
11169 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11170 /* Input mixer */
11171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11174 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
11175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11176
11177 { }
11178};
11179
11180/* capture mixer elements */
11181static struct snd_kcontrol_new alc662_capture_mixer[] = {
11182 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11183 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11184 {
11185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11186 /* The multiple "Capture Source" controls confuse alsamixer
11187 * So call somewhat different..
11188 * FIXME: the controls appear in the "playback" view!
11189 */
11190 /* .name = "Capture Source", */
11191 .name = "Input Source",
11192 .count = 1,
11193 .info = alc882_mux_enum_info,
11194 .get = alc882_mux_enum_get,
11195 .put = alc882_mux_enum_put,
11196 },
11197 { } /* end */
11198};
11199
11200static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11201{
11202 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011203 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011204
11205 present = snd_hda_codec_read(codec, 0x14, 0,
11206 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011207 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011208 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011209 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011210 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011211 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011212}
11213
11214static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11215{
11216 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011217 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011218
11219 present = snd_hda_codec_read(codec, 0x1b, 0,
11220 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011221 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011222 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011223 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011224 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011225 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011226 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011227 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011228 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011229 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011230}
11231
11232static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11233 unsigned int res)
11234{
11235 if ((res >> 26) == ALC880_HP_EVENT)
11236 alc662_lenovo_101e_all_automute(codec);
11237 if ((res >> 26) == ALC880_FRONT_EVENT)
11238 alc662_lenovo_101e_ispeaker_automute(codec);
11239}
11240
11241
11242/* pcm configuration: identiacal with ALC880 */
11243#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11244#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11245#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11246#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11247
11248/*
11249 * configuration and preset
11250 */
11251static const char *alc662_models[ALC662_MODEL_LAST] = {
11252 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11253 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11254 [ALC662_3ST_6ch] = "3stack-6ch",
11255 [ALC662_5ST_DIG] = "6stack-dig",
11256 [ALC662_LENOVO_101E] = "lenovo-101e",
11257 [ALC662_AUTO] = "auto",
11258};
11259
11260static struct snd_pci_quirk alc662_cfg_tbl[] = {
11261 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11262 {}
11263};
11264
11265static struct alc_config_preset alc662_presets[] = {
11266 [ALC662_3ST_2ch_DIG] = {
11267 .mixers = { alc662_3ST_2ch_mixer },
11268 .init_verbs = { alc662_init_verbs },
11269 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11270 .dac_nids = alc662_dac_nids,
11271 .dig_out_nid = ALC662_DIGOUT_NID,
11272 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11273 .adc_nids = alc662_adc_nids,
11274 .dig_in_nid = ALC662_DIGIN_NID,
11275 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11276 .channel_mode = alc662_3ST_2ch_modes,
11277 .input_mux = &alc662_capture_source,
11278 },
11279 [ALC662_3ST_6ch_DIG] = {
11280 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11281 .init_verbs = { alc662_init_verbs },
11282 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11283 .dac_nids = alc662_dac_nids,
11284 .dig_out_nid = ALC662_DIGOUT_NID,
11285 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11286 .adc_nids = alc662_adc_nids,
11287 .dig_in_nid = ALC662_DIGIN_NID,
11288 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11289 .channel_mode = alc662_3ST_6ch_modes,
11290 .need_dac_fix = 1,
11291 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011292 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011293 [ALC662_3ST_6ch] = {
11294 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11295 .init_verbs = { alc662_init_verbs },
11296 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11297 .dac_nids = alc662_dac_nids,
11298 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11299 .adc_nids = alc662_adc_nids,
11300 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11301 .channel_mode = alc662_3ST_6ch_modes,
11302 .need_dac_fix = 1,
11303 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011304 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011305 [ALC662_5ST_DIG] = {
11306 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11307 .init_verbs = { alc662_init_verbs },
11308 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11309 .dac_nids = alc662_dac_nids,
11310 .dig_out_nid = ALC662_DIGOUT_NID,
11311 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11312 .adc_nids = alc662_adc_nids,
11313 .dig_in_nid = ALC662_DIGIN_NID,
11314 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11315 .channel_mode = alc662_5stack_modes,
11316 .input_mux = &alc662_capture_source,
11317 },
11318 [ALC662_LENOVO_101E] = {
11319 .mixers = { alc662_lenovo_101e_mixer },
11320 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11321 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11322 .dac_nids = alc662_dac_nids,
11323 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11324 .adc_nids = alc662_adc_nids,
11325 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11326 .channel_mode = alc662_3ST_2ch_modes,
11327 .input_mux = &alc662_lenovo_101e_capture_source,
11328 .unsol_event = alc662_lenovo_101e_unsol_event,
11329 .init_hook = alc662_lenovo_101e_all_automute,
11330 },
11331
11332};
11333
11334
11335/*
11336 * BIOS auto configuration
11337 */
11338
11339/* add playback controls from the parsed DAC table */
11340static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11341 const struct auto_pin_cfg *cfg)
11342{
11343 char name[32];
11344 static const char *chname[4] = {
11345 "Front", "Surround", NULL /*CLFE*/, "Side"
11346 };
11347 hda_nid_t nid;
11348 int i, err;
11349
11350 for (i = 0; i < cfg->line_outs; i++) {
11351 if (!spec->multiout.dac_nids[i])
11352 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011353 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011354 if (i == 2) {
11355 /* Center/LFE */
11356 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11357 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011358 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11359 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011360 if (err < 0)
11361 return err;
11362 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11363 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011364 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11365 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011366 if (err < 0)
11367 return err;
11368 err = add_control(spec, ALC_CTL_BIND_MUTE,
11369 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011370 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11371 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011372 if (err < 0)
11373 return err;
11374 err = add_control(spec, ALC_CTL_BIND_MUTE,
11375 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011376 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11377 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011378 if (err < 0)
11379 return err;
11380 } else {
11381 sprintf(name, "%s Playback Volume", chname[i]);
11382 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011383 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11384 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011385 if (err < 0)
11386 return err;
11387 sprintf(name, "%s Playback Switch", chname[i]);
11388 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011389 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11390 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011391 if (err < 0)
11392 return err;
11393 }
11394 }
11395 return 0;
11396}
11397
11398/* add playback controls for speaker and HP outputs */
11399static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11400 const char *pfx)
11401{
11402 hda_nid_t nid;
11403 int err;
11404 char name[32];
11405
11406 if (!pin)
11407 return 0;
11408
11409 if (alc880_is_fixed_pin(pin)) {
11410 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11411 /* printk("DAC nid=%x\n",nid); */
11412 /* specify the DAC as the extra output */
11413 if (!spec->multiout.hp_nid)
11414 spec->multiout.hp_nid = nid;
11415 else
11416 spec->multiout.extra_out_nid[0] = nid;
11417 /* control HP volume/switch on the output mixer amp */
11418 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11419 sprintf(name, "%s Playback Volume", pfx);
11420 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11421 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11422 if (err < 0)
11423 return err;
11424 sprintf(name, "%s Playback Switch", pfx);
11425 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11426 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11427 if (err < 0)
11428 return err;
11429 } else if (alc880_is_multi_pin(pin)) {
11430 /* set manual connection */
11431 /* we have only a switch on HP-out PIN */
11432 sprintf(name, "%s Playback Switch", pfx);
11433 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11434 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11435 if (err < 0)
11436 return err;
11437 }
11438 return 0;
11439}
11440
11441/* create playback/capture controls for input pins */
11442static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11443 const struct auto_pin_cfg *cfg)
11444{
11445 struct hda_input_mux *imux = &spec->private_imux;
11446 int i, err, idx;
11447
11448 for (i = 0; i < AUTO_PIN_LAST; i++) {
11449 if (alc880_is_input_pin(cfg->input_pins[i])) {
11450 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11451 err = new_analog_input(spec, cfg->input_pins[i],
11452 auto_pin_cfg_labels[i],
11453 idx, 0x0b);
11454 if (err < 0)
11455 return err;
11456 imux->items[imux->num_items].label =
11457 auto_pin_cfg_labels[i];
11458 imux->items[imux->num_items].index =
11459 alc880_input_pin_idx(cfg->input_pins[i]);
11460 imux->num_items++;
11461 }
11462 }
11463 return 0;
11464}
11465
11466static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11467 hda_nid_t nid, int pin_type,
11468 int dac_idx)
11469{
11470 /* set as output */
11471 snd_hda_codec_write(codec, nid, 0,
11472 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11473 snd_hda_codec_write(codec, nid, 0,
11474 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11475 /* need the manual connection? */
11476 if (alc880_is_multi_pin(nid)) {
11477 struct alc_spec *spec = codec->spec;
11478 int idx = alc880_multi_pin_idx(nid);
11479 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11480 AC_VERB_SET_CONNECT_SEL,
11481 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11482 }
11483}
11484
11485static void alc662_auto_init_multi_out(struct hda_codec *codec)
11486{
11487 struct alc_spec *spec = codec->spec;
11488 int i;
11489
11490 for (i = 0; i <= HDA_SIDE; i++) {
11491 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011492 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011493 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011494 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011495 i);
11496 }
11497}
11498
11499static void alc662_auto_init_hp_out(struct hda_codec *codec)
11500{
11501 struct alc_spec *spec = codec->spec;
11502 hda_nid_t pin;
11503
11504 pin = spec->autocfg.hp_pins[0];
11505 if (pin) /* connect to front */
11506 /* use dac 0 */
11507 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11508}
11509
11510#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11511#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11512
11513static void alc662_auto_init_analog_input(struct hda_codec *codec)
11514{
11515 struct alc_spec *spec = codec->spec;
11516 int i;
11517
11518 for (i = 0; i < AUTO_PIN_LAST; i++) {
11519 hda_nid_t nid = spec->autocfg.input_pins[i];
11520 if (alc662_is_input_pin(nid)) {
11521 snd_hda_codec_write(codec, nid, 0,
11522 AC_VERB_SET_PIN_WIDGET_CONTROL,
11523 (i <= AUTO_PIN_FRONT_MIC ?
11524 PIN_VREF80 : PIN_IN));
11525 if (nid != ALC662_PIN_CD_NID)
11526 snd_hda_codec_write(codec, nid, 0,
11527 AC_VERB_SET_AMP_GAIN_MUTE,
11528 AMP_OUT_MUTE);
11529 }
11530 }
11531}
11532
11533static int alc662_parse_auto_config(struct hda_codec *codec)
11534{
11535 struct alc_spec *spec = codec->spec;
11536 int err;
11537 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11538
11539 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11540 alc662_ignore);
11541 if (err < 0)
11542 return err;
11543 if (!spec->autocfg.line_outs)
11544 return 0; /* can't find valid BIOS pin config */
11545
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011546 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11547 if (err < 0)
11548 return err;
11549 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11550 if (err < 0)
11551 return err;
11552 err = alc662_auto_create_extra_out(spec,
11553 spec->autocfg.speaker_pins[0],
11554 "Speaker");
11555 if (err < 0)
11556 return err;
11557 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11558 "Headphone");
11559 if (err < 0)
11560 return err;
11561 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11562 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011563 return err;
11564
11565 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11566
11567 if (spec->autocfg.dig_out_pin)
11568 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11569
11570 if (spec->kctl_alloc)
11571 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11572
11573 spec->num_mux_defs = 1;
11574 spec->input_mux = &spec->private_imux;
11575
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011576 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011577 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11578 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011579 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011580}
11581
11582/* additional initialization for auto-configuration model */
11583static void alc662_auto_init(struct hda_codec *codec)
11584{
11585 alc662_auto_init_multi_out(codec);
11586 alc662_auto_init_hp_out(codec);
11587 alc662_auto_init_analog_input(codec);
11588}
11589
11590static int patch_alc662(struct hda_codec *codec)
11591{
11592 struct alc_spec *spec;
11593 int err, board_config;
11594
11595 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11596 if (!spec)
11597 return -ENOMEM;
11598
11599 codec->spec = spec;
11600
11601 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11602 alc662_models,
11603 alc662_cfg_tbl);
11604 if (board_config < 0) {
11605 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11606 "trying auto-probe from BIOS...\n");
11607 board_config = ALC662_AUTO;
11608 }
11609
11610 if (board_config == ALC662_AUTO) {
11611 /* automatic parse from the BIOS config */
11612 err = alc662_parse_auto_config(codec);
11613 if (err < 0) {
11614 alc_free(codec);
11615 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011616 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011617 printk(KERN_INFO
11618 "hda_codec: Cannot set up configuration "
11619 "from BIOS. Using base mode...\n");
11620 board_config = ALC662_3ST_2ch_DIG;
11621 }
11622 }
11623
11624 if (board_config != ALC662_AUTO)
11625 setup_preset(spec, &alc662_presets[board_config]);
11626
11627 spec->stream_name_analog = "ALC662 Analog";
11628 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11629 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11630
11631 spec->stream_name_digital = "ALC662 Digital";
11632 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11633 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11634
11635 if (!spec->adc_nids && spec->input_mux) {
11636 spec->adc_nids = alc662_adc_nids;
11637 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11638 }
11639
11640 codec->patch_ops = alc_patch_ops;
11641 if (board_config == ALC662_AUTO)
11642 spec->init_hook = alc662_auto_init;
11643
11644 return 0;
11645}
11646
11647/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011648 * patch entries
11649 */
11650struct hda_codec_preset snd_hda_preset_realtek[] = {
11651 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011652 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011653 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011654 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011655 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011656 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11657 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11658 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011659 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11660 .patch = patch_alc883 },
11661 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11662 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011663 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011664 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011665 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011666 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011667 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011668 {} /* terminator */
11669};