blob: 9a47eec5a27bb27a7f24c00d7ab9189cb34ac98c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
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 Woithe7cf51e42006-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 Avdoninbab282b2006-08-22 13:31:58 +0200169 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200170 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200171 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100172 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200174 ALC883_LENOVO_NB0763,
175 ALC888_LENOVO_MS7195_DIG,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200176 ALC888_6ST_HP,
177 ALC888_3ST_HP,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200178 ALC883_AUTO,
179 ALC883_MODEL_LAST,
180};
181
Kailang Yangdf694da2005-12-05 19:42:22 +0100182/* for GPIO Poll */
183#define GPIO_MASK 0x03
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185struct alc_spec {
186 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100187 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 unsigned int num_mixers;
189
Kailang Yangdf694da2005-12-05 19:42:22 +0100190 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200191 * don't forget NULL
192 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200193 */
194 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
Takashi Iwai16ded522005-06-10 19:58:24 +0200196 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 struct hda_pcm_stream *stream_analog_playback;
198 struct hda_pcm_stream *stream_analog_capture;
199
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200200 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 struct hda_pcm_stream *stream_digital_playback;
202 struct hda_pcm_stream *stream_digital_capture;
203
204 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200205 struct hda_multi_out multiout; /* playback set-up
206 * max_channels, dacs must be set
207 * dig_out_nid and hp_nid are optional
208 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210 /* capture */
211 unsigned int num_adc_nids;
212 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200213 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200216 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 const struct hda_input_mux *input_mux;
218 unsigned int cur_mux[3];
219
220 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100221 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200223 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
225 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100226 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200227
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200228 /* dynamic controls, init_verbs and input_mux */
229 struct auto_pin_cfg autocfg;
230 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100231 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200232 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100233 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100234
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100235 /* hooks */
236 void (*init_hook)(struct hda_codec *codec);
237 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
238
Takashi Iwai834be882006-03-01 14:16:17 +0100239 /* for pin sensing */
240 unsigned int sense_updated: 1;
241 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100242};
243
244/*
245 * configuration template - to be copied to the spec instance
246 */
247struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200248 struct snd_kcontrol_new *mixers[5]; /* should be identical size
249 * with spec
250 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100251 const struct hda_verb *init_verbs[5];
252 unsigned int num_dacs;
253 hda_nid_t *dac_nids;
254 hda_nid_t dig_out_nid; /* optional */
255 hda_nid_t hp_nid; /* optional */
256 unsigned int num_adc_nids;
257 hda_nid_t *adc_nids;
258 hda_nid_t dig_in_nid;
259 unsigned int num_channel_mode;
260 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200261 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200262 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100263 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100264 void (*unsol_event)(struct hda_codec *, unsigned int);
265 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266};
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269/*
270 * input MUX handling
271 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200272static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
273 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274{
275 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
276 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200277 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
278 if (mux_idx >= spec->num_mux_defs)
279 mux_idx = 0;
280 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281}
282
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200283static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285{
286 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
287 struct alc_spec *spec = codec->spec;
288 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
289
290 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
291 return 0;
292}
293
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200294static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
295 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296{
297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
298 struct alc_spec *spec = codec->spec;
299 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200300 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
301 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200302 spec->adc_nids[adc_idx],
303 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304}
305
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307/*
308 * channel mode setting
309 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200310static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312{
313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
314 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100315 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
316 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317}
318
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200319static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
320 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321{
322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
323 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100324 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200325 spec->num_channel_mode,
326 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327}
328
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200329static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
330 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
333 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200334 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
335 spec->num_channel_mode,
336 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200337 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200338 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
339 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340}
341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100343 * Control the mode of pin widget settings via the mixer. "pc" is used
344 * instead of "%" to avoid consequences of accidently treating the % as
345 * being part of a format specifier. Maximum allowed length of a value is
346 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100347 *
348 * Note: some retasking pin complexes seem to ignore requests for input
349 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
350 * are requested. Therefore order this list so that this behaviour will not
351 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200352 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
353 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200354 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100355static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100356 "Mic 50pc bias", "Mic 80pc bias",
357 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100358};
359static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100360 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100361};
362/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200363 * in the pin being assumed to be exclusively an input or an output pin. In
364 * addition, "input" pins may or may not process the mic bias option
365 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
366 * accept requests for bias as of chip versions up to March 2006) and/or
367 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100368 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200369#define ALC_PIN_DIR_IN 0x00
370#define ALC_PIN_DIR_OUT 0x01
371#define ALC_PIN_DIR_INOUT 0x02
372#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
373#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200375/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100376 * For each direction the minimum and maximum values are given.
377 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200378static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100379 { 0, 2 }, /* ALC_PIN_DIR_IN */
380 { 3, 4 }, /* ALC_PIN_DIR_OUT */
381 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200382 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
383 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100384};
385#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
386#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
387#define alc_pin_mode_n_items(_dir) \
388 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
389
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200390static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200392{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100393 unsigned int item_num = uinfo->value.enumerated.item;
394 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
395
396 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200397 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100398 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
399
400 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
401 item_num = alc_pin_mode_min(dir);
402 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200403 return 0;
404}
405
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200406static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200408{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100409 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100412 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200413 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200414 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
415 AC_VERB_GET_PIN_WIDGET_CONTROL,
416 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200417
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418 /* Find enumerated value for current pinctl setting */
419 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100421 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200422 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423 return 0;
424}
425
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200426static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
427 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100428{
429 signed int change;
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
431 hda_nid_t nid = kcontrol->private_value & 0xffff;
432 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
433 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200434 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
435 AC_VERB_GET_PIN_WIDGET_CONTROL,
436 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200438 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100439 val = alc_pin_mode_min(dir);
440
441 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100442 if (change) {
443 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200444 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100446
447 /* Also enable the retasking pin's input/output as required
448 * for the requested pin mode. Enum values of 2 or less are
449 * input modes.
450 *
451 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200452 * reduces noise slightly (particularly on input) so we'll
453 * do it. However, having both input and output buffers
454 * enabled simultaneously doesn't seem to be problematic if
455 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100456 */
457 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458 snd_hda_codec_write(codec, nid, 0,
459 AC_VERB_SET_AMP_GAIN_MUTE,
460 AMP_OUT_MUTE);
461 snd_hda_codec_write(codec, nid, 0,
462 AC_VERB_SET_AMP_GAIN_MUTE,
463 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100464 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200465 snd_hda_codec_write(codec, nid, 0,
466 AC_VERB_SET_AMP_GAIN_MUTE,
467 AMP_IN_MUTE(0));
468 snd_hda_codec_write(codec, nid, 0,
469 AC_VERB_SET_AMP_GAIN_MUTE,
470 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100471 }
472 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200473 return change;
474}
475
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200477 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478 .info = alc_pin_mode_info, \
479 .get = alc_pin_mode_get, \
480 .put = alc_pin_mode_put, \
481 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100482
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100483/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
484 * together using a mask with more than one bit set. This control is
485 * currently used only by the ALC260 test model. At this stage they are not
486 * needed for any "production" models.
487 */
488#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200489static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
490 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100491{
492 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
493 uinfo->count = 1;
494 uinfo->value.integer.min = 0;
495 uinfo->value.integer.max = 1;
496 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200497}
498
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200499static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100501{
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 hda_nid_t nid = kcontrol->private_value & 0xffff;
504 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
505 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200506 unsigned int val = snd_hda_codec_read(codec, nid, 0,
507 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100508
509 *valp = (val & mask) != 0;
510 return 0;
511}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200512static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
513 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100514{
515 signed int change;
516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
517 hda_nid_t nid = kcontrol->private_value & 0xffff;
518 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
519 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200520 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
521 AC_VERB_GET_GPIO_DATA,
522 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100523
524 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
526 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100527 gpio_data &= ~mask;
528 else
529 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100531
532 return change;
533}
534#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
535 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
536 .info = alc_gpio_data_info, \
537 .get = alc_gpio_data_get, \
538 .put = alc_gpio_data_put, \
539 .private_value = nid | (mask<<16) }
540#endif /* CONFIG_SND_DEBUG */
541
Jonathan Woithe92621f12006-02-28 11:47:47 +0100542/* A switch control to allow the enabling of the digital IO pins on the
543 * ALC260. This is incredibly simplistic; the intention of this control is
544 * to provide something in the test model allowing digital outputs to be
545 * identified if present. If models are found which can utilise these
546 * outputs a more complete mixer control can be devised for those models if
547 * necessary.
548 */
549#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100552{
553 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
554 uinfo->count = 1;
555 uinfo->value.integer.min = 0;
556 uinfo->value.integer.max = 1;
557 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200558}
559
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100562{
563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 hda_nid_t nid = kcontrol->private_value & 0xffff;
565 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
566 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200567 unsigned int val = snd_hda_codec_read(codec, nid, 0,
568 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100569
570 *valp = (val & mask) != 0;
571 return 0;
572}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200573static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
574 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100575{
576 signed int change;
577 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
578 hda_nid_t nid = kcontrol->private_value & 0xffff;
579 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
580 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200581 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
582 AC_VERB_GET_DIGI_CONVERT,
583 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100584
585 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100587 if (val==0)
588 ctrl_data &= ~mask;
589 else
590 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
592 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100593
594 return change;
595}
596#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
597 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
598 .info = alc_spdif_ctrl_info, \
599 .get = alc_spdif_ctrl_get, \
600 .put = alc_spdif_ctrl_put, \
601 .private_value = nid | (mask<<16) }
602#endif /* CONFIG_SND_DEBUG */
603
Kailang Yangdf694da2005-12-05 19:42:22 +0100604/*
605 * set up from the preset table
606 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200607static void setup_preset(struct alc_spec *spec,
608 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100609{
610 int i;
611
612 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
613 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
615 i++)
616 spec->init_verbs[spec->num_init_verbs++] =
617 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100618
619 spec->channel_mode = preset->channel_mode;
620 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200621 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100622
623 spec->multiout.max_channels = spec->channel_mode[0].channels;
624
625 spec->multiout.num_dacs = preset->num_dacs;
626 spec->multiout.dac_nids = preset->dac_nids;
627 spec->multiout.dig_out_nid = preset->dig_out_nid;
628 spec->multiout.hp_nid = preset->hp_nid;
629
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200630 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200631 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200632 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100633 spec->input_mux = preset->input_mux;
634
635 spec->num_adc_nids = preset->num_adc_nids;
636 spec->adc_nids = preset->adc_nids;
637 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100638
639 spec->unsol_event = preset->unsol_event;
640 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100641}
642
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200643/* Enable GPIO mask and set output */
644static struct hda_verb alc_gpio1_init_verbs[] = {
645 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
646 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
647 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
648 { }
649};
650
651static struct hda_verb alc_gpio2_init_verbs[] = {
652 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
653 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
654 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
655 { }
656};
657
Kailang Yangbdd148a2007-05-08 15:19:08 +0200658static struct hda_verb alc_gpio3_init_verbs[] = {
659 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
660 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
661 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
662 { }
663};
664
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200665/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
666 * 31 ~ 16 : Manufacture ID
667 * 15 ~ 8 : SKU ID
668 * 7 ~ 0 : Assembly ID
669 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
670 */
671static void alc_subsystem_id(struct hda_codec *codec,
672 unsigned int porta, unsigned int porte,
673 unsigned int portd)
674{
675 unsigned int ass, tmp;
676
677 ass = codec->subsystem_id;
678 if (!(ass & 1))
679 return;
680
681 /* Override */
682 tmp = (ass & 0x38) >> 3; /* external Amp control */
683 switch (tmp) {
684 case 1:
685 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
686 break;
687 case 3:
688 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
689 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200690 case 7:
691 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
692 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200693 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200694 switch (codec->vendor_id) {
695 case 0x10ec0862:
696 case 0x10ec0660:
697 case 0x10ec0662:
698 case 0x10ec0267:
699 case 0x10ec0268:
700 snd_hda_codec_write(codec, 0x14, 0,
701 AC_VERB_SET_EAPD_BTLENABLE, 2);
702 snd_hda_codec_write(codec, 0x15, 0,
703 AC_VERB_SET_EAPD_BTLENABLE, 2);
704 return;
705 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200706 case 6:
707 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
708 hda_nid_t port = 0;
709 tmp = (ass & 0x1800) >> 11;
710 switch (tmp) {
711 case 0: port = porta; break;
712 case 1: port = porte; break;
713 case 2: port = portd; break;
714 }
715 if (port)
716 snd_hda_codec_write(codec, port, 0,
717 AC_VERB_SET_EAPD_BTLENABLE,
718 2);
719 }
720 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
721 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
722 (tmp == 5 ? 0x3040 : 0x3050));
723 break;
724 }
725}
726
Takashi Iwai41e41f12005-06-08 14:48:49 +0200727/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200728 * Fix-up pin default configurations
729 */
730
731struct alc_pincfg {
732 hda_nid_t nid;
733 u32 val;
734};
735
736static void alc_fix_pincfg(struct hda_codec *codec,
737 const struct snd_pci_quirk *quirk,
738 const struct alc_pincfg **pinfix)
739{
740 const struct alc_pincfg *cfg;
741
742 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
743 if (!quirk)
744 return;
745
746 cfg = pinfix[quirk->value];
747 for (; cfg->nid; cfg++) {
748 int i;
749 u32 val = cfg->val;
750 for (i = 0; i < 4; i++) {
751 snd_hda_codec_write(codec, cfg->nid, 0,
752 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
753 val & 0xff);
754 val >>= 8;
755 }
756 }
757}
758
759/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200760 * ALC880 3-stack model
761 *
762 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200763 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
764 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 */
766
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200767static hda_nid_t alc880_dac_nids[4] = {
768 /* front, rear, clfe, rear_surr */
769 0x02, 0x05, 0x04, 0x03
770};
771
772static hda_nid_t alc880_adc_nids[3] = {
773 /* ADC0-2 */
774 0x07, 0x08, 0x09,
775};
776
777/* The datasheet says the node 0x07 is connected from inputs,
778 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100779 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200781static hda_nid_t alc880_adc_nids_alt[2] = {
782 /* ADC1-2 */
783 0x08, 0x09,
784};
785
786#define ALC880_DIGOUT_NID 0x06
787#define ALC880_DIGIN_NID 0x0a
788
789static struct hda_input_mux alc880_capture_source = {
790 .num_items = 4,
791 .items = {
792 { "Mic", 0x0 },
793 { "Front Mic", 0x3 },
794 { "Line", 0x2 },
795 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200797};
798
799/* channel source setting (2/6 channel selection for 3-stack) */
800/* 2ch mode */
801static struct hda_verb alc880_threestack_ch2_init[] = {
802 /* set line-in to input, mute it */
803 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
804 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
805 /* set mic-in to input vref 80%, mute it */
806 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
807 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 { } /* end */
809};
810
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200811/* 6ch mode */
812static struct hda_verb alc880_threestack_ch6_init[] = {
813 /* set line-in to output, unmute it */
814 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
815 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
816 /* set mic-in to output, unmute it */
817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
819 { } /* end */
820};
821
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100822static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200823 { 2, alc880_threestack_ch2_init },
824 { 6, alc880_threestack_ch6_init },
825};
826
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100827static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200828 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100829 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200830 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100831 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200832 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
833 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100834 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
835 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
837 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
838 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
839 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
843 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
844 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
845 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200847 {
848 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
849 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100850 .info = alc_ch_mode_info,
851 .get = alc_ch_mode_get,
852 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200853 },
854 { } /* end */
855};
856
857/* capture mixer elements */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100858static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200859 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
860 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
861 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
862 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
863 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
864 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
865 {
866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
867 /* The multiple "Capture Source" controls confuse alsamixer
868 * So call somewhat different..
869 * FIXME: the controls appear in the "playback" view!
870 */
871 /* .name = "Capture Source", */
872 .name = "Input Source",
873 .count = 3,
874 .info = alc_mux_enum_info,
875 .get = alc_mux_enum_get,
876 .put = alc_mux_enum_put,
877 },
878 { } /* end */
879};
880
881/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100882static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200883 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
884 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
885 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
886 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 {
888 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
889 /* The multiple "Capture Source" controls confuse alsamixer
890 * So call somewhat different..
891 * FIXME: the controls appear in the "playback" view!
892 */
893 /* .name = "Capture Source", */
894 .name = "Input Source",
895 .count = 2,
896 .info = alc_mux_enum_info,
897 .get = alc_mux_enum_get,
898 .put = alc_mux_enum_put,
899 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 { } /* end */
901};
902
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200903
904
905/*
906 * ALC880 5-stack model
907 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200908 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
909 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200910 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
911 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
912 */
913
914/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100915static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200916 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100917 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 { } /* end */
919};
920
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200921/* channel source setting (6/8 channel selection for 5-stack) */
922/* 6ch mode */
923static struct hda_verb alc880_fivestack_ch6_init[] = {
924 /* set line-in to input, mute it */
925 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
926 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200927 { } /* end */
928};
929
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200930/* 8ch mode */
931static struct hda_verb alc880_fivestack_ch8_init[] = {
932 /* set line-in to output, unmute it */
933 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
934 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
935 { } /* end */
936};
937
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100938static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200939 { 6, alc880_fivestack_ch6_init },
940 { 8, alc880_fivestack_ch8_init },
941};
942
943
944/*
945 * ALC880 6-stack model
946 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200947 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
948 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200949 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
950 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
951 */
952
953static hda_nid_t alc880_6st_dac_nids[4] = {
954 /* front, rear, clfe, rear_surr */
955 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200956};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200957
958static struct hda_input_mux alc880_6stack_capture_source = {
959 .num_items = 4,
960 .items = {
961 { "Mic", 0x0 },
962 { "Front Mic", 0x1 },
963 { "Line", 0x2 },
964 { "CD", 0x4 },
965 },
966};
967
968/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100969static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200970 { 8, NULL },
971};
972
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100973static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100975 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200976 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100977 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200978 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
979 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100980 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
981 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200982 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100983 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
990 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
991 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
992 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
993 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200994 {
995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
996 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100997 .info = alc_ch_mode_info,
998 .get = alc_ch_mode_get,
999 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001000 },
1001 { } /* end */
1002};
1003
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001004
1005/*
1006 * ALC880 W810 model
1007 *
1008 * W810 has rear IO for:
1009 * Front (DAC 02)
1010 * Surround (DAC 03)
1011 * Center/LFE (DAC 04)
1012 * Digital out (06)
1013 *
1014 * The system also has a pair of internal speakers, and a headphone jack.
1015 * These are both connected to Line2 on the codec, hence to DAC 02.
1016 *
1017 * There is a variable resistor to control the speaker or headphone
1018 * volume. This is a hardware-only device without a software API.
1019 *
1020 * Plugging headphones in will disable the internal speakers. This is
1021 * implemented in hardware, not via the driver using jack sense. In
1022 * a similar fashion, plugging into the rear socket marked "front" will
1023 * disable both the speakers and headphones.
1024 *
1025 * For input, there's a microphone jack, and an "audio in" jack.
1026 * These may not do anything useful with this driver yet, because I
1027 * haven't setup any initialization verbs for these yet...
1028 */
1029
1030static hda_nid_t alc880_w810_dac_nids[3] = {
1031 /* front, rear/surround, clfe */
1032 0x02, 0x03, 0x04
1033};
1034
1035/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001036static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001037 { 6, NULL }
1038};
1039
1040/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001041static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001045 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001046 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001048 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1049 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001050 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1051 { } /* end */
1052};
1053
1054
1055/*
1056 * Z710V model
1057 *
1058 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001059 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1060 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001061 */
1062
1063static hda_nid_t alc880_z71v_dac_nids[1] = {
1064 0x02
1065};
1066#define ALC880_Z71V_HP_DAC 0x03
1067
1068/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001069static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001070 { 2, NULL }
1071};
1072
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001073static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001074 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001075 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001076 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001077 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001078 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1079 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1082 { } /* end */
1083};
1084
1085
1086/* FIXME! */
1087/*
1088 * ALC880 F1734 model
1089 *
1090 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1091 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1092 */
1093
1094static hda_nid_t alc880_f1734_dac_nids[1] = {
1095 0x03
1096};
1097#define ALC880_F1734_HP_DAC 0x02
1098
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001099static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001100 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001101 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001102 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001103 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001108 { } /* end */
1109};
1110
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001111
1112/* FIXME! */
1113/*
1114 * ALC880 ASUS model
1115 *
1116 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1117 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1118 * Mic = 0x18, Line = 0x1a
1119 */
1120
1121#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1122#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1123
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001124static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001125 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001126 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001127 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001128 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001129 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001131 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1132 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001133 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1134 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001139 {
1140 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1141 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001142 .info = alc_ch_mode_info,
1143 .get = alc_ch_mode_get,
1144 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001145 },
1146 { } /* end */
1147};
1148
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001149/* FIXME! */
1150/*
1151 * ALC880 ASUS W1V model
1152 *
1153 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1154 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1155 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1156 */
1157
1158/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001159static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001160 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1161 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001162 { } /* end */
1163};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001164
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001165/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001166static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001167 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1168 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1169 { } /* end */
1170};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001171
Kailang Yangdf694da2005-12-05 19:42:22 +01001172/* TCL S700 */
1173static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1178 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1181 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1183 {
1184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1185 /* The multiple "Capture Source" controls confuse alsamixer
1186 * So call somewhat different..
1187 * FIXME: the controls appear in the "playback" view!
1188 */
1189 /* .name = "Capture Source", */
1190 .name = "Input Source",
1191 .count = 1,
1192 .info = alc_mux_enum_info,
1193 .get = alc_mux_enum_get,
1194 .put = alc_mux_enum_put,
1195 },
1196 { } /* end */
1197};
1198
Kailang Yangccc656c2006-10-17 12:32:26 +02001199/* Uniwill */
1200static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1201 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1202 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1203 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1204 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1205 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1212 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1215 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1216 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1217 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1218 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1219 {
1220 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1221 .name = "Channel Mode",
1222 .info = alc_ch_mode_info,
1223 .get = alc_ch_mode_get,
1224 .put = alc_ch_mode_put,
1225 },
1226 { } /* end */
1227};
1228
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001229static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1230 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1231 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1232 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1233 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1234 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1235 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1236 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1237 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1238 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1239 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1240 { } /* end */
1241};
1242
Kailang Yangccc656c2006-10-17 12:32:26 +02001243static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1244 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1245 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1246 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1247 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1250 { } /* end */
1251};
1252
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001254 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 */
1256static int alc_build_controls(struct hda_codec *codec)
1257{
1258 struct alc_spec *spec = codec->spec;
1259 int err;
1260 int i;
1261
1262 for (i = 0; i < spec->num_mixers; i++) {
1263 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1264 if (err < 0)
1265 return err;
1266 }
1267
1268 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001269 err = snd_hda_create_spdif_out_ctls(codec,
1270 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 if (err < 0)
1272 return err;
1273 }
1274 if (spec->dig_in_nid) {
1275 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1276 if (err < 0)
1277 return err;
1278 }
1279 return 0;
1280}
1281
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001282
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283/*
1284 * initialize the codec volumes, etc
1285 */
1286
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001287/*
1288 * generic initialization of ADC, input mixers and output mixers
1289 */
1290static struct hda_verb alc880_volume_init_verbs[] = {
1291 /*
1292 * Unmute ADC0-2 and set the default input to mic-in
1293 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001294 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001296 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001298 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001301 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1302 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001303 * Note: PASD motherboards uses the Line In 2 as the input for front
1304 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001306 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001313 /*
1314 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001316 /* set vol=0 to output mixers */
1317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1321 /* set up input amps for analog loopback */
1322 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331
1332 { }
1333};
1334
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001335/*
1336 * 3-stack pin configuration:
1337 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1338 */
1339static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1340 /*
1341 * preset connection lists of input pins
1342 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1343 */
1344 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1345 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1346 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1347
1348 /*
1349 * Set pin mode and muting
1350 */
1351 /* set front pin widgets 0x14 for output */
1352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1353 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1357 /* Mic2 (as headphone out) for HP output */
1358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1359 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 /* Line In pin widget for input */
1361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1363 /* Line2 (as front mic) pin widget for input and vref at 80% */
1364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1365 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1366 /* CD pin widget for input */
1367 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1368
1369 { }
1370};
1371
1372/*
1373 * 5-stack pin configuration:
1374 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1375 * line-in/side = 0x1a, f-mic = 0x1b
1376 */
1377static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1378 /*
1379 * preset connection lists of input pins
1380 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1381 */
1382 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1383 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1384
1385 /*
1386 * Set pin mode and muting
1387 */
1388 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001393 /* unmute pins for output (no gain on this amp) */
1394 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1398
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1402 /* Mic2 (as headphone out) for HP output */
1403 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001404 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001405 /* Line In pin widget for input */
1406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1408 /* Line2 (as front mic) pin widget for input and vref at 80% */
1409 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1410 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1411 /* CD pin widget for input */
1412 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413
1414 { }
1415};
1416
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001417/*
1418 * W810 pin configuration:
1419 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1420 */
1421static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 /* hphone/speaker input selector: front DAC */
1423 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1424
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1429 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1430 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1431
1432 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001433 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 { }
1436};
1437
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001438/*
1439 * Z71V pin configuration:
1440 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1441 */
1442static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001447
Takashi Iwai16ded522005-06-10 19:58:24 +02001448 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001449 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001450 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001451 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001452
1453 { }
1454};
1455
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001456/*
1457 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001458 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1459 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001460 */
1461static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1462 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1463
Takashi Iwai16ded522005-06-10 19:58:24 +02001464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001469 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001470 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1472
Takashi Iwai16ded522005-06-10 19:58:24 +02001473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001475 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001480 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001481 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1482
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001483 { }
1484};
Takashi Iwai16ded522005-06-10 19:58:24 +02001485
Kailang Yangccc656c2006-10-17 12:32:26 +02001486/*
1487 * Uniwill pin configuration:
1488 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1489 * line = 0x1a
1490 */
1491static struct hda_verb alc880_uniwill_init_verbs[] = {
1492 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1493
1494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1499 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1508
1509 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1515 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1516 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1517 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1518
1519 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1520 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1521
1522 { }
1523};
1524
1525/*
1526* Uniwill P53
1527* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1528 */
1529static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1530 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1531
1532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1537 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1543 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1544
1545 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1546 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1548 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1551
1552 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1553 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1554
1555 { }
1556};
1557
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001558static struct hda_verb alc880_beep_init_verbs[] = {
1559 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1560 { }
1561};
1562
Kailang Yangccc656c2006-10-17 12:32:26 +02001563/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001564static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001565{
1566 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001567 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001568
1569 present = snd_hda_codec_read(codec, 0x14, 0,
1570 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001571 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001572 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001573 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001574 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001575 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001576 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001577 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001578 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001579 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001580}
1581
1582/* auto-toggle front mic */
1583static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1584{
1585 unsigned int present;
1586 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001587
1588 present = snd_hda_codec_read(codec, 0x18, 0,
1589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001590 bits = present ? 0x80 : 0;
1591 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1592 0x80, bits);
1593 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1594 0x80, bits);
1595}
1596
1597static void alc880_uniwill_automute(struct hda_codec *codec)
1598{
1599 alc880_uniwill_hp_automute(codec);
1600 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001601}
1602
1603static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1604 unsigned int res)
1605{
1606 /* Looks like the unsol event is incompatible with the standard
1607 * definition. 4bit tag is placed at 28 bit!
1608 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001609 switch (res >> 28) {
1610 case ALC880_HP_EVENT:
1611 alc880_uniwill_hp_automute(codec);
1612 break;
1613 case ALC880_MIC_EVENT:
1614 alc880_uniwill_mic_automute(codec);
1615 break;
1616 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001617}
1618
1619static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1620{
1621 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001622 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001623
1624 present = snd_hda_codec_read(codec, 0x14, 0,
1625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001626 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001627 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001628 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001629 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001630 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001631}
1632
1633static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1634{
1635 unsigned int present;
1636
1637 present = snd_hda_codec_read(codec, 0x21, 0,
1638 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1639
1640 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1641 0x7f, present);
1642 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1643 0x7f, present);
1644
1645 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1646 0x7f, present);
1647 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1648 0x7f, present);
1649
1650}
1651static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1652 unsigned int res)
1653{
1654 /* Looks like the unsol event is incompatible with the standard
1655 * definition. 4bit tag is placed at 28 bit!
1656 */
1657 if ((res >> 28) == ALC880_HP_EVENT)
1658 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001659 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001660 alc880_uniwill_p53_dcvol_automute(codec);
1661}
1662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001663/* FIXME! */
1664/*
1665 * F1734 pin configuration:
1666 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1667 */
1668static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1669 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1670 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1671 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1672 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1673
1674 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1675 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1676 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1677 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1678
1679 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1680 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1681 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1683 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1684 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1686 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1687 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001688
1689 { }
1690};
1691
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001692/* FIXME! */
1693/*
1694 * ASUS pin configuration:
1695 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1696 */
1697static struct hda_verb alc880_pin_asus_init_verbs[] = {
1698 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1699 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1700 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1701 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1702
1703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1707 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1711
1712 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1714 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1716 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1718 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1721
1722 { }
1723};
1724
1725/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001726#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1727#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001728
Kailang Yangdf694da2005-12-05 19:42:22 +01001729/* Clevo m520g init */
1730static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1731 /* headphone output */
1732 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1733 /* line-out */
1734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1735 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1736 /* Line-in */
1737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1738 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1739 /* CD */
1740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1741 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1742 /* Mic1 (rear panel) */
1743 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1745 /* Mic2 (front panel) */
1746 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1747 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1748 /* headphone */
1749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1751 /* change to EAPD mode */
1752 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1753 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1754
1755 { }
1756};
1757
1758static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001759 /* change to EAPD mode */
1760 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1761 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1762
Kailang Yangdf694da2005-12-05 19:42:22 +01001763 /* Headphone output */
1764 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1765 /* Front output*/
1766 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1767 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1768
1769 /* Line In pin widget for input */
1770 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1771 /* CD pin widget for input */
1772 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1773 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775
1776 /* change to EAPD mode */
1777 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1778 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1779
1780 { }
1781};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001782
1783/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001784 * LG m1 express dual
1785 *
1786 * Pin assignment:
1787 * Rear Line-In/Out (blue): 0x14
1788 * Build-in Mic-In: 0x15
1789 * Speaker-out: 0x17
1790 * HP-Out (green): 0x1b
1791 * Mic-In/Out (red): 0x19
1792 * SPDIF-Out: 0x1e
1793 */
1794
1795/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1796static hda_nid_t alc880_lg_dac_nids[3] = {
1797 0x05, 0x02, 0x03
1798};
1799
1800/* seems analog CD is not working */
1801static struct hda_input_mux alc880_lg_capture_source = {
1802 .num_items = 3,
1803 .items = {
1804 { "Mic", 0x1 },
1805 { "Line", 0x5 },
1806 { "Internal Mic", 0x6 },
1807 },
1808};
1809
1810/* 2,4,6 channel modes */
1811static struct hda_verb alc880_lg_ch2_init[] = {
1812 /* set line-in and mic-in to input */
1813 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1814 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1815 { }
1816};
1817
1818static struct hda_verb alc880_lg_ch4_init[] = {
1819 /* set line-in to out and mic-in to input */
1820 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1821 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1822 { }
1823};
1824
1825static struct hda_verb alc880_lg_ch6_init[] = {
1826 /* set line-in and mic-in to output */
1827 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1828 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1829 { }
1830};
1831
1832static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1833 { 2, alc880_lg_ch2_init },
1834 { 4, alc880_lg_ch4_init },
1835 { 6, alc880_lg_ch6_init },
1836};
1837
1838static struct snd_kcontrol_new alc880_lg_mixer[] = {
1839 /* FIXME: it's not really "master" but front channels */
1840 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1841 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1842 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1843 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1844 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1845 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1846 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1847 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1852 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1853 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1854 {
1855 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1856 .name = "Channel Mode",
1857 .info = alc_ch_mode_info,
1858 .get = alc_ch_mode_get,
1859 .put = alc_ch_mode_put,
1860 },
1861 { } /* end */
1862};
1863
1864static struct hda_verb alc880_lg_init_verbs[] = {
1865 /* set capture source to mic-in */
1866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1869 /* mute all amp mixer inputs */
1870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1873 /* line-in to input */
1874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1876 /* built-in mic */
1877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1879 /* speaker-out */
1880 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1882 /* mic-in to input */
1883 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1884 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1885 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1886 /* HP-out */
1887 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1888 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1889 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1890 /* jack sense */
1891 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1892 { }
1893};
1894
1895/* toggle speaker-output according to the hp-jack state */
1896static void alc880_lg_automute(struct hda_codec *codec)
1897{
1898 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001899 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001900
1901 present = snd_hda_codec_read(codec, 0x1b, 0,
1902 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001903 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001904 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001905 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001906 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001907 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001908}
1909
1910static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1911{
1912 /* Looks like the unsol event is incompatible with the standard
1913 * definition. 4bit tag is placed at 28 bit!
1914 */
1915 if ((res >> 28) == 0x01)
1916 alc880_lg_automute(codec);
1917}
1918
1919/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001920 * LG LW20
1921 *
1922 * Pin assignment:
1923 * Speaker-out: 0x14
1924 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001925 * Built-in Mic-In: 0x19
1926 * Line-In: 0x1b
1927 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01001928 * SPDIF-Out: 0x1e
1929 */
1930
Takashi Iwaid6815182006-03-23 16:06:23 +01001931static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001932 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01001933 .items = {
1934 { "Mic", 0x0 },
1935 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001936 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001937 },
1938};
1939
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001940#define alc880_lg_lw_modes alc880_threestack_modes
1941
Takashi Iwaid6815182006-03-23 16:06:23 +01001942static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1946 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1955 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1956 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001957 {
1958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1959 .name = "Channel Mode",
1960 .info = alc_ch_mode_info,
1961 .get = alc_ch_mode_get,
1962 .put = alc_ch_mode_put,
1963 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001964 { } /* end */
1965};
1966
1967static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001968 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1969 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1970 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1971
Takashi Iwaid6815182006-03-23 16:06:23 +01001972 /* set capture source to mic-in */
1973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1977 /* speaker-out */
1978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1980 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1983 /* mic-in to input */
1984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1985 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1986 /* built-in mic */
1987 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1989 /* jack sense */
1990 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1991 { }
1992};
1993
1994/* toggle speaker-output according to the hp-jack state */
1995static void alc880_lg_lw_automute(struct hda_codec *codec)
1996{
1997 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001998 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001999
2000 present = snd_hda_codec_read(codec, 0x1b, 0,
2001 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002002 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01002003 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002004 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002005 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002006 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002007}
2008
2009static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2010{
2011 /* Looks like the unsol event is incompatible with the standard
2012 * definition. 4bit tag is placed at 28 bit!
2013 */
2014 if ((res >> 28) == 0x01)
2015 alc880_lg_lw_automute(codec);
2016}
2017
2018/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002019 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002020 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002021
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022static int alc_init(struct hda_codec *codec)
2023{
2024 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002025 unsigned int i;
2026
2027 for (i = 0; i < spec->num_init_verbs; i++)
2028 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002029
2030 if (spec->init_hook)
2031 spec->init_hook(codec);
2032
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033 return 0;
2034}
2035
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002036static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2037{
2038 struct alc_spec *spec = codec->spec;
2039
2040 if (spec->unsol_event)
2041 spec->unsol_event(codec, res);
2042}
2043
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044#ifdef CONFIG_PM
2045/*
2046 * resume
2047 */
2048static int alc_resume(struct hda_codec *codec)
2049{
2050 struct alc_spec *spec = codec->spec;
2051 int i;
2052
2053 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002054 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056 if (spec->multiout.dig_out_nid)
2057 snd_hda_resume_spdif_out(codec);
2058 if (spec->dig_in_nid)
2059 snd_hda_resume_spdif_in(codec);
2060
2061 return 0;
2062}
2063#endif
2064
2065/*
2066 * Analog playback callbacks
2067 */
2068static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2069 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-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_analog_open(codec, &spec->multiout, substream);
2074}
2075
2076static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2077 struct hda_codec *codec,
2078 unsigned int stream_tag,
2079 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002080 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081{
2082 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002083 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2084 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085}
2086
2087static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2088 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-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_analog_cleanup(codec, &spec->multiout);
2093}
2094
2095/*
2096 * Digital out
2097 */
2098static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2099 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002100 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101{
2102 struct alc_spec *spec = codec->spec;
2103 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2104}
2105
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002106static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2107 struct hda_codec *codec,
2108 unsigned int stream_tag,
2109 unsigned int format,
2110 struct snd_pcm_substream *substream)
2111{
2112 struct alc_spec *spec = codec->spec;
2113 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2114 stream_tag, format, substream);
2115}
2116
Linus Torvalds1da177e2005-04-16 15:20:36 -07002117static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2118 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002119 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120{
2121 struct alc_spec *spec = codec->spec;
2122 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2123}
2124
2125/*
2126 * Analog capture
2127 */
2128static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2129 struct hda_codec *codec,
2130 unsigned int stream_tag,
2131 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002132 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002133{
2134 struct alc_spec *spec = codec->spec;
2135
2136 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2137 stream_tag, 0, format);
2138 return 0;
2139}
2140
2141static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2142 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002143 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144{
2145 struct alc_spec *spec = codec->spec;
2146
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002147 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2148 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 return 0;
2150}
2151
2152
2153/*
2154 */
2155static struct hda_pcm_stream alc880_pcm_analog_playback = {
2156 .substreams = 1,
2157 .channels_min = 2,
2158 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002159 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002160 .ops = {
2161 .open = alc880_playback_pcm_open,
2162 .prepare = alc880_playback_pcm_prepare,
2163 .cleanup = alc880_playback_pcm_cleanup
2164 },
2165};
2166
2167static struct hda_pcm_stream alc880_pcm_analog_capture = {
2168 .substreams = 2,
2169 .channels_min = 2,
2170 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002171 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172 .ops = {
2173 .prepare = alc880_capture_pcm_prepare,
2174 .cleanup = alc880_capture_pcm_cleanup
2175 },
2176};
2177
2178static struct hda_pcm_stream alc880_pcm_digital_playback = {
2179 .substreams = 1,
2180 .channels_min = 2,
2181 .channels_max = 2,
2182 /* NID is set in alc_build_pcms */
2183 .ops = {
2184 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002185 .close = alc880_dig_playback_pcm_close,
2186 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187 },
2188};
2189
2190static struct hda_pcm_stream alc880_pcm_digital_capture = {
2191 .substreams = 1,
2192 .channels_min = 2,
2193 .channels_max = 2,
2194 /* NID is set in alc_build_pcms */
2195};
2196
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002197/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2198static struct hda_pcm_stream alc_pcm_null_playback = {
2199 .substreams = 0,
2200 .channels_min = 0,
2201 .channels_max = 0,
2202};
2203
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204static int alc_build_pcms(struct hda_codec *codec)
2205{
2206 struct alc_spec *spec = codec->spec;
2207 struct hda_pcm *info = spec->pcm_rec;
2208 int i;
2209
2210 codec->num_pcms = 1;
2211 codec->pcm_info = info;
2212
2213 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002214 if (spec->stream_analog_playback) {
2215 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2216 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2217 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2218 }
2219 if (spec->stream_analog_capture) {
2220 snd_assert(spec->adc_nids, return -EINVAL);
2221 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2222 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2223 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224
Takashi Iwai4a471b72005-12-07 13:56:29 +01002225 if (spec->channel_mode) {
2226 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2227 for (i = 0; i < spec->num_channel_mode; i++) {
2228 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2229 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2230 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002231 }
2232 }
2233
Takashi Iwaie08a0072006-09-07 17:52:14 +02002234 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002236 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002237 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002239 if (spec->multiout.dig_out_nid &&
2240 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2242 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2243 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002244 if (spec->dig_in_nid &&
2245 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2247 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2248 }
2249 }
2250
Takashi Iwaie08a0072006-09-07 17:52:14 +02002251 /* If the use of more than one ADC is requested for the current
2252 * model, configure a second analog capture-only PCM.
2253 */
2254 /* Additional Analaog capture for index #2 */
2255 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2256 spec->adc_nids) {
2257 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002258 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002259 info->name = spec->stream_name_analog;
2260 /* No playback stream for second PCM */
2261 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2262 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2263 if (spec->stream_analog_capture) {
2264 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2265 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2266 }
2267 }
2268
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269 return 0;
2270}
2271
2272static void alc_free(struct hda_codec *codec)
2273{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002274 struct alc_spec *spec = codec->spec;
2275 unsigned int i;
2276
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002277 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002278 return;
2279
2280 if (spec->kctl_alloc) {
2281 for (i = 0; i < spec->num_kctl_used; i++)
2282 kfree(spec->kctl_alloc[i].name);
2283 kfree(spec->kctl_alloc);
2284 }
2285 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286}
2287
2288/*
2289 */
2290static struct hda_codec_ops alc_patch_ops = {
2291 .build_controls = alc_build_controls,
2292 .build_pcms = alc_build_pcms,
2293 .init = alc_init,
2294 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002295 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296#ifdef CONFIG_PM
2297 .resume = alc_resume,
2298#endif
2299};
2300
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002301
2302/*
2303 * Test configuration for debugging
2304 *
2305 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2306 * enum controls.
2307 */
2308#ifdef CONFIG_SND_DEBUG
2309static hda_nid_t alc880_test_dac_nids[4] = {
2310 0x02, 0x03, 0x04, 0x05
2311};
2312
2313static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002314 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002315 .items = {
2316 { "In-1", 0x0 },
2317 { "In-2", 0x1 },
2318 { "In-3", 0x2 },
2319 { "In-4", 0x3 },
2320 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002321 { "Front", 0x5 },
2322 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002323 },
2324};
2325
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002326static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002327 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002328 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002329 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002330 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002331};
2332
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002333static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2334 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002335{
2336 static char *texts[] = {
2337 "N/A", "Line Out", "HP Out",
2338 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2339 };
2340 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2341 uinfo->count = 1;
2342 uinfo->value.enumerated.items = 8;
2343 if (uinfo->value.enumerated.item >= 8)
2344 uinfo->value.enumerated.item = 7;
2345 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2346 return 0;
2347}
2348
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002349static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2350 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002351{
2352 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2353 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2354 unsigned int pin_ctl, item = 0;
2355
2356 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2357 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2358 if (pin_ctl & AC_PINCTL_OUT_EN) {
2359 if (pin_ctl & AC_PINCTL_HP_EN)
2360 item = 2;
2361 else
2362 item = 1;
2363 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2364 switch (pin_ctl & AC_PINCTL_VREFEN) {
2365 case AC_PINCTL_VREF_HIZ: item = 3; break;
2366 case AC_PINCTL_VREF_50: item = 4; break;
2367 case AC_PINCTL_VREF_GRD: item = 5; break;
2368 case AC_PINCTL_VREF_80: item = 6; break;
2369 case AC_PINCTL_VREF_100: item = 7; break;
2370 }
2371 }
2372 ucontrol->value.enumerated.item[0] = item;
2373 return 0;
2374}
2375
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002376static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2377 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002378{
2379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2380 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2381 static unsigned int ctls[] = {
2382 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2383 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2384 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2385 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2386 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2387 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2388 };
2389 unsigned int old_ctl, new_ctl;
2390
2391 old_ctl = snd_hda_codec_read(codec, nid, 0,
2392 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2393 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2394 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002395 snd_hda_codec_write(codec, nid, 0,
2396 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002397 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002398 (ucontrol->value.enumerated.item[0] >= 3 ?
2399 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002400 return 1;
2401 }
2402 return 0;
2403}
2404
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002405static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2406 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002407{
2408 static char *texts[] = {
2409 "Front", "Surround", "CLFE", "Side"
2410 };
2411 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2412 uinfo->count = 1;
2413 uinfo->value.enumerated.items = 4;
2414 if (uinfo->value.enumerated.item >= 4)
2415 uinfo->value.enumerated.item = 3;
2416 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2417 return 0;
2418}
2419
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002420static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2421 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002422{
2423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2424 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2425 unsigned int sel;
2426
2427 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2428 ucontrol->value.enumerated.item[0] = sel & 3;
2429 return 0;
2430}
2431
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002432static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2433 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002434{
2435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2436 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2437 unsigned int sel;
2438
2439 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2440 if (ucontrol->value.enumerated.item[0] != sel) {
2441 sel = ucontrol->value.enumerated.item[0] & 3;
2442 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2443 return 1;
2444 }
2445 return 0;
2446}
2447
2448#define PIN_CTL_TEST(xname,nid) { \
2449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2450 .name = xname, \
2451 .info = alc_test_pin_ctl_info, \
2452 .get = alc_test_pin_ctl_get, \
2453 .put = alc_test_pin_ctl_put, \
2454 .private_value = nid \
2455 }
2456
2457#define PIN_SRC_TEST(xname,nid) { \
2458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2459 .name = xname, \
2460 .info = alc_test_pin_src_info, \
2461 .get = alc_test_pin_src_get, \
2462 .put = alc_test_pin_src_put, \
2463 .private_value = nid \
2464 }
2465
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002466static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002467 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2468 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2469 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2470 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002471 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2472 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2473 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2474 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002475 PIN_CTL_TEST("Front Pin Mode", 0x14),
2476 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2477 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2478 PIN_CTL_TEST("Side Pin Mode", 0x17),
2479 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2480 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2481 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2482 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2483 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2484 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2485 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2486 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2487 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2488 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2489 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2490 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2491 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2492 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2493 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2494 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002497 {
2498 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2499 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002500 .info = alc_ch_mode_info,
2501 .get = alc_ch_mode_get,
2502 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002503 },
2504 { } /* end */
2505};
2506
2507static struct hda_verb alc880_test_init_verbs[] = {
2508 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2511 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002517 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002522 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2526 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002527 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2530 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2531 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002532 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002533 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2534 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002535 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2536 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2537 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002538 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002539 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2540 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2542 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002543 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002545 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002546 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002547 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002548 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002549 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002550 /* Analog input/passthru */
2551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2555 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002556 { }
2557};
2558#endif
2559
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560/*
2561 */
2562
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002563static const char *alc880_models[ALC880_MODEL_LAST] = {
2564 [ALC880_3ST] = "3stack",
2565 [ALC880_TCL_S700] = "tcl",
2566 [ALC880_3ST_DIG] = "3stack-digout",
2567 [ALC880_CLEVO] = "clevo",
2568 [ALC880_5ST] = "5stack",
2569 [ALC880_5ST_DIG] = "5stack-digout",
2570 [ALC880_W810] = "w810",
2571 [ALC880_Z71V] = "z71v",
2572 [ALC880_6ST] = "6stack",
2573 [ALC880_6ST_DIG] = "6stack-digout",
2574 [ALC880_ASUS] = "asus",
2575 [ALC880_ASUS_W1V] = "asus-w1v",
2576 [ALC880_ASUS_DIG] = "asus-dig",
2577 [ALC880_ASUS_DIG2] = "asus-dig2",
2578 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002579 [ALC880_UNIWILL_P53] = "uniwill-p53",
2580 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002581 [ALC880_F1734] = "F1734",
2582 [ALC880_LG] = "lg",
2583 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002584#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002585 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002586#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002587 [ALC880_AUTO] = "auto",
2588};
2589
2590static struct snd_pci_quirk alc880_cfg_tbl[] = {
2591 /* Broken BIOS configuration */
2592 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2593 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2594
2595 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2596 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002597 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002598 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2599 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2600 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2601 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2602 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2603 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2604
2605 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2606 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2607
2608 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2609 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2610 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2611 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2612 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2613 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2614 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2615 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2616 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2617 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002618 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002619 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2620 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2621 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2622 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2623
2624 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2625 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2626 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2627 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2628 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2629 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2630 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2631 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2632 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2633 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2634 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2635 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2636 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2637 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2638 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2639 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2640 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2641 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2642
2643 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2644 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2645 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2646 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2647
2648 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2649 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2650 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002651 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002652
2653 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2654 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2655 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2656 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2657
2658 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2659 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2660 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2661 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2662 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2663 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2664 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2665 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2666 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2667 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2668 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002669
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 {}
2671};
2672
Takashi Iwai16ded522005-06-10 19:58:24 +02002673/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002674 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002676static struct alc_config_preset alc880_presets[] = {
2677 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002679 .init_verbs = { alc880_volume_init_verbs,
2680 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002681 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002682 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2684 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002685 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 .input_mux = &alc880_capture_source,
2687 },
2688 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002693 .dac_nids = alc880_dac_nids,
2694 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002695 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2696 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002697 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002698 .input_mux = &alc880_capture_source,
2699 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002700 [ALC880_TCL_S700] = {
2701 .mixers = { alc880_tcl_s700_mixer },
2702 .init_verbs = { alc880_volume_init_verbs,
2703 alc880_pin_tcl_S700_init_verbs,
2704 alc880_gpio2_init_verbs },
2705 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2706 .dac_nids = alc880_dac_nids,
2707 .hp_nid = 0x03,
2708 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2709 .channel_mode = alc880_2_jack_modes,
2710 .input_mux = &alc880_capture_source,
2711 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002712 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002713 .mixers = { alc880_three_stack_mixer,
2714 alc880_five_stack_mixer},
2715 .init_verbs = { alc880_volume_init_verbs,
2716 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002717 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2718 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002719 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2720 .channel_mode = alc880_fivestack_modes,
2721 .input_mux = &alc880_capture_source,
2722 },
2723 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002724 .mixers = { alc880_three_stack_mixer,
2725 alc880_five_stack_mixer },
2726 .init_verbs = { alc880_volume_init_verbs,
2727 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2729 .dac_nids = alc880_dac_nids,
2730 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002731 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2732 .channel_mode = alc880_fivestack_modes,
2733 .input_mux = &alc880_capture_source,
2734 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002735 [ALC880_6ST] = {
2736 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002737 .init_verbs = { alc880_volume_init_verbs,
2738 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002739 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2740 .dac_nids = alc880_6st_dac_nids,
2741 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2742 .channel_mode = alc880_sixstack_modes,
2743 .input_mux = &alc880_6stack_capture_source,
2744 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002745 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002747 .init_verbs = { alc880_volume_init_verbs,
2748 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002749 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2750 .dac_nids = alc880_6st_dac_nids,
2751 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002752 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2753 .channel_mode = alc880_sixstack_modes,
2754 .input_mux = &alc880_6stack_capture_source,
2755 },
2756 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002757 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002758 .init_verbs = { alc880_volume_init_verbs,
2759 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002760 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002761 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2762 .dac_nids = alc880_w810_dac_nids,
2763 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002764 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2765 .channel_mode = alc880_w810_modes,
2766 .input_mux = &alc880_capture_source,
2767 },
2768 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002769 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002770 .init_verbs = { alc880_volume_init_verbs,
2771 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002772 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2773 .dac_nids = alc880_z71v_dac_nids,
2774 .dig_out_nid = ALC880_DIGOUT_NID,
2775 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2777 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002778 .input_mux = &alc880_capture_source,
2779 },
2780 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002782 .init_verbs = { alc880_volume_init_verbs,
2783 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002784 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2785 .dac_nids = alc880_f1734_dac_nids,
2786 .hp_nid = 0x02,
2787 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2788 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002789 .input_mux = &alc880_capture_source,
2790 },
2791 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002792 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002793 .init_verbs = { alc880_volume_init_verbs,
2794 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 alc880_gpio1_init_verbs },
2796 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2797 .dac_nids = alc880_asus_dac_nids,
2798 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2799 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002800 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 .input_mux = &alc880_capture_source,
2802 },
2803 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002804 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002805 .init_verbs = { alc880_volume_init_verbs,
2806 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002807 alc880_gpio1_init_verbs },
2808 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2809 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002810 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002811 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2812 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002813 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002814 .input_mux = &alc880_capture_source,
2815 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002816 [ALC880_ASUS_DIG2] = {
2817 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002818 .init_verbs = { alc880_volume_init_verbs,
2819 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002820 alc880_gpio2_init_verbs }, /* use GPIO2 */
2821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2822 .dac_nids = alc880_asus_dac_nids,
2823 .dig_out_nid = ALC880_DIGOUT_NID,
2824 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2825 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002826 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002827 .input_mux = &alc880_capture_source,
2828 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002829 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002830 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002831 .init_verbs = { alc880_volume_init_verbs,
2832 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002833 alc880_gpio1_init_verbs },
2834 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2835 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002836 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2838 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002839 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002840 .input_mux = &alc880_capture_source,
2841 },
2842 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002843 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002844 .init_verbs = { alc880_volume_init_verbs,
2845 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002846 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2847 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002848 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002849 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2850 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002851 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002852 .input_mux = &alc880_capture_source,
2853 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002854 [ALC880_UNIWILL] = {
2855 .mixers = { alc880_uniwill_mixer },
2856 .init_verbs = { alc880_volume_init_verbs,
2857 alc880_uniwill_init_verbs },
2858 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2859 .dac_nids = alc880_asus_dac_nids,
2860 .dig_out_nid = ALC880_DIGOUT_NID,
2861 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2862 .channel_mode = alc880_threestack_modes,
2863 .need_dac_fix = 1,
2864 .input_mux = &alc880_capture_source,
2865 .unsol_event = alc880_uniwill_unsol_event,
2866 .init_hook = alc880_uniwill_automute,
2867 },
2868 [ALC880_UNIWILL_P53] = {
2869 .mixers = { alc880_uniwill_p53_mixer },
2870 .init_verbs = { alc880_volume_init_verbs,
2871 alc880_uniwill_p53_init_verbs },
2872 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2873 .dac_nids = alc880_asus_dac_nids,
2874 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002875 .channel_mode = alc880_threestack_modes,
2876 .input_mux = &alc880_capture_source,
2877 .unsol_event = alc880_uniwill_p53_unsol_event,
2878 .init_hook = alc880_uniwill_p53_hp_automute,
2879 },
2880 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002881 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002882 alc880_pcbeep_mixer, },
2883 .init_verbs = { alc880_volume_init_verbs,
2884 alc880_uniwill_p53_init_verbs,
2885 alc880_beep_init_verbs },
2886 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2887 .dac_nids = alc880_dac_nids,
2888 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2889 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002890 .input_mux = &alc880_capture_source,
2891 .unsol_event = alc880_uniwill_p53_unsol_event,
2892 .init_hook = alc880_uniwill_p53_hp_automute,
2893 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002894 [ALC880_CLEVO] = {
2895 .mixers = { alc880_three_stack_mixer },
2896 .init_verbs = { alc880_volume_init_verbs,
2897 alc880_pin_clevo_init_verbs },
2898 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2899 .dac_nids = alc880_dac_nids,
2900 .hp_nid = 0x03,
2901 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2902 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002903 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002904 .input_mux = &alc880_capture_source,
2905 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002906 [ALC880_LG] = {
2907 .mixers = { alc880_lg_mixer },
2908 .init_verbs = { alc880_volume_init_verbs,
2909 alc880_lg_init_verbs },
2910 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2911 .dac_nids = alc880_lg_dac_nids,
2912 .dig_out_nid = ALC880_DIGOUT_NID,
2913 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2914 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002915 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002916 .input_mux = &alc880_lg_capture_source,
2917 .unsol_event = alc880_lg_unsol_event,
2918 .init_hook = alc880_lg_automute,
2919 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002920 [ALC880_LG_LW] = {
2921 .mixers = { alc880_lg_lw_mixer },
2922 .init_verbs = { alc880_volume_init_verbs,
2923 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002924 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002925 .dac_nids = alc880_dac_nids,
2926 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002927 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2928 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002929 .input_mux = &alc880_lg_lw_capture_source,
2930 .unsol_event = alc880_lg_lw_unsol_event,
2931 .init_hook = alc880_lg_lw_automute,
2932 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002933#ifdef CONFIG_SND_DEBUG
2934 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002935 .mixers = { alc880_test_mixer },
2936 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002937 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2938 .dac_nids = alc880_test_dac_nids,
2939 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002940 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2941 .channel_mode = alc880_test_modes,
2942 .input_mux = &alc880_test_capture_source,
2943 },
2944#endif
2945};
2946
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002947/*
2948 * Automatic parse of I/O pins from the BIOS configuration
2949 */
2950
2951#define NUM_CONTROL_ALLOC 32
2952#define NUM_VERB_ALLOC 32
2953
2954enum {
2955 ALC_CTL_WIDGET_VOL,
2956 ALC_CTL_WIDGET_MUTE,
2957 ALC_CTL_BIND_MUTE,
2958};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002959static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002960 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2961 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002962 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002963};
2964
2965/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002966static int add_control(struct alc_spec *spec, int type, const char *name,
2967 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002968{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002969 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002970
2971 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2972 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2973
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002974 /* array + terminator */
2975 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2976 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977 return -ENOMEM;
2978 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002979 memcpy(knew, spec->kctl_alloc,
2980 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002981 kfree(spec->kctl_alloc);
2982 }
2983 spec->kctl_alloc = knew;
2984 spec->num_kctl_alloc = num;
2985 }
2986
2987 knew = &spec->kctl_alloc[spec->num_kctl_used];
2988 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002989 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002990 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002991 return -ENOMEM;
2992 knew->private_value = val;
2993 spec->num_kctl_used++;
2994 return 0;
2995}
2996
2997#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2998#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2999#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3000#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3001#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3002#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3003#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3004#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3005#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3006#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3007#define ALC880_PIN_CD_NID 0x1c
3008
3009/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003010static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3011 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003012{
3013 hda_nid_t nid;
3014 int assigned[4];
3015 int i, j;
3016
3017 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003018 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003019
3020 /* check the pins hardwired to audio widget */
3021 for (i = 0; i < cfg->line_outs; i++) {
3022 nid = cfg->line_out_pins[i];
3023 if (alc880_is_fixed_pin(nid)) {
3024 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003025 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003026 assigned[idx] = 1;
3027 }
3028 }
3029 /* left pins can be connect to any audio widget */
3030 for (i = 0; i < cfg->line_outs; i++) {
3031 nid = cfg->line_out_pins[i];
3032 if (alc880_is_fixed_pin(nid))
3033 continue;
3034 /* search for an empty channel */
3035 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003036 if (!assigned[j]) {
3037 spec->multiout.dac_nids[i] =
3038 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003039 assigned[j] = 1;
3040 break;
3041 }
3042 }
3043 }
3044 spec->multiout.num_dacs = cfg->line_outs;
3045 return 0;
3046}
3047
3048/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003049static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3050 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003051{
3052 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003053 static const char *chname[4] = {
3054 "Front", "Surround", NULL /*CLFE*/, "Side"
3055 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003056 hda_nid_t nid;
3057 int i, err;
3058
3059 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003060 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003061 continue;
3062 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3063 if (i == 2) {
3064 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003065 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3066 "Center Playback Volume",
3067 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3068 HDA_OUTPUT));
3069 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003070 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003071 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3072 "LFE Playback Volume",
3073 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3074 HDA_OUTPUT));
3075 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003077 err = add_control(spec, ALC_CTL_BIND_MUTE,
3078 "Center Playback Switch",
3079 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3080 HDA_INPUT));
3081 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003083 err = add_control(spec, ALC_CTL_BIND_MUTE,
3084 "LFE Playback Switch",
3085 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3086 HDA_INPUT));
3087 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 return err;
3089 } else {
3090 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003091 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3092 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3093 HDA_OUTPUT));
3094 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003095 return err;
3096 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003097 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3098 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3099 HDA_INPUT));
3100 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 return err;
3102 }
3103 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 return 0;
3105}
3106
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003107/* add playback controls for speaker and HP outputs */
3108static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3109 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110{
3111 hda_nid_t nid;
3112 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003113 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003114
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003115 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116 return 0;
3117
3118 if (alc880_is_fixed_pin(pin)) {
3119 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003120 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003121 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003123 else
3124 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003125 /* control HP volume/switch on the output mixer amp */
3126 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003127 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003128 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3129 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3130 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003132 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003133 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3134 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3135 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136 return err;
3137 } else if (alc880_is_multi_pin(pin)) {
3138 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003140 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003141 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3142 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3143 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003144 return err;
3145 }
3146 return 0;
3147}
3148
3149/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003150static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3151 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003152 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003153{
3154 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003155 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003156
3157 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003158 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3159 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3160 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161 return err;
3162 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003163 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3164 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3165 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003166 return err;
3167 return 0;
3168}
3169
3170/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003171static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3172 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003173{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003175 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003176
3177 for (i = 0; i < AUTO_PIN_LAST; i++) {
3178 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003179 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003180 err = new_analog_input(spec, cfg->input_pins[i],
3181 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003182 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003183 if (err < 0)
3184 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003185 imux->items[imux->num_items].label =
3186 auto_pin_cfg_labels[i];
3187 imux->items[imux->num_items].index =
3188 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003189 imux->num_items++;
3190 }
3191 }
3192 return 0;
3193}
3194
Kailang Yangdf694da2005-12-05 19:42:22 +01003195static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3196 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 int dac_idx)
3198{
3199 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003200 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3201 pin_type);
3202 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3203 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003204 /* need the manual connection? */
3205 if (alc880_is_multi_pin(nid)) {
3206 struct alc_spec *spec = codec->spec;
3207 int idx = alc880_multi_pin_idx(nid);
3208 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3209 AC_VERB_SET_CONNECT_SEL,
3210 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3211 }
3212}
3213
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003214static int get_pin_type(int line_out_type)
3215{
3216 if (line_out_type == AUTO_PIN_HP_OUT)
3217 return PIN_HP;
3218 else
3219 return PIN_OUT;
3220}
3221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003222static void alc880_auto_init_multi_out(struct hda_codec *codec)
3223{
3224 struct alc_spec *spec = codec->spec;
3225 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003226
3227 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003228 for (i = 0; i < spec->autocfg.line_outs; i++) {
3229 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003230 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3231 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003232 }
3233}
3234
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003235static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236{
3237 struct alc_spec *spec = codec->spec;
3238 hda_nid_t pin;
3239
Takashi Iwai82bc9552006-03-21 11:24:42 +01003240 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003241 if (pin) /* connect to front */
3242 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003243 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003244 if (pin) /* connect to front */
3245 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3246}
3247
3248static void alc880_auto_init_analog_input(struct hda_codec *codec)
3249{
3250 struct alc_spec *spec = codec->spec;
3251 int i;
3252
3253 for (i = 0; i < AUTO_PIN_LAST; i++) {
3254 hda_nid_t nid = spec->autocfg.input_pins[i];
3255 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003256 snd_hda_codec_write(codec, nid, 0,
3257 AC_VERB_SET_PIN_WIDGET_CONTROL,
3258 i <= AUTO_PIN_FRONT_MIC ?
3259 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003260 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003261 snd_hda_codec_write(codec, nid, 0,
3262 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263 AMP_OUT_MUTE);
3264 }
3265 }
3266}
3267
3268/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003269/* return 1 if successful, 0 if the proper config is not found,
3270 * or a negative error code
3271 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272static int alc880_parse_auto_config(struct hda_codec *codec)
3273{
3274 struct alc_spec *spec = codec->spec;
3275 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003276 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003277
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003278 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3279 alc880_ignore);
3280 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003282 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003284
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003285 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3286 if (err < 0)
3287 return err;
3288 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3289 if (err < 0)
3290 return err;
3291 err = alc880_auto_create_extra_out(spec,
3292 spec->autocfg.speaker_pins[0],
3293 "Speaker");
3294 if (err < 0)
3295 return err;
3296 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3297 "Headphone");
3298 if (err < 0)
3299 return err;
3300 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3301 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003302 return err;
3303
3304 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3305
3306 if (spec->autocfg.dig_out_pin)
3307 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3308 if (spec->autocfg.dig_in_pin)
3309 spec->dig_in_nid = ALC880_DIGIN_NID;
3310
3311 if (spec->kctl_alloc)
3312 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3313
3314 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3315
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003316 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003317 spec->input_mux = &spec->private_imux;
3318
3319 return 1;
3320}
3321
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003322/* additional initialization for auto-configuration model */
3323static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003324{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003325 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003326 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003327 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003328}
3329
3330/*
3331 * OK, here we have finally the patch for ALC880
3332 */
3333
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334static int patch_alc880(struct hda_codec *codec)
3335{
3336 struct alc_spec *spec;
3337 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003338 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003339
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003340 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003341 if (spec == NULL)
3342 return -ENOMEM;
3343
3344 codec->spec = spec;
3345
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003346 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3347 alc880_models,
3348 alc880_cfg_tbl);
3349 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003350 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3351 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003352 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003353 }
3354
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003355 if (board_config == ALC880_AUTO) {
3356 /* automatic parse from the BIOS config */
3357 err = alc880_parse_auto_config(codec);
3358 if (err < 0) {
3359 alc_free(codec);
3360 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003361 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003362 printk(KERN_INFO
3363 "hda_codec: Cannot set up configuration "
3364 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365 board_config = ALC880_3ST;
3366 }
3367 }
3368
Kailang Yangdf694da2005-12-05 19:42:22 +01003369 if (board_config != ALC880_AUTO)
3370 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003371
3372 spec->stream_name_analog = "ALC880 Analog";
3373 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3374 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3375
3376 spec->stream_name_digital = "ALC880 Digital";
3377 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3378 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3379
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003380 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003381 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003382 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003383 /* get type */
3384 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 if (wcap != AC_WID_AUD_IN) {
3386 spec->adc_nids = alc880_adc_nids_alt;
3387 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003388 spec->mixers[spec->num_mixers] =
3389 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390 spec->num_mixers++;
3391 } else {
3392 spec->adc_nids = alc880_adc_nids;
3393 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3394 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3395 spec->num_mixers++;
3396 }
3397 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003398
3399 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003400 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003401 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003402
3403 return 0;
3404}
3405
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003406
Linus Torvalds1da177e2005-04-16 15:20:36 -07003407/*
3408 * ALC260 support
3409 */
3410
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411static hda_nid_t alc260_dac_nids[1] = {
3412 /* front */
3413 0x02,
3414};
3415
3416static hda_nid_t alc260_adc_nids[1] = {
3417 /* ADC0 */
3418 0x04,
3419};
3420
Kailang Yangdf694da2005-12-05 19:42:22 +01003421static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003422 /* ADC1 */
3423 0x05,
3424};
3425
Kailang Yangdf694da2005-12-05 19:42:22 +01003426static hda_nid_t alc260_hp_adc_nids[2] = {
3427 /* ADC1, 0 */
3428 0x05, 0x04
3429};
3430
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003431/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3432 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3433 */
3434static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003435 /* ADC0, ADC1 */
3436 0x04, 0x05
3437};
3438
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439#define ALC260_DIGOUT_NID 0x03
3440#define ALC260_DIGIN_NID 0x06
3441
3442static struct hda_input_mux alc260_capture_source = {
3443 .num_items = 4,
3444 .items = {
3445 { "Mic", 0x0 },
3446 { "Front Mic", 0x1 },
3447 { "Line", 0x2 },
3448 { "CD", 0x4 },
3449 },
3450};
3451
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003452/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003453 * headphone jack and the internal CD lines since these are the only pins at
3454 * which audio can appear. For flexibility, also allow the option of
3455 * recording the mixer output on the second ADC (ADC0 doesn't have a
3456 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003457 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003458static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3459 {
3460 .num_items = 3,
3461 .items = {
3462 { "Mic/Line", 0x0 },
3463 { "CD", 0x4 },
3464 { "Headphone", 0x2 },
3465 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003466 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003467 {
3468 .num_items = 4,
3469 .items = {
3470 { "Mic/Line", 0x0 },
3471 { "CD", 0x4 },
3472 { "Headphone", 0x2 },
3473 { "Mixer", 0x5 },
3474 },
3475 },
3476
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003477};
3478
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003479/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3480 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003481 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003482static struct hda_input_mux alc260_acer_capture_sources[2] = {
3483 {
3484 .num_items = 4,
3485 .items = {
3486 { "Mic", 0x0 },
3487 { "Line", 0x2 },
3488 { "CD", 0x4 },
3489 { "Headphone", 0x5 },
3490 },
3491 },
3492 {
3493 .num_items = 5,
3494 .items = {
3495 { "Mic", 0x0 },
3496 { "Line", 0x2 },
3497 { "CD", 0x4 },
3498 { "Headphone", 0x6 },
3499 { "Mixer", 0x5 },
3500 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003501 },
3502};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503/*
3504 * This is just place-holder, so there's something for alc_build_pcms to look
3505 * at when it calculates the maximum number of channels. ALC260 has no mixer
3506 * element which allows changing the channel mode, so the verb list is
3507 * never used.
3508 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003509static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003510 { 2, NULL },
3511};
3512
Kailang Yangdf694da2005-12-05 19:42:22 +01003513
3514/* Mixer combinations
3515 *
3516 * basic: base_output + input + pc_beep + capture
3517 * HP: base_output + input + capture_alt
3518 * HP_3013: hp_3013 + input + capture
3519 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003520 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003521 */
3522
3523static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003524 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003525 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003526 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3527 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3528 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3529 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3530 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003531};
Kailang Yangdf694da2005-12-05 19:42:22 +01003532
3533static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003534 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3535 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3536 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3537 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3539 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3540 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3541 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003542 { } /* end */
3543};
3544
Kailang Yangdf694da2005-12-05 19:42:22 +01003545static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3546 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3547 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3548 { } /* end */
3549};
3550
3551static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3552 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3553 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3554 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3555 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3556 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3557 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3558 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3559 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003560 { } /* end */
3561};
3562
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003563/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3564 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3565 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003566static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003567 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003568 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003569 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003570 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3571 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3572 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3573 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003574 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003575 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3576 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3577 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003578 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003579 { } /* end */
3580};
3581
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003582/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3583 * versions of the ALC260 don't act on requests to enable mic bias from NID
3584 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3585 * datasheet doesn't mention this restriction. At this stage it's not clear
3586 * whether this behaviour is intentional or is a hardware bug in chip
3587 * revisions available in early 2006. Therefore for now allow the
3588 * "Headphone Jack Mode" control to span all choices, but if it turns out
3589 * that the lack of mic bias for this NID is intentional we could change the
3590 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3591 *
3592 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3593 * don't appear to make the mic bias available from the "line" jack, even
3594 * though the NID used for this jack (0x14) can supply it. The theory is
3595 * that perhaps Acer have included blocking capacitors between the ALC260
3596 * and the output jack. If this turns out to be the case for all such
3597 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3598 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003599 *
3600 * The C20x Tablet series have a mono internal speaker which is controlled
3601 * via the chip's Mono sum widget and pin complex, so include the necessary
3602 * controls for such models. On models without a "mono speaker" the control
3603 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003604 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003605static struct snd_kcontrol_new alc260_acer_mixer[] = {
3606 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3607 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003608 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003609 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3610 HDA_OUTPUT),
3611 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3612 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003613 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3614 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3616 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3617 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3618 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3619 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3620 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3621 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3622 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3623 { } /* end */
3624};
3625
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003626/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3627 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3628 */
3629static struct snd_kcontrol_new alc260_will_mixer[] = {
3630 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3631 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3633 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3634 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3635 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3636 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3637 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3638 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3639 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3640 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3641 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3642 { } /* end */
3643};
3644
3645/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3646 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3647 */
3648static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3649 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3650 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3652 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3653 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3654 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3655 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3656 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3657 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3658 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3659 { } /* end */
3660};
3661
Kailang Yangdf694da2005-12-05 19:42:22 +01003662/* capture mixer elements */
3663static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003664 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3665 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003666 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3667 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003668 {
3669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003670 /* The multiple "Capture Source" controls confuse alsamixer
3671 * So call somewhat different..
3672 * FIXME: the controls appear in the "playback" view!
3673 */
3674 /* .name = "Capture Source", */
3675 .name = "Input Source",
3676 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003677 .info = alc_mux_enum_info,
3678 .get = alc_mux_enum_get,
3679 .put = alc_mux_enum_put,
3680 },
3681 { } /* end */
3682};
3683
Kailang Yangdf694da2005-12-05 19:42:22 +01003684static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3685 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3686 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3687 {
3688 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3689 /* The multiple "Capture Source" controls confuse alsamixer
3690 * So call somewhat different..
3691 * FIXME: the controls appear in the "playback" view!
3692 */
3693 /* .name = "Capture Source", */
3694 .name = "Input Source",
3695 .count = 1,
3696 .info = alc_mux_enum_info,
3697 .get = alc_mux_enum_get,
3698 .put = alc_mux_enum_put,
3699 },
3700 { } /* end */
3701};
3702
3703/*
3704 * initialization verbs
3705 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003706static struct hda_verb alc260_init_verbs[] = {
3707 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003709 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003710 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003711 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003712 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003713 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003714 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003715 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003716 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003718 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003719 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003720 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003721 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003722 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003723 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003724 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3725 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003726 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003727 /* set connection select to line in (default select for this ADC) */
3728 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003729 /* mute capture amp left and right */
3730 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3731 /* set connection select to line in (default select for this ADC) */
3732 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003733 /* set vol=0 Line-Out mixer amp left and right */
3734 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3735 /* unmute pin widget amp left and right (no gain on this amp) */
3736 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3737 /* set vol=0 HP mixer amp left and right */
3738 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3739 /* unmute pin widget amp left and right (no gain on this amp) */
3740 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3741 /* set vol=0 Mono mixer amp left and right */
3742 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3743 /* unmute pin widget amp left and right (no gain on this amp) */
3744 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3745 /* unmute LINE-2 out pin */
3746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003747 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3748 * Line In 2 = 0x03
3749 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003750 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003752 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003754 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003756 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003757 /* mute Front out path */
3758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3759 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3760 /* mute Headphone out path */
3761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3762 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3763 /* mute Mono out path */
3764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3765 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003766 { }
3767};
3768
Takashi Iwai474167d2006-05-17 17:17:43 +02003769#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003770static struct hda_verb alc260_hp_init_verbs[] = {
3771 /* Headphone and output */
3772 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3773 /* mono output */
3774 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3775 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3776 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3777 /* Mic2 (front panel) pin widget for input and vref at 80% */
3778 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3779 /* Line In pin widget for input */
3780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3781 /* Line-2 pin widget for output */
3782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3783 /* CD pin widget for input */
3784 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3785 /* unmute amp left and right */
3786 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3787 /* set connection select to line in (default select for this ADC) */
3788 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3789 /* unmute Line-Out mixer amp left and right (volume = 0) */
3790 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3791 /* mute pin widget amp left and right (no gain on this amp) */
3792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3793 /* unmute HP mixer amp left and right (volume = 0) */
3794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3795 /* mute pin widget amp left and right (no gain on this amp) */
3796 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003797 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3798 * Line In 2 = 0x03
3799 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003800 /* unmute CD */
3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3802 /* unmute Line In */
3803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3804 /* unmute Mic */
3805 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3806 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3807 /* Unmute Front out path */
3808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3809 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3810 /* Unmute Headphone out path */
3811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3812 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3813 /* Unmute Mono out path */
3814 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3815 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3816 { }
3817};
Takashi Iwai474167d2006-05-17 17:17:43 +02003818#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003819
3820static struct hda_verb alc260_hp_3013_init_verbs[] = {
3821 /* Line out and output */
3822 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3823 /* mono output */
3824 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3825 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3826 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3827 /* Mic2 (front panel) pin widget for input and vref at 80% */
3828 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3829 /* Line In pin widget for input */
3830 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3831 /* Headphone pin widget for output */
3832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3833 /* CD pin widget for input */
3834 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3835 /* unmute amp left and right */
3836 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3837 /* set connection select to line in (default select for this ADC) */
3838 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3839 /* unmute Line-Out mixer amp left and right (volume = 0) */
3840 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3841 /* mute pin widget amp left and right (no gain on this amp) */
3842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3843 /* unmute HP mixer amp left and right (volume = 0) */
3844 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3845 /* mute pin widget amp left and right (no gain on this amp) */
3846 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003847 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3848 * Line In 2 = 0x03
3849 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003850 /* unmute CD */
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3852 /* unmute Line In */
3853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3854 /* unmute Mic */
3855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3856 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3857 /* Unmute Front out path */
3858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3860 /* Unmute Headphone out path */
3861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3863 /* Unmute Mono out path */
3864 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3865 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3866 { }
3867};
3868
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003869/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003870 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3871 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003872 */
3873static struct hda_verb alc260_fujitsu_init_verbs[] = {
3874 /* Disable all GPIOs */
3875 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3876 /* Internal speaker is connected to headphone pin */
3877 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3878 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003880 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3881 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3882 /* Ensure all other unused pins are disabled and muted. */
3883 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3884 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003885 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003886 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003887 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003888 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3889 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3890 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003891
Jonathan Woithef7ace402006-02-28 11:46:14 +01003892 /* Disable digital (SPDIF) pins */
3893 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3894 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003895
Jonathan Woithef7ace402006-02-28 11:46:14 +01003896 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3897 * when acting as an output.
3898 */
3899 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3900
3901 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3904 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3910 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003911
Jonathan Woithef7ace402006-02-28 11:46:14 +01003912 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3913 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3914 /* Unmute Line1 pin widget output buffer since it starts as an output.
3915 * If the pin mode is changed by the user the pin mode control will
3916 * take care of enabling the pin's input/output buffers as needed.
3917 * Therefore there's no need to enable the input buffer at this
3918 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003919 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003921 /* Unmute input buffer of pin widget used for Line-in (no equiv
3922 * mixer ctrl)
3923 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003924 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003925
Jonathan Woithef7ace402006-02-28 11:46:14 +01003926 /* Mute capture amp left and right */
3927 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3928 /* Set ADC connection select to match default mixer setting - line
3929 * in (on mic1 pin)
3930 */
3931 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003932
Jonathan Woithef7ace402006-02-28 11:46:14 +01003933 /* Do the same for the second ADC: mute capture input amp and
3934 * set ADC connection to line in (on mic1 pin)
3935 */
3936 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3937 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003938
Jonathan Woithef7ace402006-02-28 11:46:14 +01003939 /* Mute all inputs to mixer widget (even unconnected ones) */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003948
3949 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003950};
3951
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003952/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3953 * similar laptops (adapted from Fujitsu init verbs).
3954 */
3955static struct hda_verb alc260_acer_init_verbs[] = {
3956 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3957 * the headphone jack. Turn this on and rely on the standard mute
3958 * methods whenever the user wants to turn these outputs off.
3959 */
3960 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3961 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3962 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3963 /* Internal speaker/Headphone jack is connected to Line-out pin */
3964 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3965 /* Internal microphone/Mic jack is connected to Mic1 pin */
3966 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3967 /* Line In jack is connected to Line1 pin */
3968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003969 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3970 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003971 /* Ensure all other unused pins are disabled and muted. */
3972 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3973 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003974 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3975 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3978 /* Disable digital (SPDIF) pins */
3979 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3980 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3981
3982 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3983 * bus when acting as outputs.
3984 */
3985 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3986 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3987
3988 /* Start with output sum widgets muted and their output gains at min */
3989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3992 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3994 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3995 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3996 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3997 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3998
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003999 /* Unmute Line-out pin widget amp left and right
4000 * (no equiv mixer ctrl)
4001 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004003 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4004 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004005 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4006 * inputs. If the pin mode is changed by the user the pin mode control
4007 * will take care of enabling the pin's input/output buffers as needed.
4008 * Therefore there's no need to enable the input buffer at this
4009 * stage.
4010 */
4011 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4013
4014 /* Mute capture amp left and right */
4015 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4016 /* Set ADC connection select to match default mixer setting - mic
4017 * (on mic1 pin)
4018 */
4019 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4020
4021 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004022 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004023 */
4024 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004025 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004026
4027 /* Mute all inputs to mixer widget (even unconnected ones) */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4036
4037 { }
4038};
4039
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004040static struct hda_verb alc260_will_verbs[] = {
4041 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4042 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4043 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4044 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4045 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4046 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4047 {}
4048};
4049
4050static struct hda_verb alc260_replacer_672v_verbs[] = {
4051 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4052 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4053 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4054
4055 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4056 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4057 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4058
4059 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4060 {}
4061};
4062
4063/* toggle speaker-output according to the hp-jack state */
4064static void alc260_replacer_672v_automute(struct hda_codec *codec)
4065{
4066 unsigned int present;
4067
4068 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4069 present = snd_hda_codec_read(codec, 0x0f, 0,
4070 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4071 if (present) {
4072 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4073 snd_hda_codec_write(codec, 0x0f, 0,
4074 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4075 } else {
4076 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4077 snd_hda_codec_write(codec, 0x0f, 0,
4078 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4079 }
4080}
4081
4082static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4083 unsigned int res)
4084{
4085 if ((res >> 26) == ALC880_HP_EVENT)
4086 alc260_replacer_672v_automute(codec);
4087}
4088
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004089/* Test configuration for debugging, modelled after the ALC880 test
4090 * configuration.
4091 */
4092#ifdef CONFIG_SND_DEBUG
4093static hda_nid_t alc260_test_dac_nids[1] = {
4094 0x02,
4095};
4096static hda_nid_t alc260_test_adc_nids[2] = {
4097 0x04, 0x05,
4098};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004099/* For testing the ALC260, each input MUX needs its own definition since
4100 * the signal assignments are different. This assumes that the first ADC
4101 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004102 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004103static struct hda_input_mux alc260_test_capture_sources[2] = {
4104 {
4105 .num_items = 7,
4106 .items = {
4107 { "MIC1 pin", 0x0 },
4108 { "MIC2 pin", 0x1 },
4109 { "LINE1 pin", 0x2 },
4110 { "LINE2 pin", 0x3 },
4111 { "CD pin", 0x4 },
4112 { "LINE-OUT pin", 0x5 },
4113 { "HP-OUT pin", 0x6 },
4114 },
4115 },
4116 {
4117 .num_items = 8,
4118 .items = {
4119 { "MIC1 pin", 0x0 },
4120 { "MIC2 pin", 0x1 },
4121 { "LINE1 pin", 0x2 },
4122 { "LINE2 pin", 0x3 },
4123 { "CD pin", 0x4 },
4124 { "Mixer", 0x5 },
4125 { "LINE-OUT pin", 0x6 },
4126 { "HP-OUT pin", 0x7 },
4127 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004128 },
4129};
4130static struct snd_kcontrol_new alc260_test_mixer[] = {
4131 /* Output driver widgets */
4132 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4133 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4134 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4135 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4136 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4137 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4138
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004139 /* Modes for retasking pin widgets
4140 * Note: the ALC260 doesn't seem to act on requests to enable mic
4141 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4142 * mention this restriction. At this stage it's not clear whether
4143 * this behaviour is intentional or is a hardware bug in chip
4144 * revisions available at least up until early 2006. Therefore for
4145 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4146 * choices, but if it turns out that the lack of mic bias for these
4147 * NIDs is intentional we could change their modes from
4148 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4149 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004150 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4151 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4152 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4153 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4155 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4156
4157 /* Loopback mixer controls */
4158 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4159 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4160 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4161 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4162 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4163 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4164 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4165 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4166 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4167 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4168 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4169 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4170 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4171 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4172 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4173 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004174
4175 /* Controls for GPIO pins, assuming they are configured as outputs */
4176 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4177 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4178 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4179 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4180
Jonathan Woithe92621f12006-02-28 11:47:47 +01004181 /* Switches to allow the digital IO pins to be enabled. The datasheet
4182 * is ambigious as to which NID is which; testing on laptops which
4183 * make this output available should provide clarification.
4184 */
4185 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4186 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4187
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004188 { } /* end */
4189};
4190static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004191 /* Enable all GPIOs as outputs with an initial value of 0 */
4192 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4193 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4194 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4195
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004196 /* Enable retasking pins as output, initially without power amp */
4197 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4198 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4202 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4203
Jonathan Woithe92621f12006-02-28 11:47:47 +01004204 /* Disable digital (SPDIF) pins initially, but users can enable
4205 * them via a mixer switch. In the case of SPDIF-out, this initverb
4206 * payload also sets the generation to 0, output to be in "consumer"
4207 * PCM format, copyright asserted, no pre-emphasis and no validity
4208 * control.
4209 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004210 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4211 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4212
Jonathan Woithef7ace402006-02-28 11:46:14 +01004213 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004214 * OUT1 sum bus when acting as an output.
4215 */
4216 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4217 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4218 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4219 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4220
4221 /* Start with output sum widgets muted and their output gains at min */
4222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4224 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4226 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4228 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4229 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4230 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4231
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004232 /* Unmute retasking pin widget output buffers since the default
4233 * state appears to be output. As the pin mode is changed by the
4234 * user the pin mode control will take care of enabling the pin's
4235 * input/output buffers as needed.
4236 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004237 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 /* Also unmute the mono-out pin widget */
4244 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4245
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004246 /* Mute capture amp left and right */
4247 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004248 /* Set ADC connection select to match default mixer setting (mic1
4249 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004250 */
4251 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4252
4253 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004254 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004255 */
4256 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4257 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4258
4259 /* Mute all inputs to mixer widget (even unconnected ones) */
4260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4268
4269 { }
4270};
4271#endif
4272
Linus Torvalds1da177e2005-04-16 15:20:36 -07004273static struct hda_pcm_stream alc260_pcm_analog_playback = {
4274 .substreams = 1,
4275 .channels_min = 2,
4276 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004277};
4278
4279static struct hda_pcm_stream alc260_pcm_analog_capture = {
4280 .substreams = 1,
4281 .channels_min = 2,
4282 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004283};
4284
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004285#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4286#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4287
Kailang Yangdf694da2005-12-05 19:42:22 +01004288/*
4289 * for BIOS auto-configuration
4290 */
4291
4292static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4293 const char *pfx)
4294{
4295 hda_nid_t nid_vol;
4296 unsigned long vol_val, sw_val;
4297 char name[32];
4298 int err;
4299
4300 if (nid >= 0x0f && nid < 0x11) {
4301 nid_vol = nid - 0x7;
4302 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4303 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4304 } else if (nid == 0x11) {
4305 nid_vol = nid - 0x7;
4306 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4307 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4308 } else if (nid >= 0x12 && nid <= 0x15) {
4309 nid_vol = 0x08;
4310 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4311 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4312 } else
4313 return 0; /* N/A */
4314
4315 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004316 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4317 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004318 return err;
4319 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004320 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4321 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004322 return err;
4323 return 1;
4324}
4325
4326/* add playback controls from the parsed DAC table */
4327static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4328 const struct auto_pin_cfg *cfg)
4329{
4330 hda_nid_t nid;
4331 int err;
4332
4333 spec->multiout.num_dacs = 1;
4334 spec->multiout.dac_nids = spec->private_dac_nids;
4335 spec->multiout.dac_nids[0] = 0x02;
4336
4337 nid = cfg->line_out_pins[0];
4338 if (nid) {
4339 err = alc260_add_playback_controls(spec, nid, "Front");
4340 if (err < 0)
4341 return err;
4342 }
4343
Takashi Iwai82bc9552006-03-21 11:24:42 +01004344 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004345 if (nid) {
4346 err = alc260_add_playback_controls(spec, nid, "Speaker");
4347 if (err < 0)
4348 return err;
4349 }
4350
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004351 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004352 if (nid) {
4353 err = alc260_add_playback_controls(spec, nid, "Headphone");
4354 if (err < 0)
4355 return err;
4356 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004357 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004358}
4359
4360/* create playback/capture controls for input pins */
4361static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4362 const struct auto_pin_cfg *cfg)
4363{
Kailang Yangdf694da2005-12-05 19:42:22 +01004364 struct hda_input_mux *imux = &spec->private_imux;
4365 int i, err, idx;
4366
4367 for (i = 0; i < AUTO_PIN_LAST; i++) {
4368 if (cfg->input_pins[i] >= 0x12) {
4369 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004370 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004371 auto_pin_cfg_labels[i], idx,
4372 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004373 if (err < 0)
4374 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004375 imux->items[imux->num_items].label =
4376 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004377 imux->items[imux->num_items].index = idx;
4378 imux->num_items++;
4379 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004380 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004381 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004382 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004383 auto_pin_cfg_labels[i], idx,
4384 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004385 if (err < 0)
4386 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004387 imux->items[imux->num_items].label =
4388 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004389 imux->items[imux->num_items].index = idx;
4390 imux->num_items++;
4391 }
4392 }
4393 return 0;
4394}
4395
4396static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4397 hda_nid_t nid, int pin_type,
4398 int sel_idx)
4399{
4400 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004401 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4402 pin_type);
4403 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4404 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004405 /* need the manual connection? */
4406 if (nid >= 0x12) {
4407 int idx = nid - 0x12;
4408 snd_hda_codec_write(codec, idx + 0x0b, 0,
4409 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004410 }
4411}
4412
4413static void alc260_auto_init_multi_out(struct hda_codec *codec)
4414{
4415 struct alc_spec *spec = codec->spec;
4416 hda_nid_t nid;
4417
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004418 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004419 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004420 if (nid) {
4421 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4422 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4423 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004424
Takashi Iwai82bc9552006-03-21 11:24:42 +01004425 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004426 if (nid)
4427 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4428
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004429 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004430 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004431 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004432}
Kailang Yangdf694da2005-12-05 19:42:22 +01004433
4434#define ALC260_PIN_CD_NID 0x16
4435static void alc260_auto_init_analog_input(struct hda_codec *codec)
4436{
4437 struct alc_spec *spec = codec->spec;
4438 int i;
4439
4440 for (i = 0; i < AUTO_PIN_LAST; i++) {
4441 hda_nid_t nid = spec->autocfg.input_pins[i];
4442 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004443 snd_hda_codec_write(codec, nid, 0,
4444 AC_VERB_SET_PIN_WIDGET_CONTROL,
4445 i <= AUTO_PIN_FRONT_MIC ?
4446 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004447 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004448 snd_hda_codec_write(codec, nid, 0,
4449 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004450 AMP_OUT_MUTE);
4451 }
4452 }
4453}
4454
4455/*
4456 * generic initialization of ADC, input mixers and output mixers
4457 */
4458static struct hda_verb alc260_volume_init_verbs[] = {
4459 /*
4460 * Unmute ADC0-1 and set the default input to mic-in
4461 */
4462 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4463 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4464 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4465 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4466
4467 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4468 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469 * Note: PASD motherboards uses the Line In 2 as the input for
4470 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004471 */
4472 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4478
4479 /*
4480 * Set up output mixers (0x08 - 0x0a)
4481 */
4482 /* set vol=0 to output mixers */
4483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4485 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4486 /* set up input amps for analog loopback */
4487 /* Amp Indices: DAC = 0, mixer = 1 */
4488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4493 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4494
4495 { }
4496};
4497
4498static int alc260_parse_auto_config(struct hda_codec *codec)
4499{
4500 struct alc_spec *spec = codec->spec;
4501 unsigned int wcap;
4502 int err;
4503 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4504
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004505 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4506 alc260_ignore);
4507 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004508 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004509 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4510 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004511 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004512 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004513 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004514 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4515 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004516 return err;
4517
4518 spec->multiout.max_channels = 2;
4519
4520 if (spec->autocfg.dig_out_pin)
4521 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4522 if (spec->kctl_alloc)
4523 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4524
4525 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4526
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004527 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004528 spec->input_mux = &spec->private_imux;
4529
4530 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004531 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004532 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4533 if (wcap != AC_WID_AUD_IN) {
4534 spec->adc_nids = alc260_adc_nids_alt;
4535 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4536 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004537 } else {
4538 spec->adc_nids = alc260_adc_nids;
4539 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4540 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004541 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004542 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004543
4544 return 1;
4545}
4546
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004547/* additional initialization for auto-configuration model */
4548static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004549{
Kailang Yangdf694da2005-12-05 19:42:22 +01004550 alc260_auto_init_multi_out(codec);
4551 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004552}
4553
4554/*
4555 * ALC260 configurations
4556 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004557static const char *alc260_models[ALC260_MODEL_LAST] = {
4558 [ALC260_BASIC] = "basic",
4559 [ALC260_HP] = "hp",
4560 [ALC260_HP_3013] = "hp-3013",
4561 [ALC260_FUJITSU_S702X] = "fujitsu",
4562 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004563 [ALC260_WILL] = "will",
4564 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004565#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004566 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004567#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004568 [ALC260_AUTO] = "auto",
4569};
4570
4571static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004572 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004573 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004574 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004575 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004576 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4577 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4578 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4579 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4580 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4581 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4582 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4583 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4584 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4585 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4586 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4587 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004588 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4589 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004590 {}
4591};
4592
Kailang Yangdf694da2005-12-05 19:42:22 +01004593static struct alc_config_preset alc260_presets[] = {
4594 [ALC260_BASIC] = {
4595 .mixers = { alc260_base_output_mixer,
4596 alc260_input_mixer,
4597 alc260_pc_beep_mixer,
4598 alc260_capture_mixer },
4599 .init_verbs = { alc260_init_verbs },
4600 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4601 .dac_nids = alc260_dac_nids,
4602 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4603 .adc_nids = alc260_adc_nids,
4604 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4605 .channel_mode = alc260_modes,
4606 .input_mux = &alc260_capture_source,
4607 },
4608 [ALC260_HP] = {
4609 .mixers = { alc260_base_output_mixer,
4610 alc260_input_mixer,
4611 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004612 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004613 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4614 .dac_nids = alc260_dac_nids,
4615 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4616 .adc_nids = alc260_hp_adc_nids,
4617 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4618 .channel_mode = alc260_modes,
4619 .input_mux = &alc260_capture_source,
4620 },
4621 [ALC260_HP_3013] = {
4622 .mixers = { alc260_hp_3013_mixer,
4623 alc260_input_mixer,
4624 alc260_capture_alt_mixer },
4625 .init_verbs = { alc260_hp_3013_init_verbs },
4626 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4627 .dac_nids = alc260_dac_nids,
4628 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4629 .adc_nids = alc260_hp_adc_nids,
4630 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4631 .channel_mode = alc260_modes,
4632 .input_mux = &alc260_capture_source,
4633 },
4634 [ALC260_FUJITSU_S702X] = {
4635 .mixers = { alc260_fujitsu_mixer,
4636 alc260_capture_mixer },
4637 .init_verbs = { alc260_fujitsu_init_verbs },
4638 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4639 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004640 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4641 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004642 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4643 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004644 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4645 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004646 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004647 [ALC260_ACER] = {
4648 .mixers = { alc260_acer_mixer,
4649 alc260_capture_mixer },
4650 .init_verbs = { alc260_acer_init_verbs },
4651 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4652 .dac_nids = alc260_dac_nids,
4653 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4654 .adc_nids = alc260_dual_adc_nids,
4655 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4656 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004657 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4658 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004659 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004660 [ALC260_WILL] = {
4661 .mixers = { alc260_will_mixer,
4662 alc260_capture_mixer },
4663 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4664 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4665 .dac_nids = alc260_dac_nids,
4666 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4667 .adc_nids = alc260_adc_nids,
4668 .dig_out_nid = ALC260_DIGOUT_NID,
4669 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4670 .channel_mode = alc260_modes,
4671 .input_mux = &alc260_capture_source,
4672 },
4673 [ALC260_REPLACER_672V] = {
4674 .mixers = { alc260_replacer_672v_mixer,
4675 alc260_capture_mixer },
4676 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4677 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4678 .dac_nids = alc260_dac_nids,
4679 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4680 .adc_nids = alc260_adc_nids,
4681 .dig_out_nid = ALC260_DIGOUT_NID,
4682 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4683 .channel_mode = alc260_modes,
4684 .input_mux = &alc260_capture_source,
4685 .unsol_event = alc260_replacer_672v_unsol_event,
4686 .init_hook = alc260_replacer_672v_automute,
4687 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004688#ifdef CONFIG_SND_DEBUG
4689 [ALC260_TEST] = {
4690 .mixers = { alc260_test_mixer,
4691 alc260_capture_mixer },
4692 .init_verbs = { alc260_test_init_verbs },
4693 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4694 .dac_nids = alc260_test_dac_nids,
4695 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4696 .adc_nids = alc260_test_adc_nids,
4697 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4698 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004699 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4700 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004701 },
4702#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004703};
4704
Linus Torvalds1da177e2005-04-16 15:20:36 -07004705static int patch_alc260(struct hda_codec *codec)
4706{
4707 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004708 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004709
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004710 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004711 if (spec == NULL)
4712 return -ENOMEM;
4713
4714 codec->spec = spec;
4715
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004716 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4717 alc260_models,
4718 alc260_cfg_tbl);
4719 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004720 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4721 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004722 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004723 }
4724
Kailang Yangdf694da2005-12-05 19:42:22 +01004725 if (board_config == ALC260_AUTO) {
4726 /* automatic parse from the BIOS config */
4727 err = alc260_parse_auto_config(codec);
4728 if (err < 0) {
4729 alc_free(codec);
4730 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004731 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004732 printk(KERN_INFO
4733 "hda_codec: Cannot set up configuration "
4734 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004735 board_config = ALC260_BASIC;
4736 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004737 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004738
Kailang Yangdf694da2005-12-05 19:42:22 +01004739 if (board_config != ALC260_AUTO)
4740 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004741
4742 spec->stream_name_analog = "ALC260 Analog";
4743 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4744 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4745
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004746 spec->stream_name_digital = "ALC260 Digital";
4747 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4748 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4749
Linus Torvalds1da177e2005-04-16 15:20:36 -07004750 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004751 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004752 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004753
4754 return 0;
4755}
4756
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757
Linus Torvalds1da177e2005-04-16 15:20:36 -07004758/*
4759 * ALC882 support
4760 *
4761 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4762 * configuration. Each pin widget can choose any input DACs and a mixer.
4763 * Each ADC is connected from a mixer of all inputs. This makes possible
4764 * 6-channel independent captures.
4765 *
4766 * In addition, an independent DAC for the multi-playback (not used in this
4767 * driver yet).
4768 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004769#define ALC882_DIGOUT_NID 0x06
4770#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004772static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004773 { 8, NULL }
4774};
4775
4776static hda_nid_t alc882_dac_nids[4] = {
4777 /* front, rear, clfe, rear_surr */
4778 0x02, 0x03, 0x04, 0x05
4779};
4780
Kailang Yangdf694da2005-12-05 19:42:22 +01004781/* identical with ALC880 */
4782#define alc882_adc_nids alc880_adc_nids
4783#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004784
4785/* input MUX */
4786/* FIXME: should be a matrix-type input source selection */
4787
4788static struct hda_input_mux alc882_capture_source = {
4789 .num_items = 4,
4790 .items = {
4791 { "Mic", 0x0 },
4792 { "Front Mic", 0x1 },
4793 { "Line", 0x2 },
4794 { "CD", 0x4 },
4795 },
4796};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004797#define alc882_mux_enum_info alc_mux_enum_info
4798#define alc882_mux_enum_get alc_mux_enum_get
4799
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004800static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4801 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004802{
4803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4804 struct alc_spec *spec = codec->spec;
4805 const struct hda_input_mux *imux = spec->input_mux;
4806 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4807 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4808 hda_nid_t nid = capture_mixers[adc_idx];
4809 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4810 unsigned int i, idx;
4811
4812 idx = ucontrol->value.enumerated.item[0];
4813 if (idx >= imux->num_items)
4814 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004815 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004816 return 0;
4817 for (i = 0; i < imux->num_items; i++) {
4818 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4819 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4820 v | (imux->items[i].index << 8));
4821 }
4822 *cur_val = idx;
4823 return 1;
4824}
4825
Kailang Yangdf694da2005-12-05 19:42:22 +01004826/*
Kailang Yang272a5272007-05-14 11:00:38 +02004827 * 2ch mode
4828 */
4829static struct hda_verb alc882_3ST_ch2_init[] = {
4830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4834 { } /* end */
4835};
4836
4837/*
4838 * 6ch mode
4839 */
4840static struct hda_verb alc882_3ST_ch6_init[] = {
4841 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4843 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4844 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4845 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4846 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4847 { } /* end */
4848};
4849
4850static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4851 { 2, alc882_3ST_ch2_init },
4852 { 6, alc882_3ST_ch6_init },
4853};
4854
4855/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004856 * 6ch mode
4857 */
4858static struct hda_verb alc882_sixstack_ch6_init[] = {
4859 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4860 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4861 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4862 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4863 { } /* end */
4864};
4865
4866/*
4867 * 8ch mode
4868 */
4869static struct hda_verb alc882_sixstack_ch8_init[] = {
4870 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4871 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4872 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4873 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4874 { } /* end */
4875};
4876
4877static struct hda_channel_mode alc882_sixstack_modes[2] = {
4878 { 6, alc882_sixstack_ch6_init },
4879 { 8, alc882_sixstack_ch8_init },
4880};
4881
Linus Torvalds1da177e2005-04-16 15:20:36 -07004882/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4883 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4884 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004885static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004886 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004887 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004888 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004889 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004890 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4891 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004892 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4893 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004894 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004895 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4898 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4899 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4900 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004902 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4904 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004905 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004906 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4907 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4908 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004909 { } /* end */
4910};
4911
Kailang Yangbdd148a2007-05-08 15:19:08 +02004912static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4913 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4914 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4922 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4923 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4924 { } /* end */
4925};
4926
Kailang Yang272a5272007-05-14 11:00:38 +02004927static struct snd_kcontrol_new alc882_targa_mixer[] = {
4928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4938 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4939 { } /* end */
4940};
4941
4942/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4943 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4944 */
4945static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4949 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4954 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4955 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4958 { } /* end */
4959};
4960
Kailang Yangdf694da2005-12-05 19:42:22 +01004961static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4962 {
4963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4964 .name = "Channel Mode",
4965 .info = alc_ch_mode_info,
4966 .get = alc_ch_mode_get,
4967 .put = alc_ch_mode_put,
4968 },
4969 { } /* end */
4970};
4971
Linus Torvalds1da177e2005-04-16 15:20:36 -07004972static struct hda_verb alc882_init_verbs[] = {
4973 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004974 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4975 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4976 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004977 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004978 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4979 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4980 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004981 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4983 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4984 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004985 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004986 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4987 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4988 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004989
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004991 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004992 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004994 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004995 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004998 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004999 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005000 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005001 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005002 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005003 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005005 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005006 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5009 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005010 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005011 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5012 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005013 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5015 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5016 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5017 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5018 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005019 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005021
5022 /* FIXME: use matrix-type input source selection */
5023 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5024 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005029 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005034 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5039 /* ADC1: mute amp left and right */
5040 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005041 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005042 /* ADC2: mute amp left and right */
5043 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005044 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005045 /* ADC3: mute amp left and right */
5046 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005047 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005048
5049 { }
5050};
5051
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005052static struct hda_verb alc882_eapd_verbs[] = {
5053 /* change to EAPD mode */
5054 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005055 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005056 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005057};
5058
Tobin Davis9102cd12006-12-15 10:02:12 +01005059/* Mac Pro test */
5060static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5062 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5064 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5065 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5066 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5067 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5068 { } /* end */
5069};
5070
5071static struct hda_verb alc882_macpro_init_verbs[] = {
5072 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5076 /* Front Pin: output 0 (0x0c) */
5077 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5079 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5080 /* Front Mic pin: input vref at 80% */
5081 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5082 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5083 /* Speaker: output */
5084 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5085 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5086 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5087 /* Headphone output (output 0 - 0x0c) */
5088 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5090 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5091
5092 /* FIXME: use matrix-type input source selection */
5093 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5094 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5099 /* Input mixer2 */
5100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5104 /* Input mixer3 */
5105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5109 /* ADC1: mute amp left and right */
5110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5111 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5112 /* ADC2: mute amp left and right */
5113 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5114 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5115 /* ADC3: mute amp left and right */
5116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5117 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5118
5119 { }
5120};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005121
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005122/* iMac 24 mixer. */
5123static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5124 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5125 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5126 { } /* end */
5127};
5128
5129/* iMac 24 init verbs. */
5130static struct hda_verb alc885_imac24_init_verbs[] = {
5131 /* Internal speakers: output 0 (0x0c) */
5132 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5134 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5135 /* Internal speakers: output 0 (0x0c) */
5136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5138 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5139 /* Headphone: output 0 (0x0c) */
5140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5141 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5142 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5144 /* Front Mic: input vref at 80% */
5145 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5147 { }
5148};
5149
5150/* Toggle speaker-output according to the hp-jack state */
5151static void alc885_imac24_automute(struct hda_codec *codec)
5152{
5153 unsigned int present;
5154
5155 present = snd_hda_codec_read(codec, 0x14, 0,
5156 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5157 snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
5158 0x80, present ? 0x80 : 0);
5159 snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
5160 0x80, present ? 0x80 : 0);
5161 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
5162 0x80, present ? 0x80 : 0);
5163 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
5164 0x80, present ? 0x80 : 0);
5165}
5166
5167/* Processes unsolicited events. */
5168static void alc885_imac24_unsol_event(struct hda_codec *codec,
5169 unsigned int res)
5170{
5171 /* Headphone insertion or removal. */
5172 if ((res >> 26) == ALC880_HP_EVENT)
5173 alc885_imac24_automute(codec);
5174}
5175
Kailang Yang272a5272007-05-14 11:00:38 +02005176static struct hda_verb alc882_targa_verbs[] = {
5177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5179
5180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5182
5183 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5185 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5186
5187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5188 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5189 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5190 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5191 { } /* end */
5192};
5193
5194/* toggle speaker-output according to the hp-jack state */
5195static void alc882_targa_automute(struct hda_codec *codec)
5196{
5197 unsigned int present;
5198
5199 present = snd_hda_codec_read(codec, 0x14, 0,
5200 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5201 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5202 0x80, present ? 0x80 : 0);
5203 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5204 0x80, present ? 0x80 : 0);
5205 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5206}
5207
5208static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5209{
5210 /* Looks like the unsol event is incompatible with the standard
5211 * definition. 4bit tag is placed at 26 bit!
5212 */
5213 if (((res >> 26) == ALC880_HP_EVENT)) {
5214 alc882_targa_automute(codec);
5215 }
5216}
5217
5218static struct hda_verb alc882_asus_a7j_verbs[] = {
5219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5221
5222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5225
5226 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5228 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5229
5230 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5232 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5233 { } /* end */
5234};
5235
Tobin Davis9102cd12006-12-15 10:02:12 +01005236static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5237{
5238 unsigned int gpiostate, gpiomask, gpiodir;
5239
5240 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5241 AC_VERB_GET_GPIO_DATA, 0);
5242
5243 if (!muted)
5244 gpiostate |= (1 << pin);
5245 else
5246 gpiostate &= ~(1 << pin);
5247
5248 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5249 AC_VERB_GET_GPIO_MASK, 0);
5250 gpiomask |= (1 << pin);
5251
5252 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5253 AC_VERB_GET_GPIO_DIRECTION, 0);
5254 gpiodir |= (1 << pin);
5255
5256
5257 snd_hda_codec_write(codec, codec->afg, 0,
5258 AC_VERB_SET_GPIO_MASK, gpiomask);
5259 snd_hda_codec_write(codec, codec->afg, 0,
5260 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5261
5262 msleep(1);
5263
5264 snd_hda_codec_write(codec, codec->afg, 0,
5265 AC_VERB_SET_GPIO_DATA, gpiostate);
5266}
5267
Kailang Yangdf694da2005-12-05 19:42:22 +01005268/*
5269 * generic initialization of ADC, input mixers and output mixers
5270 */
5271static struct hda_verb alc882_auto_init_verbs[] = {
5272 /*
5273 * Unmute ADC0-2 and set the default input to mic-in
5274 */
5275 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5277 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5279 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5281
5282 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5283 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005284 * Note: PASD motherboards uses the Line In 2 as the input for
5285 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005286 */
5287 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5293
5294 /*
5295 * Set up output mixers (0x0c - 0x0f)
5296 */
5297 /* set vol=0 to output mixers */
5298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5301 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5302 /* set up input amps for analog loopback */
5303 /* Amp Indices: DAC = 0, mixer = 1 */
5304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5306 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5310 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5312 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5313 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5314
5315 /* FIXME: use matrix-type input source selection */
5316 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5317 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5322 /* Input mixer2 */
5323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5327 /* Input mixer3 */
5328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5332
5333 { }
5334};
5335
5336/* capture mixer elements */
5337static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5338 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5339 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5340 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5341 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5342 {
5343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5344 /* The multiple "Capture Source" controls confuse alsamixer
5345 * So call somewhat different..
5346 * FIXME: the controls appear in the "playback" view!
5347 */
5348 /* .name = "Capture Source", */
5349 .name = "Input Source",
5350 .count = 2,
5351 .info = alc882_mux_enum_info,
5352 .get = alc882_mux_enum_get,
5353 .put = alc882_mux_enum_put,
5354 },
5355 { } /* end */
5356};
5357
5358static struct snd_kcontrol_new alc882_capture_mixer[] = {
5359 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5360 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5361 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5362 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5363 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5364 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5365 {
5366 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5367 /* The multiple "Capture Source" controls confuse alsamixer
5368 * So call somewhat different..
5369 * FIXME: the controls appear in the "playback" view!
5370 */
5371 /* .name = "Capture Source", */
5372 .name = "Input Source",
5373 .count = 3,
5374 .info = alc882_mux_enum_info,
5375 .get = alc882_mux_enum_get,
5376 .put = alc882_mux_enum_put,
5377 },
5378 { } /* end */
5379};
5380
5381/* pcm configuration: identiacal with ALC880 */
5382#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5383#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5384#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5385#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5386
5387/*
5388 * configuration and preset
5389 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005390static const char *alc882_models[ALC882_MODEL_LAST] = {
5391 [ALC882_3ST_DIG] = "3stack-dig",
5392 [ALC882_6ST_DIG] = "6stack-dig",
5393 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005394 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005395 [ALC885_MACPRO] = "macpro",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005396 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005397 [ALC882_AUTO] = "auto",
5398};
5399
5400static struct snd_pci_quirk alc882_cfg_tbl[] = {
5401 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5402 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5403 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005404 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005405 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005406 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005407 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005408 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005409 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005410 {}
5411};
5412
5413static struct alc_config_preset alc882_presets[] = {
5414 [ALC882_3ST_DIG] = {
5415 .mixers = { alc882_base_mixer },
5416 .init_verbs = { alc882_init_verbs },
5417 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5418 .dac_nids = alc882_dac_nids,
5419 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005420 .dig_in_nid = ALC882_DIGIN_NID,
5421 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5422 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005423 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005424 .input_mux = &alc882_capture_source,
5425 },
5426 [ALC882_6ST_DIG] = {
5427 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5428 .init_verbs = { alc882_init_verbs },
5429 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5430 .dac_nids = alc882_dac_nids,
5431 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005432 .dig_in_nid = ALC882_DIGIN_NID,
5433 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5434 .channel_mode = alc882_sixstack_modes,
5435 .input_mux = &alc882_capture_source,
5436 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005437 [ALC882_ARIMA] = {
5438 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5439 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5440 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5441 .dac_nids = alc882_dac_nids,
5442 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5443 .channel_mode = alc882_sixstack_modes,
5444 .input_mux = &alc882_capture_source,
5445 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005446 [ALC882_W2JC] = {
5447 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5448 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5449 alc880_gpio1_init_verbs },
5450 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5451 .dac_nids = alc882_dac_nids,
5452 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5453 .channel_mode = alc880_threestack_modes,
5454 .need_dac_fix = 1,
5455 .input_mux = &alc882_capture_source,
5456 .dig_out_nid = ALC882_DIGOUT_NID,
5457 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005458 [ALC885_MACPRO] = {
5459 .mixers = { alc882_macpro_mixer },
5460 .init_verbs = { alc882_macpro_init_verbs },
5461 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5462 .dac_nids = alc882_dac_nids,
5463 .dig_out_nid = ALC882_DIGOUT_NID,
5464 .dig_in_nid = ALC882_DIGIN_NID,
5465 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5466 .channel_mode = alc882_ch_modes,
5467 .input_mux = &alc882_capture_source,
5468 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005469 [ALC885_IMAC24] = {
5470 .mixers = { alc885_imac24_mixer },
5471 .init_verbs = { alc885_imac24_init_verbs },
5472 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5473 .dac_nids = alc882_dac_nids,
5474 .dig_out_nid = ALC882_DIGOUT_NID,
5475 .dig_in_nid = ALC882_DIGIN_NID,
5476 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5477 .channel_mode = alc882_ch_modes,
5478 .input_mux = &alc882_capture_source,
5479 .unsol_event = alc885_imac24_unsol_event,
5480 .init_hook = alc885_imac24_automute,
5481 },
Kailang Yang272a5272007-05-14 11:00:38 +02005482 [ALC882_TARGA] = {
5483 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5484 alc882_capture_mixer },
5485 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5486 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5487 .dac_nids = alc882_dac_nids,
5488 .dig_out_nid = ALC882_DIGOUT_NID,
5489 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5490 .adc_nids = alc882_adc_nids,
5491 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5492 .channel_mode = alc882_3ST_6ch_modes,
5493 .need_dac_fix = 1,
5494 .input_mux = &alc882_capture_source,
5495 .unsol_event = alc882_targa_unsol_event,
5496 .init_hook = alc882_targa_automute,
5497 },
5498 [ALC882_ASUS_A7J] = {
5499 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5500 alc882_capture_mixer },
5501 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5502 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5503 .dac_nids = alc882_dac_nids,
5504 .dig_out_nid = ALC882_DIGOUT_NID,
5505 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5506 .adc_nids = alc882_adc_nids,
5507 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5508 .channel_mode = alc882_3ST_6ch_modes,
5509 .need_dac_fix = 1,
5510 .input_mux = &alc882_capture_source,
5511 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005512};
5513
5514
5515/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005516 * Pin config fixes
5517 */
5518enum {
5519 PINFIX_ABIT_AW9D_MAX
5520};
5521
5522static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5523 { 0x15, 0x01080104 }, /* side */
5524 { 0x16, 0x01011012 }, /* rear */
5525 { 0x17, 0x01016011 }, /* clfe */
5526 { }
5527};
5528
5529static const struct alc_pincfg *alc882_pin_fixes[] = {
5530 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5531};
5532
5533static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5534 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5535 {}
5536};
5537
5538/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005539 * BIOS auto configuration
5540 */
5541static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5542 hda_nid_t nid, int pin_type,
5543 int dac_idx)
5544{
5545 /* set as output */
5546 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005547 int idx;
5548
Kailang Yangdf694da2005-12-05 19:42:22 +01005549 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5550 idx = 4;
5551 else
5552 idx = spec->multiout.dac_nids[dac_idx] - 2;
5553
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005554 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5555 pin_type);
5556 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5557 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005558 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5559
5560}
5561
5562static void alc882_auto_init_multi_out(struct hda_codec *codec)
5563{
5564 struct alc_spec *spec = codec->spec;
5565 int i;
5566
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005567 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005568 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005569 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005570 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005571 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005572 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005573 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005574 }
5575}
5576
5577static void alc882_auto_init_hp_out(struct hda_codec *codec)
5578{
5579 struct alc_spec *spec = codec->spec;
5580 hda_nid_t pin;
5581
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005582 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005583 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005584 /* use dac 0 */
5585 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005586}
5587
5588#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5589#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5590
5591static void alc882_auto_init_analog_input(struct hda_codec *codec)
5592{
5593 struct alc_spec *spec = codec->spec;
5594 int i;
5595
5596 for (i = 0; i < AUTO_PIN_LAST; i++) {
5597 hda_nid_t nid = spec->autocfg.input_pins[i];
5598 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005599 snd_hda_codec_write(codec, nid, 0,
5600 AC_VERB_SET_PIN_WIDGET_CONTROL,
5601 i <= AUTO_PIN_FRONT_MIC ?
5602 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005603 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005604 snd_hda_codec_write(codec, nid, 0,
5605 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005606 AMP_OUT_MUTE);
5607 }
5608 }
5609}
5610
5611/* almost identical with ALC880 parser... */
5612static int alc882_parse_auto_config(struct hda_codec *codec)
5613{
5614 struct alc_spec *spec = codec->spec;
5615 int err = alc880_parse_auto_config(codec);
5616
5617 if (err < 0)
5618 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005619 else if (err > 0)
5620 /* hack - override the init verbs */
5621 spec->init_verbs[0] = alc882_auto_init_verbs;
5622 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005623}
5624
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005625/* additional initialization for auto-configuration model */
5626static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005627{
Kailang Yangdf694da2005-12-05 19:42:22 +01005628 alc882_auto_init_multi_out(codec);
5629 alc882_auto_init_hp_out(codec);
5630 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005631}
5632
Linus Torvalds1da177e2005-04-16 15:20:36 -07005633static int patch_alc882(struct hda_codec *codec)
5634{
5635 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005636 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005637
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005638 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005639 if (spec == NULL)
5640 return -ENOMEM;
5641
Linus Torvalds1da177e2005-04-16 15:20:36 -07005642 codec->spec = spec;
5643
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005644 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5645 alc882_models,
5646 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005647
Kailang Yangdf694da2005-12-05 19:42:22 +01005648 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005649 /* Pick up systems that don't supply PCI SSID */
5650 switch (codec->subsystem_id) {
5651 case 0x106b0c00: /* Mac Pro */
5652 board_config = ALC885_MACPRO;
5653 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005654 case 0x106b1000: /* iMac 24 */
5655 board_config = ALC885_IMAC24;
5656 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01005657 default:
5658 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5659 "trying auto-probe from BIOS...\n");
5660 board_config = ALC882_AUTO;
5661 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005662 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005663
Takashi Iwaif95474e2007-07-10 00:47:43 +02005664 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5665
Kailang Yangdf694da2005-12-05 19:42:22 +01005666 if (board_config == ALC882_AUTO) {
5667 /* automatic parse from the BIOS config */
5668 err = alc882_parse_auto_config(codec);
5669 if (err < 0) {
5670 alc_free(codec);
5671 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005672 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005673 printk(KERN_INFO
5674 "hda_codec: Cannot set up configuration "
5675 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005676 board_config = ALC882_3ST_DIG;
5677 }
5678 }
5679
5680 if (board_config != ALC882_AUTO)
5681 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005682
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005683 if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
Tobin Davis9102cd12006-12-15 10:02:12 +01005684 alc882_gpio_mute(codec, 0, 0);
5685 alc882_gpio_mute(codec, 1, 0);
5686 }
5687
Linus Torvalds1da177e2005-04-16 15:20:36 -07005688 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005689 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5690 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005691
5692 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005693 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5694 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005695
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005696 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005697 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005698 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005699 /* get type */
5700 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005701 if (wcap != AC_WID_AUD_IN) {
5702 spec->adc_nids = alc882_adc_nids_alt;
5703 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005704 spec->mixers[spec->num_mixers] =
5705 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005706 spec->num_mixers++;
5707 } else {
5708 spec->adc_nids = alc882_adc_nids;
5709 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5710 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5711 spec->num_mixers++;
5712 }
5713 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005714
5715 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005716 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005717 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005718
5719 return 0;
5720}
5721
5722/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005723 * ALC883 support
5724 *
5725 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5726 * configuration. Each pin widget can choose any input DACs and a mixer.
5727 * Each ADC is connected from a mixer of all inputs. This makes possible
5728 * 6-channel independent captures.
5729 *
5730 * In addition, an independent DAC for the multi-playback (not used in this
5731 * driver yet).
5732 */
5733#define ALC883_DIGOUT_NID 0x06
5734#define ALC883_DIGIN_NID 0x0a
5735
5736static hda_nid_t alc883_dac_nids[4] = {
5737 /* front, rear, clfe, rear_surr */
5738 0x02, 0x04, 0x03, 0x05
5739};
5740
5741static hda_nid_t alc883_adc_nids[2] = {
5742 /* ADC1-2 */
5743 0x08, 0x09,
5744};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005745
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005746/* input MUX */
5747/* FIXME: should be a matrix-type input source selection */
5748
5749static struct hda_input_mux alc883_capture_source = {
5750 .num_items = 4,
5751 .items = {
5752 { "Mic", 0x0 },
5753 { "Front Mic", 0x1 },
5754 { "Line", 0x2 },
5755 { "CD", 0x4 },
5756 },
5757};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005758
5759static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5760 .num_items = 2,
5761 .items = {
5762 { "Mic", 0x1 },
5763 { "Line", 0x2 },
5764 },
5765};
5766
Kailang Yang272a5272007-05-14 11:00:38 +02005767static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5768 .num_items = 4,
5769 .items = {
5770 { "Mic", 0x0 },
5771 { "iMic", 0x1 },
5772 { "Line", 0x2 },
5773 { "CD", 0x4 },
5774 },
5775};
5776
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005777#define alc883_mux_enum_info alc_mux_enum_info
5778#define alc883_mux_enum_get alc_mux_enum_get
5779
5780static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5781 struct snd_ctl_elem_value *ucontrol)
5782{
5783 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5784 struct alc_spec *spec = codec->spec;
5785 const struct hda_input_mux *imux = spec->input_mux;
5786 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5787 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5788 hda_nid_t nid = capture_mixers[adc_idx];
5789 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5790 unsigned int i, idx;
5791
5792 idx = ucontrol->value.enumerated.item[0];
5793 if (idx >= imux->num_items)
5794 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005795 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005796 return 0;
5797 for (i = 0; i < imux->num_items; i++) {
5798 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5800 v | (imux->items[i].index << 8));
5801 }
5802 *cur_val = idx;
5803 return 1;
5804}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005805
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005806/*
5807 * 2ch mode
5808 */
5809static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5810 { 2, NULL }
5811};
5812
5813/*
5814 * 2ch mode
5815 */
5816static struct hda_verb alc883_3ST_ch2_init[] = {
5817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5819 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5820 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5821 { } /* end */
5822};
5823
5824/*
5825 * 6ch mode
5826 */
5827static struct hda_verb alc883_3ST_ch6_init[] = {
5828 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5829 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5830 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5831 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5832 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5833 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5834 { } /* end */
5835};
5836
5837static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5838 { 2, alc883_3ST_ch2_init },
5839 { 6, alc883_3ST_ch6_init },
5840};
5841
5842/*
5843 * 6ch mode
5844 */
5845static struct hda_verb alc883_sixstack_ch6_init[] = {
5846 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5847 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5848 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5849 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5850 { } /* end */
5851};
5852
5853/*
5854 * 8ch mode
5855 */
5856static struct hda_verb alc883_sixstack_ch8_init[] = {
5857 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5858 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5859 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5860 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5861 { } /* end */
5862};
5863
5864static struct hda_channel_mode alc883_sixstack_modes[2] = {
5865 { 6, alc883_sixstack_ch6_init },
5866 { 8, alc883_sixstack_ch8_init },
5867};
5868
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005869static struct hda_verb alc883_medion_eapd_verbs[] = {
5870 /* eanable EAPD on medion laptop */
5871 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5872 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5873 { }
5874};
5875
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005876/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5877 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5878 */
5879
5880static struct snd_kcontrol_new alc883_base_mixer[] = {
5881 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5882 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5883 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5884 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5885 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5886 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5887 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5888 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5889 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5890 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5891 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5892 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5893 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005897 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005900 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5902 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5903 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5904 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5905 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5906 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5907 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5908 {
5909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5910 /* .name = "Capture Source", */
5911 .name = "Input Source",
5912 .count = 2,
5913 .info = alc883_mux_enum_info,
5914 .get = alc883_mux_enum_get,
5915 .put = alc883_mux_enum_put,
5916 },
5917 { } /* end */
5918};
5919
5920static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5921 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5922 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5926 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5927 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005929 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5931 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005932 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005933 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5934 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5935 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5936 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5937 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5938 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5939 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5940 {
5941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5942 /* .name = "Capture Source", */
5943 .name = "Input Source",
5944 .count = 2,
5945 .info = alc883_mux_enum_info,
5946 .get = alc883_mux_enum_get,
5947 .put = alc883_mux_enum_put,
5948 },
5949 { } /* end */
5950};
5951
5952static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5953 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5954 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5955 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5956 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5957 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5958 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5959 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5960 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5962 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5963 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5964 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5965 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5966 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005967 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005968 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5969 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005970 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005971 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5972 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5973 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5974 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5975 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5976 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5977 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5978 {
5979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5980 /* .name = "Capture Source", */
5981 .name = "Input Source",
5982 .count = 2,
5983 .info = alc883_mux_enum_info,
5984 .get = alc883_mux_enum_get,
5985 .put = alc883_mux_enum_put,
5986 },
5987 { } /* end */
5988};
5989
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005990static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5992 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5993 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5994 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5995 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5996 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5997 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5998 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6002 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6003 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6007 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006008 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006009 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6010 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6011 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6012 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6013 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6014
6015 {
6016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6017 /* .name = "Capture Source", */
6018 .name = "Input Source",
6019 .count = 1,
6020 .info = alc883_mux_enum_info,
6021 .get = alc883_mux_enum_get,
6022 .put = alc883_mux_enum_put,
6023 },
6024 { } /* end */
6025};
6026
Kailang Yangccc656c2006-10-17 12:32:26 +02006027static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6030 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6032 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6033 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6034 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6035 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6036 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6037 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6038 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6039 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6040 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6041 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006042 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6044 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6045 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6046 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6047 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6048 {
6049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6050 /* .name = "Capture Source", */
6051 .name = "Input Source",
6052 .count = 2,
6053 .info = alc883_mux_enum_info,
6054 .get = alc883_mux_enum_get,
6055 .put = alc883_mux_enum_put,
6056 },
6057 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006058};
Kailang Yangccc656c2006-10-17 12:32:26 +02006059
6060static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6063 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6065 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006067 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6069 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6070 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6071 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6072 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6073 {
6074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6075 /* .name = "Capture Source", */
6076 .name = "Input Source",
6077 .count = 2,
6078 .info = alc883_mux_enum_info,
6079 .get = alc883_mux_enum_get,
6080 .put = alc883_mux_enum_put,
6081 },
6082 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006083};
Kailang Yangccc656c2006-10-17 12:32:26 +02006084
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006085static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6087 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6088 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6089 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6094 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6095 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6096 {
6097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6098 /* .name = "Capture Source", */
6099 .name = "Input Source",
6100 .count = 1,
6101 .info = alc883_mux_enum_info,
6102 .get = alc883_mux_enum_get,
6103 .put = alc883_mux_enum_put,
6104 },
6105 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006106};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006107
Kailang Yang272a5272007-05-14 11:00:38 +02006108static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6109 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6110 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6116 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6117 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6120 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6122 {
6123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6124 /* .name = "Capture Source", */
6125 .name = "Input Source",
6126 .count = 2,
6127 .info = alc883_mux_enum_info,
6128 .get = alc883_mux_enum_get,
6129 .put = alc883_mux_enum_put,
6130 },
6131 { } /* end */
6132};
6133
6134static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6135 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6137 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6144 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6145 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6147 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6148 {
6149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6150 /* .name = "Capture Source", */
6151 .name = "Input Source",
6152 .count = 2,
6153 .info = alc883_mux_enum_info,
6154 .get = alc883_mux_enum_get,
6155 .put = alc883_mux_enum_put,
6156 },
6157 { } /* end */
6158};
6159
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006160static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006161 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6162 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6163 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6164 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6165 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6166 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6167 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6168 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6169 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6170 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6172 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6173 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6182 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6183 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6184 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6185 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6188 {
6189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6190 /* .name = "Capture Source", */
6191 .name = "Input Source",
6192 .count = 2,
6193 .info = alc883_mux_enum_info,
6194 .get = alc883_mux_enum_get,
6195 .put = alc883_mux_enum_put,
6196 },
6197 { } /* end */
6198};
6199
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006200static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006201 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6202 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6203 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6204 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6205 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6215 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6218 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6220 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6221 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6222 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6223 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6224 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6225 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6226 {
6227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6228 /* .name = "Capture Source", */
6229 .name = "Input Source",
6230 .count = 2,
6231 .info = alc883_mux_enum_info,
6232 .get = alc883_mux_enum_get,
6233 .put = alc883_mux_enum_put,
6234 },
6235 { } /* end */
6236};
6237
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006238static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6239 {
6240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6241 .name = "Channel Mode",
6242 .info = alc_ch_mode_info,
6243 .get = alc_ch_mode_get,
6244 .put = alc_ch_mode_put,
6245 },
6246 { } /* end */
6247};
6248
6249static struct hda_verb alc883_init_verbs[] = {
6250 /* ADC1: mute amp left and right */
6251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6252 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6253 /* ADC2: mute amp left and right */
6254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6255 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6256 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6260 /* Rear mixer */
6261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6263 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6264 /* CLFE mixer */
6265 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6266 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6267 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6268 /* Side mixer */
6269 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6270 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6272
6273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6278
6279 /* Front Pin: output 0 (0x0c) */
6280 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6281 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6282 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6283 /* Rear Pin: output 1 (0x0d) */
6284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6286 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6287 /* CLFE Pin: output 2 (0x0e) */
6288 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6289 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6290 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6291 /* Side Pin: output 3 (0x0f) */
6292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6294 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6295 /* Mic (rear) pin: input vref at 80% */
6296 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6298 /* Front Mic pin: input vref at 80% */
6299 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6300 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6301 /* Line In pin: input */
6302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6303 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6304 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6305 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6306 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6307 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6308 /* CD pin widget for input */
6309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6310
6311 /* FIXME: use matrix-type input source selection */
6312 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6313 /* Input mixer2 */
6314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6318 /* Input mixer3 */
6319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6323 { }
6324};
6325
Kailang Yangccc656c2006-10-17 12:32:26 +02006326static struct hda_verb alc883_tagra_verbs[] = {
6327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6329
6330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6331 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6332
6333 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6334 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6335 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6336
6337 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006338 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6339 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6340 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006341
6342 { } /* end */
6343};
6344
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006345static struct hda_verb alc883_lenovo_101e_verbs[] = {
6346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6347 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6348 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6349 { } /* end */
6350};
6351
Kailang Yang272a5272007-05-14 11:00:38 +02006352static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6355 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6357 { } /* end */
6358};
6359
6360static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6363 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6364 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6366 { } /* end */
6367};
6368
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006369static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006370 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6372 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6373 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6374 { }
6375};
6376
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006377static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6379 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6380 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6381 { }
6382};
6383
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006384static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006385 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6386 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6387 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6388 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6389 { }
6390};
6391
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006392static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006393 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6395 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6396 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6397 { }
6398};
6399
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006400static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6401 { 2, alc888_3st_hp_2ch_init },
6402 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006403};
6404
Kailang Yang272a5272007-05-14 11:00:38 +02006405/* toggle front-jack and RCA according to the hp-jack state */
6406static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6407{
6408 unsigned int present;
6409
6410 present = snd_hda_codec_read(codec, 0x1b, 0,
6411 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6412 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6413 0x80, present ? 0x80 : 0);
6414 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6415 0x80, present ? 0x80 : 0);
6416 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6417 0x80, present ? 0x80 : 0);
6418 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6419 0x80, present ? 0x80 : 0);
6420
6421}
6422
6423/* toggle RCA according to the front-jack state */
6424static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6425{
6426 unsigned int present;
6427
6428 present = snd_hda_codec_read(codec, 0x14, 0,
6429 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6430 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6431 0x80, present ? 0x80 : 0);
6432 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6433 0x80, present ? 0x80 : 0);
6434
6435}
6436static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6437 unsigned int res)
6438{
6439 if ((res >> 26) == ALC880_HP_EVENT)
6440 alc888_lenovo_ms7195_front_automute(codec);
6441 if ((res >> 26) == ALC880_FRONT_EVENT)
6442 alc888_lenovo_ms7195_rca_automute(codec);
6443}
6444
6445static struct hda_verb alc883_medion_md2_verbs[] = {
6446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6448
6449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6450
6451 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6452 { } /* end */
6453};
6454
6455/* toggle speaker-output according to the hp-jack state */
6456static void alc883_medion_md2_automute(struct hda_codec *codec)
6457{
6458 unsigned int present;
6459
6460 present = snd_hda_codec_read(codec, 0x14, 0,
6461 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6462 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6463 0x80, present ? 0x80 : 0);
6464 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6465 0x80, present ? 0x80 : 0);
6466}
6467
6468static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6469 unsigned int res)
6470{
6471 if ((res >> 26) == ALC880_HP_EVENT)
6472 alc883_medion_md2_automute(codec);
6473}
6474
Kailang Yangccc656c2006-10-17 12:32:26 +02006475/* toggle speaker-output according to the hp-jack state */
6476static void alc883_tagra_automute(struct hda_codec *codec)
6477{
6478 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006479 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006480
6481 present = snd_hda_codec_read(codec, 0x14, 0,
6482 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006483 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006484 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006485 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006486 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006487 0x80, bits);
6488 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6489 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006490}
6491
6492static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6493{
6494 if ((res >> 26) == ALC880_HP_EVENT)
6495 alc883_tagra_automute(codec);
6496}
6497
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006498static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6499{
6500 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006501 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006502
6503 present = snd_hda_codec_read(codec, 0x14, 0,
6504 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006505 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006506 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006507 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006508 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006509 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006510}
6511
6512static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6513{
6514 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006515 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006516
6517 present = snd_hda_codec_read(codec, 0x1b, 0,
6518 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006519 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006520 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006521 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006522 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006523 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006524 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006525 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006526 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006527 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006528}
6529
6530static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6531 unsigned int res)
6532{
6533 if ((res >> 26) == ALC880_HP_EVENT)
6534 alc883_lenovo_101e_all_automute(codec);
6535 if ((res >> 26) == ALC880_FRONT_EVENT)
6536 alc883_lenovo_101e_ispeaker_automute(codec);
6537}
6538
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006539/*
6540 * generic initialization of ADC, input mixers and output mixers
6541 */
6542static struct hda_verb alc883_auto_init_verbs[] = {
6543 /*
6544 * Unmute ADC0-2 and set the default input to mic-in
6545 */
6546 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6548 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6549 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6550
6551 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6552 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006553 * Note: PASD motherboards uses the Line In 2 as the input for
6554 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006555 */
6556 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6558 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6559 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6562
6563 /*
6564 * Set up output mixers (0x0c - 0x0f)
6565 */
6566 /* set vol=0 to output mixers */
6567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6568 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6570 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6571 /* set up input amps for analog loopback */
6572 /* Amp Indices: DAC = 0, mixer = 1 */
6573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6574 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6575 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6576 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6577 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6578 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6579 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6580 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6581 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6582 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6583
6584 /* FIXME: use matrix-type input source selection */
6585 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6586 /* Input mixer1 */
6587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006590 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6592 /* Input mixer2 */
6593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006596 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6598
6599 { }
6600};
6601
6602/* capture mixer elements */
6603static struct snd_kcontrol_new alc883_capture_mixer[] = {
6604 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6605 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6606 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6607 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6608 {
6609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6610 /* The multiple "Capture Source" controls confuse alsamixer
6611 * So call somewhat different..
6612 * FIXME: the controls appear in the "playback" view!
6613 */
6614 /* .name = "Capture Source", */
6615 .name = "Input Source",
6616 .count = 2,
6617 .info = alc882_mux_enum_info,
6618 .get = alc882_mux_enum_get,
6619 .put = alc882_mux_enum_put,
6620 },
6621 { } /* end */
6622};
6623
6624/* pcm configuration: identiacal with ALC880 */
6625#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6626#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6627#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6628#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6629
6630/*
6631 * configuration and preset
6632 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006633static const char *alc883_models[ALC883_MODEL_LAST] = {
6634 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6635 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6636 [ALC883_3ST_6ch] = "3stack-6ch",
6637 [ALC883_6ST_DIG] = "6stack-dig",
6638 [ALC883_TARGA_DIG] = "targa-dig",
6639 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006640 [ALC883_ACER] = "acer",
6641 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006642 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006643 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006644 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006645 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6646 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006647 [ALC888_6ST_HP] = "6stack-hp",
6648 [ALC888_3ST_HP] = "3stack-hp",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006649 [ALC883_AUTO] = "auto",
6650};
6651
6652static struct snd_pci_quirk alc883_cfg_tbl[] = {
6653 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006654 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006655 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6656 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6657 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006658 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006659 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6660 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006661 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006662 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02006663 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006664 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006665 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006666 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006667 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6668 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6669 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6670 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6671 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6672 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6673 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6674 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6675 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6676 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006677 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006678 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6679 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6680 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006681 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6682 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6683 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006684 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6685 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6686 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
Kailang Yang272a5272007-05-14 11:00:38 +02006687 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006688 {}
6689};
6690
6691static struct alc_config_preset alc883_presets[] = {
6692 [ALC883_3ST_2ch_DIG] = {
6693 .mixers = { alc883_3ST_2ch_mixer },
6694 .init_verbs = { alc883_init_verbs },
6695 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6696 .dac_nids = alc883_dac_nids,
6697 .dig_out_nid = ALC883_DIGOUT_NID,
6698 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6699 .adc_nids = alc883_adc_nids,
6700 .dig_in_nid = ALC883_DIGIN_NID,
6701 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6702 .channel_mode = alc883_3ST_2ch_modes,
6703 .input_mux = &alc883_capture_source,
6704 },
6705 [ALC883_3ST_6ch_DIG] = {
6706 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6707 .init_verbs = { alc883_init_verbs },
6708 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6709 .dac_nids = alc883_dac_nids,
6710 .dig_out_nid = ALC883_DIGOUT_NID,
6711 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6712 .adc_nids = alc883_adc_nids,
6713 .dig_in_nid = ALC883_DIGIN_NID,
6714 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6715 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006716 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006717 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006718 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006719 [ALC883_3ST_6ch] = {
6720 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6721 .init_verbs = { alc883_init_verbs },
6722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6723 .dac_nids = alc883_dac_nids,
6724 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6725 .adc_nids = alc883_adc_nids,
6726 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6727 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006728 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006729 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006730 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006731 [ALC883_6ST_DIG] = {
6732 .mixers = { alc883_base_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_sixstack_modes),
6741 .channel_mode = alc883_sixstack_modes,
6742 .input_mux = &alc883_capture_source,
6743 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006744 [ALC883_TARGA_DIG] = {
6745 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6746 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6747 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6748 .dac_nids = alc883_dac_nids,
6749 .dig_out_nid = ALC883_DIGOUT_NID,
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,
6754 .need_dac_fix = 1,
6755 .input_mux = &alc883_capture_source,
6756 .unsol_event = alc883_tagra_unsol_event,
6757 .init_hook = alc883_tagra_automute,
6758 },
6759 [ALC883_TARGA_2ch_DIG] = {
6760 .mixers = { alc883_tagra_2ch_mixer},
6761 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6763 .dac_nids = alc883_dac_nids,
6764 .dig_out_nid = ALC883_DIGOUT_NID,
6765 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6766 .adc_nids = alc883_adc_nids,
6767 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6768 .channel_mode = alc883_3ST_2ch_modes,
6769 .input_mux = &alc883_capture_source,
6770 .unsol_event = alc883_tagra_unsol_event,
6771 .init_hook = alc883_tagra_automute,
6772 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02006773 [ALC883_ACER] = {
6774 .mixers = { alc883_base_mixer,
6775 alc883_chmode_mixer },
6776 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6777 * and the headphone jack. Turn this on and rely on the
6778 * standard mute methods whenever the user wants to turn
6779 * these outputs off.
6780 */
6781 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6782 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6783 .dac_nids = alc883_dac_nids,
6784 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6785 .adc_nids = alc883_adc_nids,
6786 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6787 .channel_mode = alc883_3ST_2ch_modes,
6788 .input_mux = &alc883_capture_source,
6789 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006790 [ALC883_MEDION] = {
6791 .mixers = { alc883_fivestack_mixer,
6792 alc883_chmode_mixer },
6793 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006794 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006795 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6796 .dac_nids = alc883_dac_nids,
6797 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6798 .adc_nids = alc883_adc_nids,
6799 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6800 .channel_mode = alc883_sixstack_modes,
6801 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006802 },
Kailang Yang272a5272007-05-14 11:00:38 +02006803 [ALC883_MEDION_MD2] = {
6804 .mixers = { alc883_medion_md2_mixer},
6805 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6807 .dac_nids = alc883_dac_nids,
6808 .dig_out_nid = ALC883_DIGOUT_NID,
6809 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6810 .adc_nids = alc883_adc_nids,
6811 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6812 .channel_mode = alc883_3ST_2ch_modes,
6813 .input_mux = &alc883_capture_source,
6814 .unsol_event = alc883_medion_md2_unsol_event,
6815 .init_hook = alc883_medion_md2_automute,
6816 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006817 [ALC883_LAPTOP_EAPD] = {
6818 .mixers = { alc883_base_mixer,
6819 alc883_chmode_mixer },
6820 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6821 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6822 .dac_nids = alc883_dac_nids,
6823 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6824 .adc_nids = alc883_adc_nids,
6825 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6826 .channel_mode = alc883_3ST_2ch_modes,
6827 .input_mux = &alc883_capture_source,
6828 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006829 [ALC883_LENOVO_101E_2ch] = {
6830 .mixers = { alc883_lenovo_101e_2ch_mixer},
6831 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6832 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6833 .dac_nids = alc883_dac_nids,
6834 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6835 .adc_nids = alc883_adc_nids,
6836 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6837 .channel_mode = alc883_3ST_2ch_modes,
6838 .input_mux = &alc883_lenovo_101e_capture_source,
6839 .unsol_event = alc883_lenovo_101e_unsol_event,
6840 .init_hook = alc883_lenovo_101e_all_automute,
6841 },
Kailang Yang272a5272007-05-14 11:00:38 +02006842 [ALC883_LENOVO_NB0763] = {
6843 .mixers = { alc883_lenovo_nb0763_mixer },
6844 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6846 .dac_nids = alc883_dac_nids,
6847 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6848 .adc_nids = alc883_adc_nids,
6849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6850 .channel_mode = alc883_3ST_2ch_modes,
6851 .need_dac_fix = 1,
6852 .input_mux = &alc883_lenovo_nb0763_capture_source,
6853 .unsol_event = alc883_medion_md2_unsol_event,
6854 .init_hook = alc883_medion_md2_automute,
6855 },
6856 [ALC888_LENOVO_MS7195_DIG] = {
6857 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6858 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6860 .dac_nids = alc883_dac_nids,
6861 .dig_out_nid = ALC883_DIGOUT_NID,
6862 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6863 .adc_nids = alc883_adc_nids,
6864 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6865 .channel_mode = alc883_3ST_6ch_modes,
6866 .need_dac_fix = 1,
6867 .input_mux = &alc883_capture_source,
6868 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6869 .init_hook = alc888_lenovo_ms7195_front_automute,
6870 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006871 [ALC888_6ST_HP] = {
6872 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6873 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006874 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6875 .dac_nids = alc883_dac_nids,
6876 .dig_out_nid = ALC883_DIGOUT_NID,
6877 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6878 .adc_nids = alc883_adc_nids,
6879 .dig_in_nid = ALC883_DIGIN_NID,
6880 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6881 .channel_mode = alc883_sixstack_modes,
6882 .input_mux = &alc883_capture_source,
6883 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006884 [ALC888_3ST_HP] = {
6885 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6886 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006887 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6888 .dac_nids = alc883_dac_nids,
6889 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6890 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006891 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6892 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006893 .need_dac_fix = 1,
6894 .input_mux = &alc883_capture_source,
6895 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006896};
6897
6898
6899/*
6900 * BIOS auto configuration
6901 */
6902static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6903 hda_nid_t nid, int pin_type,
6904 int dac_idx)
6905{
6906 /* set as output */
6907 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006908 int idx;
6909
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006910 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6911 idx = 4;
6912 else
6913 idx = spec->multiout.dac_nids[dac_idx] - 2;
6914
6915 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6916 pin_type);
6917 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6918 AMP_OUT_UNMUTE);
6919 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6920
6921}
6922
6923static void alc883_auto_init_multi_out(struct hda_codec *codec)
6924{
6925 struct alc_spec *spec = codec->spec;
6926 int i;
6927
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006928 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006929 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006930 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006931 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006932 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006933 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006934 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006935 }
6936}
6937
6938static void alc883_auto_init_hp_out(struct hda_codec *codec)
6939{
6940 struct alc_spec *spec = codec->spec;
6941 hda_nid_t pin;
6942
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006943 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006944 if (pin) /* connect to front */
6945 /* use dac 0 */
6946 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6947}
6948
6949#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6950#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6951
6952static void alc883_auto_init_analog_input(struct hda_codec *codec)
6953{
6954 struct alc_spec *spec = codec->spec;
6955 int i;
6956
6957 for (i = 0; i < AUTO_PIN_LAST; i++) {
6958 hda_nid_t nid = spec->autocfg.input_pins[i];
6959 if (alc883_is_input_pin(nid)) {
6960 snd_hda_codec_write(codec, nid, 0,
6961 AC_VERB_SET_PIN_WIDGET_CONTROL,
6962 (i <= AUTO_PIN_FRONT_MIC ?
6963 PIN_VREF80 : PIN_IN));
6964 if (nid != ALC883_PIN_CD_NID)
6965 snd_hda_codec_write(codec, nid, 0,
6966 AC_VERB_SET_AMP_GAIN_MUTE,
6967 AMP_OUT_MUTE);
6968 }
6969 }
6970}
6971
6972/* almost identical with ALC880 parser... */
6973static int alc883_parse_auto_config(struct hda_codec *codec)
6974{
6975 struct alc_spec *spec = codec->spec;
6976 int err = alc880_parse_auto_config(codec);
6977
6978 if (err < 0)
6979 return err;
6980 else if (err > 0)
6981 /* hack - override the init verbs */
6982 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006983 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6984 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006985 return err;
6986}
6987
6988/* additional initialization for auto-configuration model */
6989static void alc883_auto_init(struct hda_codec *codec)
6990{
6991 alc883_auto_init_multi_out(codec);
6992 alc883_auto_init_hp_out(codec);
6993 alc883_auto_init_analog_input(codec);
6994}
6995
6996static int patch_alc883(struct hda_codec *codec)
6997{
6998 struct alc_spec *spec;
6999 int err, board_config;
7000
7001 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7002 if (spec == NULL)
7003 return -ENOMEM;
7004
7005 codec->spec = spec;
7006
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007007 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7008 alc883_models,
7009 alc883_cfg_tbl);
7010 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007011 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7012 "trying auto-probe from BIOS...\n");
7013 board_config = ALC883_AUTO;
7014 }
7015
7016 if (board_config == ALC883_AUTO) {
7017 /* automatic parse from the BIOS config */
7018 err = alc883_parse_auto_config(codec);
7019 if (err < 0) {
7020 alc_free(codec);
7021 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007022 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007023 printk(KERN_INFO
7024 "hda_codec: Cannot set up configuration "
7025 "from BIOS. Using base mode...\n");
7026 board_config = ALC883_3ST_2ch_DIG;
7027 }
7028 }
7029
7030 if (board_config != ALC883_AUTO)
7031 setup_preset(spec, &alc883_presets[board_config]);
7032
7033 spec->stream_name_analog = "ALC883 Analog";
7034 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7035 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7036
7037 spec->stream_name_digital = "ALC883 Digital";
7038 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7039 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7040
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007041 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007042 spec->adc_nids = alc883_adc_nids;
7043 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7044 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007045
7046 codec->patch_ops = alc_patch_ops;
7047 if (board_config == ALC883_AUTO)
7048 spec->init_hook = alc883_auto_init;
7049
7050 return 0;
7051}
7052
7053/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007054 * ALC262 support
7055 */
7056
7057#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7058#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7059
7060#define alc262_dac_nids alc260_dac_nids
7061#define alc262_adc_nids alc882_adc_nids
7062#define alc262_adc_nids_alt alc882_adc_nids_alt
7063
7064#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007065#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007066
7067static struct snd_kcontrol_new alc262_base_mixer[] = {
7068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7069 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007077 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7078 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007079 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007080 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7081 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7082 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7084 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7085 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007086 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007087};
7088
Kailang Yangccc656c2006-10-17 12:32:26 +02007089static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7090 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007098 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007099 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7100 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007101 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007102 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7103 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7104 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7106 { } /* end */
7107};
7108
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007109static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7111 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7113 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7114 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7115
7116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007119 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7120 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007121 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007122 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7123 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7124 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7125 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7126 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7127 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7128 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7129 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7130 { } /* end */
7131};
7132
Kailang Yangcd7509a2007-01-26 18:33:17 +01007133static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7134 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7135 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7136 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7138 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7139 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7140 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7141 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007142 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007143 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7144 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7145 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7146 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7147 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7148 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7149 { } /* end */
7150};
7151
7152static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7153 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7154 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007155 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007156 { } /* end */
7157};
7158
Kailang Yang272a5272007-05-14 11:00:38 +02007159static struct snd_kcontrol_new alc262_sony_mixer[] = {
7160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7161 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7164 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7165 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7166 { } /* end */
7167};
7168
Kailang Yang83c34212007-07-05 11:43:05 +02007169static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7171 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7175 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7176 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7177 { } /* end */
7178};
Kailang Yang272a5272007-05-14 11:00:38 +02007179
Kailang Yangdf694da2005-12-05 19:42:22 +01007180#define alc262_capture_mixer alc882_capture_mixer
7181#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7182
7183/*
7184 * generic initialization of ADC, input mixers and output mixers
7185 */
7186static struct hda_verb alc262_init_verbs[] = {
7187 /*
7188 * Unmute ADC0-2 and set the default input to mic-in
7189 */
7190 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7192 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7193 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7194 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7196
7197 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7198 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007199 * Note: PASD motherboards uses the Line In 2 as the input for
7200 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007201 */
7202 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7208
7209 /*
7210 * Set up output mixers (0x0c - 0x0e)
7211 */
7212 /* set vol=0 to output mixers */
7213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7216 /* set up input amps for analog loopback */
7217 /* Amp Indices: DAC = 0, mixer = 1 */
7218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7222 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7224
7225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7227 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7228 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7230 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7231
7232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7233 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7234 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7235 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7237
7238 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7239 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7240
7241 /* FIXME: use matrix-type input source selection */
7242 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7243 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7248 /* Input mixer2 */
7249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7250 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7251 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7253 /* Input mixer3 */
7254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007258
7259 { }
7260};
7261
Kailang Yangccc656c2006-10-17 12:32:26 +02007262static struct hda_verb alc262_hippo_unsol_verbs[] = {
7263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7264 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7265 {}
7266};
7267
7268static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7270 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7272
7273 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7275 {}
7276};
7277
Kailang Yang272a5272007-05-14 11:00:38 +02007278static struct hda_verb alc262_sony_unsol_verbs[] = {
7279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7280 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7282
7283 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7285};
7286
Kailang Yangccc656c2006-10-17 12:32:26 +02007287/* mute/unmute internal speaker according to the hp jack and mute state */
7288static void alc262_hippo_automute(struct hda_codec *codec, int force)
7289{
7290 struct alc_spec *spec = codec->spec;
7291 unsigned int mute;
7292
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007293 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007294 unsigned int present;
7295 /* need to execute and sync at first */
7296 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7297 present = snd_hda_codec_read(codec, 0x15, 0,
7298 AC_VERB_GET_PIN_SENSE, 0);
7299 spec->jack_present = (present & 0x80000000) != 0;
7300 spec->sense_updated = 1;
7301 }
7302 if (spec->jack_present) {
7303 /* mute internal speaker */
7304 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7305 0x80, 0x80);
7306 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7307 0x80, 0x80);
7308 } else {
7309 /* unmute internal speaker if necessary */
7310 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7311 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7312 0x80, mute & 0x80);
7313 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7314 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7315 0x80, mute & 0x80);
7316 }
7317}
7318
7319/* unsolicited event for HP jack sensing */
7320static void alc262_hippo_unsol_event(struct hda_codec *codec,
7321 unsigned int res)
7322{
7323 if ((res >> 26) != ALC880_HP_EVENT)
7324 return;
7325 alc262_hippo_automute(codec, 1);
7326}
7327
7328static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7329{
7330 struct alc_spec *spec = codec->spec;
7331 unsigned int mute;
7332
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007333 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007334 unsigned int present;
7335 /* need to execute and sync at first */
7336 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7337 present = snd_hda_codec_read(codec, 0x1b, 0,
7338 AC_VERB_GET_PIN_SENSE, 0);
7339 spec->jack_present = (present & 0x80000000) != 0;
7340 spec->sense_updated = 1;
7341 }
7342 if (spec->jack_present) {
7343 /* mute internal speaker */
7344 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7345 0x80, 0x80);
7346 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7347 0x80, 0x80);
7348 } else {
7349 /* unmute internal speaker if necessary */
7350 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7351 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7352 0x80, mute & 0x80);
7353 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7354 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7355 0x80, mute & 0x80);
7356 }
7357}
7358
7359/* unsolicited event for HP jack sensing */
7360static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7361 unsigned int res)
7362{
7363 if ((res >> 26) != ALC880_HP_EVENT)
7364 return;
7365 alc262_hippo1_automute(codec, 1);
7366}
7367
Takashi Iwai834be882006-03-01 14:16:17 +01007368/*
7369 * fujitsu model
7370 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7371 */
7372
7373#define ALC_HP_EVENT 0x37
7374
7375static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7376 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7378 {}
7379};
7380
7381static struct hda_input_mux alc262_fujitsu_capture_source = {
7382 .num_items = 2,
7383 .items = {
7384 { "Mic", 0x0 },
7385 { "CD", 0x4 },
7386 },
7387};
7388
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007389static struct hda_input_mux alc262_HP_capture_source = {
7390 .num_items = 5,
7391 .items = {
7392 { "Mic", 0x0 },
7393 { "Front Mic", 0x3 },
7394 { "Line", 0x2 },
7395 { "CD", 0x4 },
7396 { "AUX IN", 0x6 },
7397 },
7398};
7399
Takashi Iwai834be882006-03-01 14:16:17 +01007400/* mute/unmute internal speaker according to the hp jack and mute state */
7401static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7402{
7403 struct alc_spec *spec = codec->spec;
7404 unsigned int mute;
7405
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007406 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007407 unsigned int present;
7408 /* need to execute and sync at first */
7409 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7410 present = snd_hda_codec_read(codec, 0x14, 0,
7411 AC_VERB_GET_PIN_SENSE, 0);
7412 spec->jack_present = (present & 0x80000000) != 0;
7413 spec->sense_updated = 1;
7414 }
7415 if (spec->jack_present) {
7416 /* mute internal speaker */
7417 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7418 0x80, 0x80);
7419 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7420 0x80, 0x80);
7421 } else {
7422 /* unmute internal speaker if necessary */
7423 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7424 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7425 0x80, mute & 0x80);
7426 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7427 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7428 0x80, mute & 0x80);
7429 }
7430}
7431
7432/* unsolicited event for HP jack sensing */
7433static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7434 unsigned int res)
7435{
7436 if ((res >> 26) != ALC_HP_EVENT)
7437 return;
7438 alc262_fujitsu_automute(codec, 1);
7439}
7440
7441/* bind volumes of both NID 0x0c and 0x0d */
7442static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7443 struct snd_ctl_elem_value *ucontrol)
7444{
7445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7446 long *valp = ucontrol->value.integer.value;
7447 int change;
7448
7449 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7450 0x7f, valp[0] & 0x7f);
7451 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7452 0x7f, valp[1] & 0x7f);
7453 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7454 0x7f, valp[0] & 0x7f);
7455 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7456 0x7f, valp[1] & 0x7f);
7457 return change;
7458}
7459
7460/* bind hp and internal speaker mute (with plug check) */
7461static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7462 struct snd_ctl_elem_value *ucontrol)
7463{
7464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7465 long *valp = ucontrol->value.integer.value;
7466 int change;
7467
7468 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7469 0x80, valp[0] ? 0 : 0x80);
7470 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7471 0x80, valp[1] ? 0 : 0x80);
7472 if (change || codec->in_resume)
7473 alc262_fujitsu_automute(codec, codec->in_resume);
7474 return change;
7475}
7476
7477static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7478 {
7479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7480 .name = "Master Playback Volume",
7481 .info = snd_hda_mixer_amp_volume_info,
7482 .get = snd_hda_mixer_amp_volume_get,
7483 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007484 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007485 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7486 },
7487 {
7488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7489 .name = "Master Playback Switch",
7490 .info = snd_hda_mixer_amp_switch_info,
7491 .get = snd_hda_mixer_amp_switch_get,
7492 .put = alc262_fujitsu_master_sw_put,
7493 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7494 },
7495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7497 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7499 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7500 { } /* end */
7501};
7502
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007503/* additional init verbs for Benq laptops */
7504static struct hda_verb alc262_EAPD_verbs[] = {
7505 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7506 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7507 {}
7508};
7509
Kailang Yang83c34212007-07-05 11:43:05 +02007510static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7513
7514 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7515 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7516 {}
7517};
7518
Kailang Yangdf694da2005-12-05 19:42:22 +01007519/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007520static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7521 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007522{
7523 hda_nid_t nid;
7524 int err;
7525
7526 spec->multiout.num_dacs = 1; /* only use one dac */
7527 spec->multiout.dac_nids = spec->private_dac_nids;
7528 spec->multiout.dac_nids[0] = 2;
7529
7530 nid = cfg->line_out_pins[0];
7531 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007532 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7533 "Front Playback Volume",
7534 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7535 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007536 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007537 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7538 "Front Playback Switch",
7539 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7540 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007541 return err;
7542 }
7543
Takashi Iwai82bc9552006-03-21 11:24:42 +01007544 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007545 if (nid) {
7546 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007547 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7548 "Speaker Playback Volume",
7549 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7550 HDA_OUTPUT));
7551 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007552 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007553 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7554 "Speaker Playback Switch",
7555 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7556 HDA_OUTPUT));
7557 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007558 return err;
7559 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007560 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7561 "Speaker Playback Switch",
7562 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7563 HDA_OUTPUT));
7564 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007565 return err;
7566 }
7567 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007568 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007569 if (nid) {
7570 /* spec->multiout.hp_nid = 2; */
7571 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007572 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7573 "Headphone Playback Volume",
7574 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7575 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 "Headphone Playback Switch",
7580 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7581 HDA_OUTPUT));
7582 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007583 return err;
7584 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007585 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7586 "Headphone Playback Switch",
7587 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7588 HDA_OUTPUT));
7589 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007590 return err;
7591 }
7592 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007593 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007594}
7595
7596/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007597#define alc262_auto_create_analog_input_ctls \
7598 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007599
7600/*
7601 * generic initialization of ADC, input mixers and output mixers
7602 */
7603static struct hda_verb alc262_volume_init_verbs[] = {
7604 /*
7605 * Unmute ADC0-2 and set the default input to mic-in
7606 */
7607 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7609 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7611 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7612 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7613
7614 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7615 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007616 * Note: PASD motherboards uses the Line In 2 as the input for
7617 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007618 */
7619 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7620 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7621 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7623 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7625
7626 /*
7627 * Set up output mixers (0x0c - 0x0f)
7628 */
7629 /* set vol=0 to output mixers */
7630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7633
7634 /* set up input amps for analog loopback */
7635 /* Amp Indices: DAC = 0, mixer = 1 */
7636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7640 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7642
7643 /* FIXME: use matrix-type input source selection */
7644 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7645 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7646 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7648 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7649 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7650 /* Input mixer2 */
7651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7655 /* Input mixer3 */
7656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7660
7661 { }
7662};
7663
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007664static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7665 /*
7666 * Unmute ADC0-2 and set the default input to mic-in
7667 */
7668 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7670 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7672 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7673 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7674
7675 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7676 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007677 * Note: PASD motherboards uses the Line In 2 as the input for
7678 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007679 */
7680 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7688
7689 /*
7690 * Set up output mixers (0x0c - 0x0e)
7691 */
7692 /* set vol=0 to output mixers */
7693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7694 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7695 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7696
7697 /* set up input amps for analog loopback */
7698 /* Amp Indices: DAC = 0, mixer = 1 */
7699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7700 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7705
7706 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7709
7710 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7712
7713 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7714 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7715
7716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7718 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7719 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7721
7722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7724 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7726 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7727 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7728
7729
7730 /* FIXME: use matrix-type input source selection */
7731 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7732 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7736 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7737 /* Input mixer2 */
7738 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7740 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7741 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7742 /* Input mixer3 */
7743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7747
7748 { }
7749};
7750
Kailang Yangcd7509a2007-01-26 18:33:17 +01007751static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7752 /*
7753 * Unmute ADC0-2 and set the default input to mic-in
7754 */
7755 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7757 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7759 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7761
7762 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7763 * mixer widget
7764 * Note: PASD motherboards uses the Line In 2 as the input for front
7765 * panel mic (mic 2)
7766 */
7767 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7776 /*
7777 * Set up output mixers (0x0c - 0x0e)
7778 */
7779 /* set vol=0 to output mixers */
7780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7781 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7782 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7783
7784 /* set up input amps for analog loopback */
7785 /* Amp Indices: DAC = 0, mixer = 1 */
7786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7789 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7792
7793
7794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7795 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7796 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7797 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7798 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7799 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7800 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7801
7802 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7804
7805 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7807
7808 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7809 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7810 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7812 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7813 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7814
7815 /* FIXME: use matrix-type input source selection */
7816 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7817 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7818 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7819 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7820 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7821 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7822 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7823 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7824 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7825 /* Input mixer2 */
7826 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7827 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7828 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7830 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7831 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7833 /* Input mixer3 */
7834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7839 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7841
7842 { }
7843};
7844
Kailang Yangdf694da2005-12-05 19:42:22 +01007845/* pcm configuration: identiacal with ALC880 */
7846#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7847#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7848#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7849#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7850
7851/*
7852 * BIOS auto configuration
7853 */
7854static int alc262_parse_auto_config(struct hda_codec *codec)
7855{
7856 struct alc_spec *spec = codec->spec;
7857 int err;
7858 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7859
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007860 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7861 alc262_ignore);
7862 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007863 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007864 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007865 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007866 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7867 if (err < 0)
7868 return err;
7869 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7870 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007871 return err;
7872
7873 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7874
7875 if (spec->autocfg.dig_out_pin)
7876 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7877 if (spec->autocfg.dig_in_pin)
7878 spec->dig_in_nid = ALC262_DIGIN_NID;
7879
7880 if (spec->kctl_alloc)
7881 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7882
7883 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007884 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007885 spec->input_mux = &spec->private_imux;
7886
7887 return 1;
7888}
7889
7890#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7891#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7892#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7893
7894
7895/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007896static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007897{
Kailang Yangdf694da2005-12-05 19:42:22 +01007898 alc262_auto_init_multi_out(codec);
7899 alc262_auto_init_hp_out(codec);
7900 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007901}
7902
7903/*
7904 * configuration and preset
7905 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007906static const char *alc262_models[ALC262_MODEL_LAST] = {
7907 [ALC262_BASIC] = "basic",
7908 [ALC262_HIPPO] = "hippo",
7909 [ALC262_HIPPO_1] = "hippo_1",
7910 [ALC262_FUJITSU] = "fujitsu",
7911 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007912 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007913 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02007914 [ALC262_BENQ_T31] = "benq-t31",
7915 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007916 [ALC262_AUTO] = "auto",
7917};
7918
7919static struct snd_pci_quirk alc262_cfg_tbl[] = {
7920 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7921 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7922 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007923 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7924 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007925 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007926 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007927 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007928 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007929 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7930 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7931 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7932 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7933 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7934 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7935 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7936 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007937 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7938 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7939 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7940 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02007941 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Kailang Yang272a5272007-05-14 11:00:38 +02007942 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7943 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7944 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007945 {}
7946};
7947
7948static struct alc_config_preset alc262_presets[] = {
7949 [ALC262_BASIC] = {
7950 .mixers = { alc262_base_mixer },
7951 .init_verbs = { alc262_init_verbs },
7952 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7953 .dac_nids = alc262_dac_nids,
7954 .hp_nid = 0x03,
7955 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7956 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007957 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007958 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007959 [ALC262_HIPPO] = {
7960 .mixers = { alc262_base_mixer },
7961 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7962 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7963 .dac_nids = alc262_dac_nids,
7964 .hp_nid = 0x03,
7965 .dig_out_nid = ALC262_DIGOUT_NID,
7966 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7967 .channel_mode = alc262_modes,
7968 .input_mux = &alc262_capture_source,
7969 .unsol_event = alc262_hippo_unsol_event,
7970 },
7971 [ALC262_HIPPO_1] = {
7972 .mixers = { alc262_hippo1_mixer },
7973 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7974 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7975 .dac_nids = alc262_dac_nids,
7976 .hp_nid = 0x02,
7977 .dig_out_nid = ALC262_DIGOUT_NID,
7978 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7979 .channel_mode = alc262_modes,
7980 .input_mux = &alc262_capture_source,
7981 .unsol_event = alc262_hippo1_unsol_event,
7982 },
Takashi Iwai834be882006-03-01 14:16:17 +01007983 [ALC262_FUJITSU] = {
7984 .mixers = { alc262_fujitsu_mixer },
7985 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7986 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7987 .dac_nids = alc262_dac_nids,
7988 .hp_nid = 0x03,
7989 .dig_out_nid = ALC262_DIGOUT_NID,
7990 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7991 .channel_mode = alc262_modes,
7992 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007993 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007994 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007995 [ALC262_HP_BPC] = {
7996 .mixers = { alc262_HP_BPC_mixer },
7997 .init_verbs = { alc262_HP_BPC_init_verbs },
7998 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7999 .dac_nids = alc262_dac_nids,
8000 .hp_nid = 0x03,
8001 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8002 .channel_mode = alc262_modes,
8003 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008004 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008005 [ALC262_HP_BPC_D7000_WF] = {
8006 .mixers = { alc262_HP_BPC_WildWest_mixer },
8007 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8008 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8009 .dac_nids = alc262_dac_nids,
8010 .hp_nid = 0x03,
8011 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8012 .channel_mode = alc262_modes,
8013 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008014 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008015 [ALC262_HP_BPC_D7000_WL] = {
8016 .mixers = { alc262_HP_BPC_WildWest_mixer,
8017 alc262_HP_BPC_WildWest_option_mixer },
8018 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8019 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8020 .dac_nids = alc262_dac_nids,
8021 .hp_nid = 0x03,
8022 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8023 .channel_mode = alc262_modes,
8024 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008025 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008026 [ALC262_BENQ_ED8] = {
8027 .mixers = { alc262_base_mixer },
8028 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8029 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8030 .dac_nids = alc262_dac_nids,
8031 .hp_nid = 0x03,
8032 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8033 .channel_mode = alc262_modes,
8034 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008035 },
Kailang Yang272a5272007-05-14 11:00:38 +02008036 [ALC262_SONY_ASSAMD] = {
8037 .mixers = { alc262_sony_mixer },
8038 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8039 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8040 .dac_nids = alc262_dac_nids,
8041 .hp_nid = 0x02,
8042 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8043 .channel_mode = alc262_modes,
8044 .input_mux = &alc262_capture_source,
8045 .unsol_event = alc262_hippo_unsol_event,
Kailang Yang83c34212007-07-05 11:43:05 +02008046 },
8047 [ALC262_BENQ_T31] = {
8048 .mixers = { alc262_benq_t31_mixer },
8049 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8050 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8051 .dac_nids = alc262_dac_nids,
8052 .hp_nid = 0x03,
8053 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8054 .channel_mode = alc262_modes,
8055 .input_mux = &alc262_capture_source,
8056 .unsol_event = alc262_hippo_unsol_event,
Kailang Yang272a5272007-05-14 11:00:38 +02008057 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008058};
8059
8060static int patch_alc262(struct hda_codec *codec)
8061{
8062 struct alc_spec *spec;
8063 int board_config;
8064 int err;
8065
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008066 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008067 if (spec == NULL)
8068 return -ENOMEM;
8069
8070 codec->spec = spec;
8071#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008072 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8073 * under-run
8074 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008075 {
8076 int tmp;
8077 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8078 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8079 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8080 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8081 }
8082#endif
8083
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008084 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8085 alc262_models,
8086 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01008087
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008088 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008089 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8090 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008091 board_config = ALC262_AUTO;
8092 }
8093
8094 if (board_config == ALC262_AUTO) {
8095 /* automatic parse from the BIOS config */
8096 err = alc262_parse_auto_config(codec);
8097 if (err < 0) {
8098 alc_free(codec);
8099 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008100 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008101 printk(KERN_INFO
8102 "hda_codec: Cannot set up configuration "
8103 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008104 board_config = ALC262_BASIC;
8105 }
8106 }
8107
8108 if (board_config != ALC262_AUTO)
8109 setup_preset(spec, &alc262_presets[board_config]);
8110
8111 spec->stream_name_analog = "ALC262 Analog";
8112 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8113 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8114
8115 spec->stream_name_digital = "ALC262 Digital";
8116 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8117 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8118
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008119 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008120 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01008121 unsigned int wcap = get_wcaps(codec, 0x07);
8122
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008123 /* get type */
8124 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01008125 if (wcap != AC_WID_AUD_IN) {
8126 spec->adc_nids = alc262_adc_nids_alt;
8127 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008128 spec->mixers[spec->num_mixers] =
8129 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01008130 spec->num_mixers++;
8131 } else {
8132 spec->adc_nids = alc262_adc_nids;
8133 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8134 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8135 spec->num_mixers++;
8136 }
8137 }
8138
8139 codec->patch_ops = alc_patch_ops;
8140 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008141 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01008142
Kailang Yangdf694da2005-12-05 19:42:22 +01008143 return 0;
8144}
8145
Kailang Yangdf694da2005-12-05 19:42:22 +01008146/*
Kailang Yanga361d842007-06-05 12:30:55 +02008147 * ALC268 channel source setting (2 channel)
8148 */
8149#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8150#define alc268_modes alc260_modes
8151
8152static hda_nid_t alc268_dac_nids[2] = {
8153 /* front, hp */
8154 0x02, 0x03
8155};
8156
8157static hda_nid_t alc268_adc_nids[2] = {
8158 /* ADC0-1 */
8159 0x08, 0x07
8160};
8161
8162static hda_nid_t alc268_adc_nids_alt[1] = {
8163 /* ADC0 */
8164 0x08
8165};
8166
8167static struct snd_kcontrol_new alc268_base_mixer[] = {
8168 /* output mixer control */
8169 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8170 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8173 { }
8174};
8175
8176/*
8177 * generic initialization of ADC, input mixers and output mixers
8178 */
8179static struct hda_verb alc268_base_init_verbs[] = {
8180 /* Unmute DAC0-1 and set vol = 0 */
8181 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8182 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8184 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8185 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8186 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8187
8188 /*
8189 * Set up output mixers (0x0c - 0x0e)
8190 */
8191 /* set vol=0 to output mixers */
8192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8193 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8195 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8196
8197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8198 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8199
8200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8204 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8207 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8208
8209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8211 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8212 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8213 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8215 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8216 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8217
8218 /* FIXME: use matrix-type input source selection */
8219 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8220 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8221 /* Input mixer2 */
8222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8223 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8226
8227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8231 { }
8232};
8233
8234/*
8235 * generic initialization of ADC, input mixers and output mixers
8236 */
8237static struct hda_verb alc268_volume_init_verbs[] = {
8238 /* set output DAC */
8239 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8241 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8242 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8243
8244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8247 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8248 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8249
8250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255
8256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8259 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8260
8261 /* set PCBEEP vol = 0 */
8262 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8263
8264 { }
8265};
8266
8267#define alc268_mux_enum_info alc_mux_enum_info
8268#define alc268_mux_enum_get alc_mux_enum_get
8269
8270static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8271 struct snd_ctl_elem_value *ucontrol)
8272{
8273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8274 struct alc_spec *spec = codec->spec;
8275 const struct hda_input_mux *imux = spec->input_mux;
8276 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8277 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8278 hda_nid_t nid = capture_mixers[adc_idx];
8279 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8280 unsigned int i, idx;
8281
8282 idx = ucontrol->value.enumerated.item[0];
8283 if (idx >= imux->num_items)
8284 idx = imux->num_items - 1;
8285 if (*cur_val == idx && !codec->in_resume)
8286 return 0;
8287 for (i = 0; i < imux->num_items; i++) {
8288 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8289 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8290 v | (imux->items[i].index << 8));
8291 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8292 idx );
8293 }
8294 *cur_val = idx;
8295 return 1;
8296}
8297
8298static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8299 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8300 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8301 {
8302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8303 /* The multiple "Capture Source" controls confuse alsamixer
8304 * So call somewhat different..
8305 * FIXME: the controls appear in the "playback" view!
8306 */
8307 /* .name = "Capture Source", */
8308 .name = "Input Source",
8309 .count = 1,
8310 .info = alc268_mux_enum_info,
8311 .get = alc268_mux_enum_get,
8312 .put = alc268_mux_enum_put,
8313 },
8314 { } /* end */
8315};
8316
8317static struct snd_kcontrol_new alc268_capture_mixer[] = {
8318 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8319 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8320 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8321 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8322 {
8323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8324 /* The multiple "Capture Source" controls confuse alsamixer
8325 * So call somewhat different..
8326 * FIXME: the controls appear in the "playback" view!
8327 */
8328 /* .name = "Capture Source", */
8329 .name = "Input Source",
8330 .count = 2,
8331 .info = alc268_mux_enum_info,
8332 .get = alc268_mux_enum_get,
8333 .put = alc268_mux_enum_put,
8334 },
8335 { } /* end */
8336};
8337
8338static struct hda_input_mux alc268_capture_source = {
8339 .num_items = 4,
8340 .items = {
8341 { "Mic", 0x0 },
8342 { "Front Mic", 0x1 },
8343 { "Line", 0x2 },
8344 { "CD", 0x3 },
8345 },
8346};
8347
8348/* create input playback/capture controls for the given pin */
8349static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8350 const char *ctlname, int idx)
8351{
8352 char name[32];
8353 int err;
8354
8355 sprintf(name, "%s Playback Volume", ctlname);
8356 if (nid == 0x14) {
8357 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8358 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8359 HDA_OUTPUT));
8360 if (err < 0)
8361 return err;
8362 } else if (nid == 0x15) {
8363 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8364 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8365 HDA_OUTPUT));
8366 if (err < 0)
8367 return err;
8368 } else
8369 return -1;
8370 sprintf(name, "%s Playback Switch", ctlname);
8371 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8372 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8373 if (err < 0)
8374 return err;
8375 return 0;
8376}
8377
8378/* add playback controls from the parsed DAC table */
8379static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8380 const struct auto_pin_cfg *cfg)
8381{
8382 hda_nid_t nid;
8383 int err;
8384
8385 spec->multiout.num_dacs = 2; /* only use one dac */
8386 spec->multiout.dac_nids = spec->private_dac_nids;
8387 spec->multiout.dac_nids[0] = 2;
8388 spec->multiout.dac_nids[1] = 3;
8389
8390 nid = cfg->line_out_pins[0];
8391 if (nid)
8392 alc268_new_analog_output(spec, nid, "Front", 0);
8393
8394 nid = cfg->speaker_pins[0];
8395 if (nid == 0x1d) {
8396 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8397 "Speaker Playback Volume",
8398 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8399 if (err < 0)
8400 return err;
8401 }
8402 nid = cfg->hp_pins[0];
8403 if (nid)
8404 alc268_new_analog_output(spec, nid, "Headphone", 0);
8405
8406 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8407 if (nid == 0x16) {
8408 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8409 "Mono Playback Switch",
8410 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8411 if (err < 0)
8412 return err;
8413 }
8414 return 0;
8415}
8416
8417/* create playback/capture controls for input pins */
8418static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8419 const struct auto_pin_cfg *cfg)
8420{
8421 struct hda_input_mux *imux = &spec->private_imux;
8422 int i, idx1;
8423
8424 for (i = 0; i < AUTO_PIN_LAST; i++) {
8425 switch(cfg->input_pins[i]) {
8426 case 0x18:
8427 idx1 = 0; /* Mic 1 */
8428 break;
8429 case 0x19:
8430 idx1 = 1; /* Mic 2 */
8431 break;
8432 case 0x1a:
8433 idx1 = 2; /* Line In */
8434 break;
8435 case 0x1c:
8436 idx1 = 3; /* CD */
8437 break;
8438 default:
8439 continue;
8440 }
8441 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8442 imux->items[imux->num_items].index = idx1;
8443 imux->num_items++;
8444 }
8445 return 0;
8446}
8447
8448static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8449{
8450 struct alc_spec *spec = codec->spec;
8451 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8452 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8453 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8454 unsigned int dac_vol1, dac_vol2;
8455
8456 if (speaker_nid) {
8457 snd_hda_codec_write(codec, speaker_nid, 0,
8458 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8459 snd_hda_codec_write(codec, 0x0f, 0,
8460 AC_VERB_SET_AMP_GAIN_MUTE,
8461 AMP_IN_UNMUTE(1));
8462 snd_hda_codec_write(codec, 0x10, 0,
8463 AC_VERB_SET_AMP_GAIN_MUTE,
8464 AMP_IN_UNMUTE(1));
8465 } else {
8466 snd_hda_codec_write(codec, 0x0f, 0,
8467 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8468 snd_hda_codec_write(codec, 0x10, 0,
8469 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8470 }
8471
8472 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8473 if (line_nid == 0x14)
8474 dac_vol2 = AMP_OUT_ZERO;
8475 else if (line_nid == 0x15)
8476 dac_vol1 = AMP_OUT_ZERO;
8477 if (hp_nid == 0x14)
8478 dac_vol2 = AMP_OUT_ZERO;
8479 else if (hp_nid == 0x15)
8480 dac_vol1 = AMP_OUT_ZERO;
8481 if (line_nid != 0x16 || hp_nid != 0x16 ||
8482 spec->autocfg.line_out_pins[1] != 0x16 ||
8483 spec->autocfg.line_out_pins[2] != 0x16)
8484 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8485
8486 snd_hda_codec_write(codec, 0x02, 0,
8487 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8488 snd_hda_codec_write(codec, 0x03, 0,
8489 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8490}
8491
8492/* pcm configuration: identiacal with ALC880 */
8493#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8494#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8495#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8496
8497/*
8498 * BIOS auto configuration
8499 */
8500static int alc268_parse_auto_config(struct hda_codec *codec)
8501{
8502 struct alc_spec *spec = codec->spec;
8503 int err;
8504 static hda_nid_t alc268_ignore[] = { 0 };
8505
8506 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8507 alc268_ignore);
8508 if (err < 0)
8509 return err;
8510 if (!spec->autocfg.line_outs)
8511 return 0; /* can't find valid BIOS pin config */
8512
8513 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8514 if (err < 0)
8515 return err;
8516 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8517 if (err < 0)
8518 return err;
8519
8520 spec->multiout.max_channels = 2;
8521
8522 /* digital only support output */
8523 if (spec->autocfg.dig_out_pin)
8524 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8525
8526 if (spec->kctl_alloc)
8527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8528
8529 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8530 spec->num_mux_defs = 1;
8531 spec->input_mux = &spec->private_imux;
8532
8533 return 1;
8534}
8535
8536#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8537#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8538#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8539
8540/* init callback for auto-configuration model -- overriding the default init */
8541static void alc268_auto_init(struct hda_codec *codec)
8542{
8543 alc268_auto_init_multi_out(codec);
8544 alc268_auto_init_hp_out(codec);
8545 alc268_auto_init_mono_speaker_out(codec);
8546 alc268_auto_init_analog_input(codec);
8547}
8548
8549/*
8550 * configuration and preset
8551 */
8552static const char *alc268_models[ALC268_MODEL_LAST] = {
8553 [ALC268_3ST] = "3stack",
8554 [ALC268_AUTO] = "auto",
8555};
8556
8557static struct snd_pci_quirk alc268_cfg_tbl[] = {
8558 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8559 {}
8560};
8561
8562static struct alc_config_preset alc268_presets[] = {
8563 [ALC268_3ST] = {
8564 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8565 .init_verbs = { alc268_base_init_verbs },
8566 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8567 .dac_nids = alc268_dac_nids,
8568 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8569 .adc_nids = alc268_adc_nids_alt,
8570 .hp_nid = 0x03,
8571 .dig_out_nid = ALC268_DIGOUT_NID,
8572 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8573 .channel_mode = alc268_modes,
8574 .input_mux = &alc268_capture_source,
8575 },
8576};
8577
8578static int patch_alc268(struct hda_codec *codec)
8579{
8580 struct alc_spec *spec;
8581 int board_config;
8582 int err;
8583
8584 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8585 if (spec == NULL)
8586 return -ENOMEM;
8587
8588 codec->spec = spec;
8589
8590 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8591 alc268_models,
8592 alc268_cfg_tbl);
8593
8594 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8595 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8596 "trying auto-probe from BIOS...\n");
8597 board_config = ALC268_AUTO;
8598 }
8599
8600 if (board_config == ALC268_AUTO) {
8601 /* automatic parse from the BIOS config */
8602 err = alc268_parse_auto_config(codec);
8603 if (err < 0) {
8604 alc_free(codec);
8605 return err;
8606 } else if (!err) {
8607 printk(KERN_INFO
8608 "hda_codec: Cannot set up configuration "
8609 "from BIOS. Using base mode...\n");
8610 board_config = ALC268_3ST;
8611 }
8612 }
8613
8614 if (board_config != ALC268_AUTO)
8615 setup_preset(spec, &alc268_presets[board_config]);
8616
8617 spec->stream_name_analog = "ALC268 Analog";
8618 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8619 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8620
8621 spec->stream_name_digital = "ALC268 Digital";
8622 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8623
8624 if (board_config == ALC268_AUTO) {
8625 if (!spec->adc_nids && spec->input_mux) {
8626 /* check whether NID 0x07 is valid */
8627 unsigned int wcap = get_wcaps(codec, 0x07);
8628
8629 /* get type */
8630 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8631 if (wcap != AC_WID_AUD_IN) {
8632 spec->adc_nids = alc268_adc_nids_alt;
8633 spec->num_adc_nids =
8634 ARRAY_SIZE(alc268_adc_nids_alt);
8635 spec->mixers[spec->num_mixers] =
8636 alc268_capture_alt_mixer;
8637 spec->num_mixers++;
8638 } else {
8639 spec->adc_nids = alc268_adc_nids;
8640 spec->num_adc_nids =
8641 ARRAY_SIZE(alc268_adc_nids);
8642 spec->mixers[spec->num_mixers] =
8643 alc268_capture_mixer;
8644 spec->num_mixers++;
8645 }
8646 }
8647 }
8648 codec->patch_ops = alc_patch_ops;
8649 if (board_config == ALC268_AUTO)
8650 spec->init_hook = alc268_auto_init;
8651
8652 return 0;
8653}
8654
8655/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008656 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8657 */
8658
8659/*
8660 * set the path ways for 2 channel output
8661 * need to set the codec line out and mic 1 pin widgets to inputs
8662 */
8663static struct hda_verb alc861_threestack_ch2_init[] = {
8664 /* set pin widget 1Ah (line in) for input */
8665 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008666 /* set pin widget 18h (mic1/2) for input, for mic also enable
8667 * the vref
8668 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008669 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8670
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8672#if 0
8673 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8674 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8675#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008676 { } /* end */
8677};
8678/*
8679 * 6ch mode
8680 * need to set the codec line out and mic 1 pin widgets to outputs
8681 */
8682static struct hda_verb alc861_threestack_ch6_init[] = {
8683 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8684 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8685 /* set pin widget 18h (mic1) for output (CLFE)*/
8686 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8687
8688 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008689 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008690
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008691 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8692#if 0
8693 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8694 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8695#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008696 { } /* end */
8697};
8698
8699static struct hda_channel_mode alc861_threestack_modes[2] = {
8700 { 2, alc861_threestack_ch2_init },
8701 { 6, alc861_threestack_ch6_init },
8702};
Takashi Iwai22309c32006-08-09 16:57:28 +02008703/* Set mic1 as input and unmute the mixer */
8704static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8705 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8706 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8707 { } /* end */
8708};
8709/* Set mic1 as output and mute mixer */
8710static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8711 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8712 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8713 { } /* end */
8714};
8715
8716static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8717 { 2, alc861_uniwill_m31_ch2_init },
8718 { 4, alc861_uniwill_m31_ch4_init },
8719};
Kailang Yangdf694da2005-12-05 19:42:22 +01008720
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008721/* Set mic1 and line-in as input and unmute the mixer */
8722static struct hda_verb alc861_asus_ch2_init[] = {
8723 /* set pin widget 1Ah (line in) for input */
8724 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008725 /* set pin widget 18h (mic1/2) for input, for mic also enable
8726 * the vref
8727 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008728 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8729
8730 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8731#if 0
8732 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8733 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8734#endif
8735 { } /* end */
8736};
8737/* Set mic1 nad line-in as output and mute mixer */
8738static struct hda_verb alc861_asus_ch6_init[] = {
8739 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8740 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8741 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8742 /* set pin widget 18h (mic1) for output (CLFE)*/
8743 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8744 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8745 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8746 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8747
8748 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8749#if 0
8750 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8751 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8752#endif
8753 { } /* end */
8754};
8755
8756static struct hda_channel_mode alc861_asus_modes[2] = {
8757 { 2, alc861_asus_ch2_init },
8758 { 6, alc861_asus_ch6_init },
8759};
8760
Kailang Yangdf694da2005-12-05 19:42:22 +01008761/* patch-ALC861 */
8762
8763static struct snd_kcontrol_new alc861_base_mixer[] = {
8764 /* output mixer control */
8765 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8766 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8767 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8768 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8769 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8770
8771 /*Input mixer control */
8772 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8773 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8774 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8775 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8777 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8779 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008782
Kailang Yangdf694da2005-12-05 19:42:22 +01008783 /* Capture mixer control */
8784 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8785 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8786 {
8787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8788 .name = "Capture Source",
8789 .count = 1,
8790 .info = alc_mux_enum_info,
8791 .get = alc_mux_enum_get,
8792 .put = alc_mux_enum_put,
8793 },
8794 { } /* end */
8795};
8796
8797static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8798 /* output mixer control */
8799 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8800 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8801 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8802 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8803 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8804
8805 /* Input mixer control */
8806 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8807 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8808 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8809 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8810 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8811 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8813 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008816
Kailang Yangdf694da2005-12-05 19:42:22 +01008817 /* Capture mixer control */
8818 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8819 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8820 {
8821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8822 .name = "Capture Source",
8823 .count = 1,
8824 .info = alc_mux_enum_info,
8825 .get = alc_mux_enum_get,
8826 .put = alc_mux_enum_put,
8827 },
8828 {
8829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8830 .name = "Channel Mode",
8831 .info = alc_ch_mode_info,
8832 .get = alc_ch_mode_get,
8833 .put = alc_ch_mode_put,
8834 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8835 },
8836 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008837};
8838
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008839static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008840 /* output mixer control */
8841 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8843 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8844
8845 /*Capture mixer control */
8846 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8847 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8848 {
8849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8850 .name = "Capture Source",
8851 .count = 1,
8852 .info = alc_mux_enum_info,
8853 .get = alc_mux_enum_get,
8854 .put = alc_mux_enum_put,
8855 },
8856
8857 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008858};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008859
Takashi Iwai22309c32006-08-09 16:57:28 +02008860static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8861 /* output mixer control */
8862 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8863 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8864 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8865 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8866 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8867
8868 /* Input mixer control */
8869 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8870 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8871 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8872 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8873 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8874 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8876 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008879
Takashi Iwai22309c32006-08-09 16:57:28 +02008880 /* Capture mixer control */
8881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8883 {
8884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8885 .name = "Capture Source",
8886 .count = 1,
8887 .info = alc_mux_enum_info,
8888 .get = alc_mux_enum_get,
8889 .put = alc_mux_enum_put,
8890 },
8891 {
8892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8893 .name = "Channel Mode",
8894 .info = alc_ch_mode_info,
8895 .get = alc_ch_mode_get,
8896 .put = alc_ch_mode_put,
8897 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8898 },
8899 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008900};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008901
8902static struct snd_kcontrol_new alc861_asus_mixer[] = {
8903 /* output mixer control */
8904 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8905 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8907 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8908 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8909
8910 /* Input mixer control */
8911 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8912 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8913 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8914 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8915 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8916 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8918 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8919 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8921
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008922 /* Capture mixer control */
8923 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8924 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8925 {
8926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8927 .name = "Capture Source",
8928 .count = 1,
8929 .info = alc_mux_enum_info,
8930 .get = alc_mux_enum_get,
8931 .put = alc_mux_enum_put,
8932 },
8933 {
8934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8935 .name = "Channel Mode",
8936 .info = alc_ch_mode_info,
8937 .get = alc_ch_mode_get,
8938 .put = alc_ch_mode_put,
8939 .private_value = ARRAY_SIZE(alc861_asus_modes),
8940 },
8941 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008942};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008943
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008944/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008945static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008946 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8947 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8948 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8949 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8950 { }
8951};
8952
Kailang Yangdf694da2005-12-05 19:42:22 +01008953/*
8954 * generic initialization of ADC, input mixers and output mixers
8955 */
8956static struct hda_verb alc861_base_init_verbs[] = {
8957 /*
8958 * Unmute ADC0 and set the default input to mic-in
8959 */
8960 /* port-A for surround (rear panel) */
8961 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8962 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8963 /* port-B for mic-in (rear panel) with vref */
8964 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8965 /* port-C for line-in (rear panel) */
8966 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8967 /* port-D for Front */
8968 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8969 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8970 /* port-E for HP out (front panel) */
8971 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8972 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008973 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008974 /* port-F for mic-in (front panel) with vref */
8975 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8976 /* port-G for CLFE (rear panel) */
8977 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8978 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8979 /* port-H for side (rear panel) */
8980 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8981 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8982 /* CD-in */
8983 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8984 /* route front mic to ADC1*/
8985 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8987
8988 /* Unmute DAC0~3 & spdif out*/
8989 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8990 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8991 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8992 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8994
8995 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8996 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8997 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8998 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8999 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9000
9001 /* Unmute Stereo Mixer 15 */
9002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009006
9007 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9008 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9009 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9010 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9011 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9012 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9014 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009015 /* hp used DAC 3 (Front) */
9016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9018
9019 { }
9020};
9021
9022static struct hda_verb alc861_threestack_init_verbs[] = {
9023 /*
9024 * Unmute ADC0 and set the default input to mic-in
9025 */
9026 /* port-A for surround (rear panel) */
9027 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9028 /* port-B for mic-in (rear panel) with vref */
9029 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9030 /* port-C for line-in (rear panel) */
9031 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9032 /* port-D for Front */
9033 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9034 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9035 /* port-E for HP out (front panel) */
9036 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9037 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009038 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009039 /* port-F for mic-in (front panel) with vref */
9040 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9041 /* port-G for CLFE (rear panel) */
9042 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9043 /* port-H for side (rear panel) */
9044 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9045 /* CD-in */
9046 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9047 /* route front mic to ADC1*/
9048 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9049 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9050 /* Unmute DAC0~3 & spdif out*/
9051 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9052 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9053 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9054 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9056
9057 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9058 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9059 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9060 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9061 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9062
9063 /* Unmute Stereo Mixer 15 */
9064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009068
9069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9071 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9072 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009077 /* hp used DAC 3 (Front) */
9078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9080 { }
9081};
Takashi Iwai22309c32006-08-09 16:57:28 +02009082
9083static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9084 /*
9085 * Unmute ADC0 and set the default input to mic-in
9086 */
9087 /* port-A for surround (rear panel) */
9088 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9089 /* port-B for mic-in (rear panel) with vref */
9090 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9091 /* port-C for line-in (rear panel) */
9092 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9093 /* port-D for Front */
9094 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9095 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9096 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009097 /* this has to be set to VREF80 */
9098 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009099 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009100 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009101 /* port-F for mic-in (front panel) with vref */
9102 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9103 /* port-G for CLFE (rear panel) */
9104 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9105 /* port-H for side (rear panel) */
9106 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9107 /* CD-in */
9108 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9109 /* route front mic to ADC1*/
9110 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9112 /* Unmute DAC0~3 & spdif out*/
9113 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9114 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9115 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9116 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9118
9119 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9120 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9121 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9122 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9123 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9124
9125 /* Unmute Stereo Mixer 15 */
9126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02009130
9131 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9133 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9134 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9135 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009139 /* hp used DAC 3 (Front) */
9140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9142 { }
9143};
9144
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009145static struct hda_verb alc861_asus_init_verbs[] = {
9146 /*
9147 * Unmute ADC0 and set the default input to mic-in
9148 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009149 /* port-A for surround (rear panel)
9150 * according to codec#0 this is the HP jack
9151 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009152 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9153 /* route front PCM to HP */
9154 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9155 /* port-B for mic-in (rear panel) with vref */
9156 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9157 /* port-C for line-in (rear panel) */
9158 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9159 /* port-D for Front */
9160 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9161 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9162 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009163 /* this has to be set to VREF80 */
9164 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009165 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009166 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009167 /* port-F for mic-in (front panel) with vref */
9168 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9169 /* port-G for CLFE (rear panel) */
9170 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9171 /* port-H for side (rear panel) */
9172 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9173 /* CD-in */
9174 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9175 /* route front mic to ADC1*/
9176 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 /* Unmute DAC0~3 & spdif out*/
9179 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9180 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9181 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9182 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9184 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9185 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9186 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9187 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9188 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9189
9190 /* Unmute Stereo Mixer 15 */
9191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009195
9196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9198 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9199 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9202 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009204 /* hp used DAC 3 (Front) */
9205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9207 { }
9208};
9209
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009210/* additional init verbs for ASUS laptops */
9211static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9212 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9213 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9214 { }
9215};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009216
Kailang Yangdf694da2005-12-05 19:42:22 +01009217/*
9218 * generic initialization of ADC, input mixers and output mixers
9219 */
9220static struct hda_verb alc861_auto_init_verbs[] = {
9221 /*
9222 * Unmute ADC0 and set the default input to mic-in
9223 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009224 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9226
9227 /* Unmute DAC0~3 & spdif out*/
9228 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9230 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9231 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9233
9234 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9235 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9236 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9237 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9238 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9239
9240 /* Unmute Stereo Mixer 15 */
9241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9245
9246 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9247 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9248 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9249 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9250 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9254
9255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9262 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009263
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009265
9266 { }
9267};
9268
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009269static struct hda_verb alc861_toshiba_init_verbs[] = {
9270 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009271
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009272 { }
9273};
9274
9275/* toggle speaker-output according to the hp-jack state */
9276static void alc861_toshiba_automute(struct hda_codec *codec)
9277{
9278 unsigned int present;
9279
9280 present = snd_hda_codec_read(codec, 0x0f, 0,
9281 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9282 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
9283 0x80, present ? 0x80 : 0);
9284 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
9285 0x80, present ? 0x80 : 0);
9286 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
9287 0x80, present ? 0 : 0x80);
9288 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
9289 0x80, present ? 0 : 0x80);
9290}
9291
9292static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9293 unsigned int res)
9294{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009295 if ((res >> 26) == ALC880_HP_EVENT)
9296 alc861_toshiba_automute(codec);
9297}
9298
Kailang Yangdf694da2005-12-05 19:42:22 +01009299/* pcm configuration: identiacal with ALC880 */
9300#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9301#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9302#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9303#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9304
9305
9306#define ALC861_DIGOUT_NID 0x07
9307
9308static struct hda_channel_mode alc861_8ch_modes[1] = {
9309 { 8, NULL }
9310};
9311
9312static hda_nid_t alc861_dac_nids[4] = {
9313 /* front, surround, clfe, side */
9314 0x03, 0x06, 0x05, 0x04
9315};
9316
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009317static hda_nid_t alc660_dac_nids[3] = {
9318 /* front, clfe, surround */
9319 0x03, 0x05, 0x06
9320};
9321
Kailang Yangdf694da2005-12-05 19:42:22 +01009322static hda_nid_t alc861_adc_nids[1] = {
9323 /* ADC0-2 */
9324 0x08,
9325};
9326
9327static struct hda_input_mux alc861_capture_source = {
9328 .num_items = 5,
9329 .items = {
9330 { "Mic", 0x0 },
9331 { "Front Mic", 0x3 },
9332 { "Line", 0x1 },
9333 { "CD", 0x4 },
9334 { "Mixer", 0x5 },
9335 },
9336};
9337
9338/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009339static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9340 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009341{
9342 int i;
9343 hda_nid_t nid;
9344
9345 spec->multiout.dac_nids = spec->private_dac_nids;
9346 for (i = 0; i < cfg->line_outs; i++) {
9347 nid = cfg->line_out_pins[i];
9348 if (nid) {
9349 if (i >= ARRAY_SIZE(alc861_dac_nids))
9350 continue;
9351 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9352 }
9353 }
9354 spec->multiout.num_dacs = cfg->line_outs;
9355 return 0;
9356}
9357
9358/* add playback controls from the parsed DAC table */
9359static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9360 const struct auto_pin_cfg *cfg)
9361{
9362 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009363 static const char *chname[4] = {
9364 "Front", "Surround", NULL /*CLFE*/, "Side"
9365 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009366 hda_nid_t nid;
9367 int i, idx, err;
9368
9369 for (i = 0; i < cfg->line_outs; i++) {
9370 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009371 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009372 continue;
9373 if (nid == 0x05) {
9374 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009375 err = add_control(spec, ALC_CTL_BIND_MUTE,
9376 "Center Playback Switch",
9377 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9378 HDA_OUTPUT));
9379 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009380 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009381 err = add_control(spec, ALC_CTL_BIND_MUTE,
9382 "LFE Playback Switch",
9383 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9384 HDA_OUTPUT));
9385 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009386 return err;
9387 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009388 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9389 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009390 if (nid == alc861_dac_nids[idx])
9391 break;
9392 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009393 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9394 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9395 HDA_OUTPUT));
9396 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009397 return err;
9398 }
9399 }
9400 return 0;
9401}
9402
9403static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9404{
9405 int err;
9406 hda_nid_t nid;
9407
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009408 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009409 return 0;
9410
9411 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9412 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009413 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9414 "Headphone Playback Switch",
9415 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9416 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009417 return err;
9418 spec->multiout.hp_nid = nid;
9419 }
9420 return 0;
9421}
9422
9423/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009424static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9425 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009426{
Kailang Yangdf694da2005-12-05 19:42:22 +01009427 struct hda_input_mux *imux = &spec->private_imux;
9428 int i, err, idx, idx1;
9429
9430 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009431 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009432 case 0x0c:
9433 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009434 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009435 break;
9436 case 0x0f:
9437 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009438 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009439 break;
9440 case 0x0d:
9441 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009442 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009443 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009444 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009445 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009446 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009447 break;
9448 case 0x11:
9449 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009450 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009451 break;
9452 default:
9453 continue;
9454 }
9455
Takashi Iwai4a471b72005-12-07 13:56:29 +01009456 err = new_analog_input(spec, cfg->input_pins[i],
9457 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009458 if (err < 0)
9459 return err;
9460
Takashi Iwai4a471b72005-12-07 13:56:29 +01009461 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009462 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009463 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 }
9465 return 0;
9466}
9467
9468static struct snd_kcontrol_new alc861_capture_mixer[] = {
9469 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9470 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9471
9472 {
9473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9474 /* The multiple "Capture Source" controls confuse alsamixer
9475 * So call somewhat different..
9476 *FIXME: the controls appear in the "playback" view!
9477 */
9478 /* .name = "Capture Source", */
9479 .name = "Input Source",
9480 .count = 1,
9481 .info = alc_mux_enum_info,
9482 .get = alc_mux_enum_get,
9483 .put = alc_mux_enum_put,
9484 },
9485 { } /* end */
9486};
9487
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009488static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9489 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009490 int pin_type, int dac_idx)
9491{
9492 /* set as output */
9493
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9495 pin_type);
9496 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9497 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009498
9499}
9500
9501static void alc861_auto_init_multi_out(struct hda_codec *codec)
9502{
9503 struct alc_spec *spec = codec->spec;
9504 int i;
9505
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009506 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009507 for (i = 0; i < spec->autocfg.line_outs; i++) {
9508 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009509 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009510 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009511 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009512 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009513 }
9514}
9515
9516static void alc861_auto_init_hp_out(struct hda_codec *codec)
9517{
9518 struct alc_spec *spec = codec->spec;
9519 hda_nid_t pin;
9520
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009521 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009522 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009523 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9524 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009525}
9526
9527static void alc861_auto_init_analog_input(struct hda_codec *codec)
9528{
9529 struct alc_spec *spec = codec->spec;
9530 int i;
9531
9532 for (i = 0; i < AUTO_PIN_LAST; i++) {
9533 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009534 if (nid >= 0x0c && nid <= 0x11) {
9535 snd_hda_codec_write(codec, nid, 0,
9536 AC_VERB_SET_PIN_WIDGET_CONTROL,
9537 i <= AUTO_PIN_FRONT_MIC ?
9538 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009539 }
9540 }
9541}
9542
9543/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009544/* return 1 if successful, 0 if the proper config is not found,
9545 * or a negative error code
9546 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009547static int alc861_parse_auto_config(struct hda_codec *codec)
9548{
9549 struct alc_spec *spec = codec->spec;
9550 int err;
9551 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9552
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9554 alc861_ignore);
9555 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009557 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009558 return 0; /* can't find valid BIOS pin config */
9559
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009560 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9561 if (err < 0)
9562 return err;
9563 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9564 if (err < 0)
9565 return err;
9566 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9567 if (err < 0)
9568 return err;
9569 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9570 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009571 return err;
9572
9573 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9574
9575 if (spec->autocfg.dig_out_pin)
9576 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9577
9578 if (spec->kctl_alloc)
9579 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9580
9581 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9582
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009583 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009584 spec->input_mux = &spec->private_imux;
9585
9586 spec->adc_nids = alc861_adc_nids;
9587 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9588 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9589 spec->num_mixers++;
9590
9591 return 1;
9592}
9593
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009594/* additional initialization for auto-configuration model */
9595static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009596{
Kailang Yangdf694da2005-12-05 19:42:22 +01009597 alc861_auto_init_multi_out(codec);
9598 alc861_auto_init_hp_out(codec);
9599 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009600}
9601
9602
9603/*
9604 * configuration and preset
9605 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009606static const char *alc861_models[ALC861_MODEL_LAST] = {
9607 [ALC861_3ST] = "3stack",
9608 [ALC660_3ST] = "3stack-660",
9609 [ALC861_3ST_DIG] = "3stack-dig",
9610 [ALC861_6ST_DIG] = "6stack-dig",
9611 [ALC861_UNIWILL_M31] = "uniwill-m31",
9612 [ALC861_TOSHIBA] = "toshiba",
9613 [ALC861_ASUS] = "asus",
9614 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9615 [ALC861_AUTO] = "auto",
9616};
9617
9618static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009619 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009620 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9621 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009622 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +02009623 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009624 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +02009625 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +01009626 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +02009627 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9628 * Any other models that need this preset?
9629 */
9630 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009631 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009632 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009633 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009634 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009635 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Claudio Matsuokaef64adb2007-07-14 00:26:16 +02009636 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9637 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009638 {}
9639};
9640
9641static struct alc_config_preset alc861_presets[] = {
9642 [ALC861_3ST] = {
9643 .mixers = { alc861_3ST_mixer },
9644 .init_verbs = { alc861_threestack_init_verbs },
9645 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9646 .dac_nids = alc861_dac_nids,
9647 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9648 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009649 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009650 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9651 .adc_nids = alc861_adc_nids,
9652 .input_mux = &alc861_capture_source,
9653 },
9654 [ALC861_3ST_DIG] = {
9655 .mixers = { alc861_base_mixer },
9656 .init_verbs = { alc861_threestack_init_verbs },
9657 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9658 .dac_nids = alc861_dac_nids,
9659 .dig_out_nid = ALC861_DIGOUT_NID,
9660 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9661 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009662 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009663 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9664 .adc_nids = alc861_adc_nids,
9665 .input_mux = &alc861_capture_source,
9666 },
9667 [ALC861_6ST_DIG] = {
9668 .mixers = { alc861_base_mixer },
9669 .init_verbs = { alc861_base_init_verbs },
9670 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9671 .dac_nids = alc861_dac_nids,
9672 .dig_out_nid = ALC861_DIGOUT_NID,
9673 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9674 .channel_mode = alc861_8ch_modes,
9675 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9676 .adc_nids = alc861_adc_nids,
9677 .input_mux = &alc861_capture_source,
9678 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009679 [ALC660_3ST] = {
9680 .mixers = { alc861_3ST_mixer },
9681 .init_verbs = { alc861_threestack_init_verbs },
9682 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9683 .dac_nids = alc660_dac_nids,
9684 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9685 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009686 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009687 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9688 .adc_nids = alc861_adc_nids,
9689 .input_mux = &alc861_capture_source,
9690 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009691 [ALC861_UNIWILL_M31] = {
9692 .mixers = { alc861_uniwill_m31_mixer },
9693 .init_verbs = { alc861_uniwill_m31_init_verbs },
9694 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9695 .dac_nids = alc861_dac_nids,
9696 .dig_out_nid = ALC861_DIGOUT_NID,
9697 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9698 .channel_mode = alc861_uniwill_m31_modes,
9699 .need_dac_fix = 1,
9700 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9701 .adc_nids = alc861_adc_nids,
9702 .input_mux = &alc861_capture_source,
9703 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009704 [ALC861_TOSHIBA] = {
9705 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009706 .init_verbs = { alc861_base_init_verbs,
9707 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009708 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9709 .dac_nids = alc861_dac_nids,
9710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9711 .channel_mode = alc883_3ST_2ch_modes,
9712 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9713 .adc_nids = alc861_adc_nids,
9714 .input_mux = &alc861_capture_source,
9715 .unsol_event = alc861_toshiba_unsol_event,
9716 .init_hook = alc861_toshiba_automute,
9717 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009718 [ALC861_ASUS] = {
9719 .mixers = { alc861_asus_mixer },
9720 .init_verbs = { alc861_asus_init_verbs },
9721 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9722 .dac_nids = alc861_dac_nids,
9723 .dig_out_nid = ALC861_DIGOUT_NID,
9724 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9725 .channel_mode = alc861_asus_modes,
9726 .need_dac_fix = 1,
9727 .hp_nid = 0x06,
9728 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9729 .adc_nids = alc861_adc_nids,
9730 .input_mux = &alc861_capture_source,
9731 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009732 [ALC861_ASUS_LAPTOP] = {
9733 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9734 .init_verbs = { alc861_asus_init_verbs,
9735 alc861_asus_laptop_init_verbs },
9736 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9737 .dac_nids = alc861_dac_nids,
9738 .dig_out_nid = ALC861_DIGOUT_NID,
9739 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9740 .channel_mode = alc883_3ST_2ch_modes,
9741 .need_dac_fix = 1,
9742 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9743 .adc_nids = alc861_adc_nids,
9744 .input_mux = &alc861_capture_source,
9745 },
9746};
Kailang Yangdf694da2005-12-05 19:42:22 +01009747
9748
9749static int patch_alc861(struct hda_codec *codec)
9750{
9751 struct alc_spec *spec;
9752 int board_config;
9753 int err;
9754
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009755 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009756 if (spec == NULL)
9757 return -ENOMEM;
9758
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009759 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009760
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009761 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9762 alc861_models,
9763 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009764
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009765 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009766 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9767 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009768 board_config = ALC861_AUTO;
9769 }
9770
9771 if (board_config == ALC861_AUTO) {
9772 /* automatic parse from the BIOS config */
9773 err = alc861_parse_auto_config(codec);
9774 if (err < 0) {
9775 alc_free(codec);
9776 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009777 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009778 printk(KERN_INFO
9779 "hda_codec: Cannot set up configuration "
9780 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009781 board_config = ALC861_3ST_DIG;
9782 }
9783 }
9784
9785 if (board_config != ALC861_AUTO)
9786 setup_preset(spec, &alc861_presets[board_config]);
9787
9788 spec->stream_name_analog = "ALC861 Analog";
9789 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9790 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9791
9792 spec->stream_name_digital = "ALC861 Digital";
9793 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9794 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9795
9796 codec->patch_ops = alc_patch_ops;
9797 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009798 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009799
9800 return 0;
9801}
9802
9803/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009804 * ALC861-VD support
9805 *
9806 * Based on ALC882
9807 *
9808 * In addition, an independent DAC
9809 */
9810#define ALC861VD_DIGOUT_NID 0x06
9811
9812static hda_nid_t alc861vd_dac_nids[4] = {
9813 /* front, surr, clfe, side surr */
9814 0x02, 0x03, 0x04, 0x05
9815};
9816
9817/* dac_nids for ALC660vd are in a different order - according to
9818 * Realtek's driver.
9819 * This should probably tesult in a different mixer for 6stack models
9820 * of ALC660vd codecs, but for now there is only 3stack mixer
9821 * - and it is the same as in 861vd.
9822 * adc_nids in ALC660vd are (is) the same as in 861vd
9823 */
9824static hda_nid_t alc660vd_dac_nids[3] = {
9825 /* front, rear, clfe, rear_surr */
9826 0x02, 0x04, 0x03
9827};
9828
9829static hda_nid_t alc861vd_adc_nids[1] = {
9830 /* ADC0 */
9831 0x09,
9832};
9833
9834/* input MUX */
9835/* FIXME: should be a matrix-type input source selection */
9836static struct hda_input_mux alc861vd_capture_source = {
9837 .num_items = 4,
9838 .items = {
9839 { "Mic", 0x0 },
9840 { "Front Mic", 0x1 },
9841 { "Line", 0x2 },
9842 { "CD", 0x4 },
9843 },
9844};
9845
Kailang Yang272a5272007-05-14 11:00:38 +02009846static struct hda_input_mux alc861vd_dallas_capture_source = {
9847 .num_items = 3,
9848 .items = {
9849 { "Front Mic", 0x0 },
9850 { "ATAPI Mic", 0x1 },
9851 { "Line In", 0x5 },
9852 },
9853};
9854
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009855#define alc861vd_mux_enum_info alc_mux_enum_info
9856#define alc861vd_mux_enum_get alc_mux_enum_get
9857
9858static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9859 struct snd_ctl_elem_value *ucontrol)
9860{
9861 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9862 struct alc_spec *spec = codec->spec;
9863 const struct hda_input_mux *imux = spec->input_mux;
9864 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9865 static hda_nid_t capture_mixers[1] = { 0x22 };
9866 hda_nid_t nid = capture_mixers[adc_idx];
9867 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9868 unsigned int i, idx;
9869
9870 idx = ucontrol->value.enumerated.item[0];
9871 if (idx >= imux->num_items)
9872 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009873 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009874 return 0;
9875 for (i = 0; i < imux->num_items; i++) {
9876 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9877 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9878 v | (imux->items[i].index << 8));
9879 }
9880 *cur_val = idx;
9881 return 1;
9882}
9883
9884/*
9885 * 2ch mode
9886 */
9887static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9888 { 2, NULL }
9889};
9890
9891/*
9892 * 6ch mode
9893 */
9894static struct hda_verb alc861vd_6stack_ch6_init[] = {
9895 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9896 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9897 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9898 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9899 { } /* end */
9900};
9901
9902/*
9903 * 8ch mode
9904 */
9905static struct hda_verb alc861vd_6stack_ch8_init[] = {
9906 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9907 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9908 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9909 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9910 { } /* end */
9911};
9912
9913static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9914 { 6, alc861vd_6stack_ch6_init },
9915 { 8, alc861vd_6stack_ch8_init },
9916};
9917
9918static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9919 {
9920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9921 .name = "Channel Mode",
9922 .info = alc_ch_mode_info,
9923 .get = alc_ch_mode_get,
9924 .put = alc_ch_mode_put,
9925 },
9926 { } /* end */
9927};
9928
9929static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9930 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9931 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9932
9933 {
9934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9935 /* The multiple "Capture Source" controls confuse alsamixer
9936 * So call somewhat different..
9937 *FIXME: the controls appear in the "playback" view!
9938 */
9939 /* .name = "Capture Source", */
9940 .name = "Input Source",
9941 .count = 1,
9942 .info = alc861vd_mux_enum_info,
9943 .get = alc861vd_mux_enum_get,
9944 .put = alc861vd_mux_enum_put,
9945 },
9946 { } /* end */
9947};
9948
9949/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9950 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9951 */
9952static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9953 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9954 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9955
9956 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9957 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9958
9959 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9960 HDA_OUTPUT),
9961 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9962 HDA_OUTPUT),
9963 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9964 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9965
9966 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9967 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9968
9969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9970
9971 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9974
9975 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9976 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9977 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9978
9979 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9980 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9981
9982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9984
9985 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9986 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9987
9988 { } /* end */
9989};
9990
9991static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9992 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9994
9995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9996
9997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10000
10001 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10004
10005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10007
10008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10010
10011 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10012 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10013
10014 { } /* end */
10015};
10016
Kailang Yangbdd148a2007-05-08 15:19:08 +020010017static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10018 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10019 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10020 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10021
10022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10023
10024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10027
10028 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10029 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10030 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10031
10032 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10033 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10034
10035 { } /* end */
10036};
10037
Kailang Yang272a5272007-05-14 11:00:38 +020010038/* Pin assignment: Front=0x14, HP = 0x15,
10039 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10040 */
10041static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10042 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10044 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10045 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10046 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10048 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10049 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10052 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10053 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10054 {
10055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10056 /* .name = "Capture Source", */
10057 .name = "Input Source",
10058 .count = 1,
10059 .info = alc882_mux_enum_info,
10060 .get = alc882_mux_enum_get,
10061 .put = alc882_mux_enum_put,
10062 },
10063 { } /* end */
10064};
10065
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010066/*
10067 * generic initialization of ADC, input mixers and output mixers
10068 */
10069static struct hda_verb alc861vd_volume_init_verbs[] = {
10070 /*
10071 * Unmute ADC0 and set the default input to mic-in
10072 */
10073 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10075
10076 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10077 * the analog-loopback mixer widget
10078 */
10079 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10085
10086 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020010087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010091
10092 /*
10093 * Set up output mixers (0x02 - 0x05)
10094 */
10095 /* set vol=0 to output mixers */
10096 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10097 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10098 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10099 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10100
10101 /* set up input amps for analog loopback */
10102 /* Amp Indices: DAC = 0, mixer = 1 */
10103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10108 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10109 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10110 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10111
10112 { }
10113};
10114
10115/*
10116 * 3-stack pin configuration:
10117 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10118 */
10119static struct hda_verb alc861vd_3stack_init_verbs[] = {
10120 /*
10121 * Set pin mode and muting
10122 */
10123 /* set front pin widgets 0x14 for output */
10124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10126 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10127
10128 /* Mic (rear) pin: input vref at 80% */
10129 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10131 /* Front Mic pin: input vref at 80% */
10132 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10134 /* Line In pin: input */
10135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10137 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10140 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10141 /* CD pin widget for input */
10142 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10143
10144 { }
10145};
10146
10147/*
10148 * 6-stack pin configuration:
10149 */
10150static struct hda_verb alc861vd_6stack_init_verbs[] = {
10151 /*
10152 * Set pin mode and muting
10153 */
10154 /* set front pin widgets 0x14 for output */
10155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10157 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10158
10159 /* Rear Pin: output 1 (0x0d) */
10160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10163 /* CLFE Pin: output 2 (0x0e) */
10164 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10165 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10166 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10167 /* Side Pin: output 3 (0x0f) */
10168 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10169 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10170 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10171
10172 /* Mic (rear) pin: input vref at 80% */
10173 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10174 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10175 /* Front Mic pin: input vref at 80% */
10176 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10177 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10178 /* Line In pin: input */
10179 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10180 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10181 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10183 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10184 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10185 /* CD pin widget for input */
10186 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10187
10188 { }
10189};
10190
Kailang Yangbdd148a2007-05-08 15:19:08 +020010191static struct hda_verb alc861vd_eapd_verbs[] = {
10192 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10193 { }
10194};
10195
10196static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10200 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10201 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10202 {}
10203};
10204
10205/* toggle speaker-output according to the hp-jack state */
10206static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10207{
10208 unsigned int present;
10209 unsigned char bits;
10210
10211 present = snd_hda_codec_read(codec, 0x1b, 0,
10212 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10213 bits = present ? 0x80 : 0;
10214 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10215 0x80, bits);
10216 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10217 0x80, bits);
10218}
10219
10220static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10221{
10222 unsigned int present;
10223 unsigned char bits;
10224
10225 present = snd_hda_codec_read(codec, 0x18, 0,
10226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10227 bits = present ? 0x80 : 0;
10228 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10229 0x80, bits);
10230 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10231 0x80, bits);
10232}
10233
10234static void alc861vd_lenovo_automute(struct hda_codec *codec)
10235{
10236 alc861vd_lenovo_hp_automute(codec);
10237 alc861vd_lenovo_mic_automute(codec);
10238}
10239
10240static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10241 unsigned int res)
10242{
10243 switch (res >> 26) {
10244 case ALC880_HP_EVENT:
10245 alc861vd_lenovo_hp_automute(codec);
10246 break;
10247 case ALC880_MIC_EVENT:
10248 alc861vd_lenovo_mic_automute(codec);
10249 break;
10250 }
10251}
10252
Kailang Yang272a5272007-05-14 11:00:38 +020010253static struct hda_verb alc861vd_dallas_verbs[] = {
10254 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10256 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10257 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10258
10259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10267
10268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10276
10277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10279 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10280 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10284 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10285
10286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10290
10291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10292 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10294
10295 { } /* end */
10296};
10297
10298/* toggle speaker-output according to the hp-jack state */
10299static void alc861vd_dallas_automute(struct hda_codec *codec)
10300{
10301 unsigned int present;
10302
10303 present = snd_hda_codec_read(codec, 0x15, 0,
10304 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10305 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10306 0x80, present ? 0x80 : 0);
10307 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10308 0x80, present ? 0x80 : 0);
10309}
10310
10311static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10312{
10313 if ((res >> 26) == ALC880_HP_EVENT)
10314 alc861vd_dallas_automute(codec);
10315}
10316
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010317/* pcm configuration: identiacal with ALC880 */
10318#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10319#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10320#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10321#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10322
10323/*
10324 * configuration and preset
10325 */
10326static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10327 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +020010328 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010329 [ALC861VD_3ST] = "3stack",
10330 [ALC861VD_3ST_DIG] = "3stack-digout",
10331 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010332 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010333 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010334 [ALC861VD_AUTO] = "auto",
10335};
10336
10337static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010338 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010340 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010341 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10342 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10343
Kailang Yang272a5272007-05-14 11:00:38 +020010344 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10345 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010346 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10347 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010348 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010349 {}
10350};
10351
10352static struct alc_config_preset alc861vd_presets[] = {
10353 [ALC660VD_3ST] = {
10354 .mixers = { alc861vd_3st_mixer },
10355 .init_verbs = { alc861vd_volume_init_verbs,
10356 alc861vd_3stack_init_verbs },
10357 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10358 .dac_nids = alc660vd_dac_nids,
10359 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10360 .adc_nids = alc861vd_adc_nids,
10361 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10362 .channel_mode = alc861vd_3stack_2ch_modes,
10363 .input_mux = &alc861vd_capture_source,
10364 },
Mike Crash6963f842007-06-25 12:12:51 +020010365 [ALC660VD_3ST_DIG] = {
10366 .mixers = { alc861vd_3st_mixer },
10367 .init_verbs = { alc861vd_volume_init_verbs,
10368 alc861vd_3stack_init_verbs },
10369 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10370 .dac_nids = alc660vd_dac_nids,
10371 .dig_out_nid = ALC861VD_DIGOUT_NID,
10372 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10373 .adc_nids = alc861vd_adc_nids,
10374 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10375 .channel_mode = alc861vd_3stack_2ch_modes,
10376 .input_mux = &alc861vd_capture_source,
10377 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010378 [ALC861VD_3ST] = {
10379 .mixers = { alc861vd_3st_mixer },
10380 .init_verbs = { alc861vd_volume_init_verbs,
10381 alc861vd_3stack_init_verbs },
10382 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10383 .dac_nids = alc861vd_dac_nids,
10384 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10385 .channel_mode = alc861vd_3stack_2ch_modes,
10386 .input_mux = &alc861vd_capture_source,
10387 },
10388 [ALC861VD_3ST_DIG] = {
10389 .mixers = { alc861vd_3st_mixer },
10390 .init_verbs = { alc861vd_volume_init_verbs,
10391 alc861vd_3stack_init_verbs },
10392 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10393 .dac_nids = alc861vd_dac_nids,
10394 .dig_out_nid = ALC861VD_DIGOUT_NID,
10395 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10396 .channel_mode = alc861vd_3stack_2ch_modes,
10397 .input_mux = &alc861vd_capture_source,
10398 },
10399 [ALC861VD_6ST_DIG] = {
10400 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10401 .init_verbs = { alc861vd_volume_init_verbs,
10402 alc861vd_6stack_init_verbs },
10403 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10404 .dac_nids = alc861vd_dac_nids,
10405 .dig_out_nid = ALC861VD_DIGOUT_NID,
10406 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10407 .channel_mode = alc861vd_6stack_modes,
10408 .input_mux = &alc861vd_capture_source,
10409 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010410 [ALC861VD_LENOVO] = {
10411 .mixers = { alc861vd_lenovo_mixer },
10412 .init_verbs = { alc861vd_volume_init_verbs,
10413 alc861vd_3stack_init_verbs,
10414 alc861vd_eapd_verbs,
10415 alc861vd_lenovo_unsol_verbs },
10416 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10417 .dac_nids = alc660vd_dac_nids,
10418 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10419 .adc_nids = alc861vd_adc_nids,
10420 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10421 .channel_mode = alc861vd_3stack_2ch_modes,
10422 .input_mux = &alc861vd_capture_source,
10423 .unsol_event = alc861vd_lenovo_unsol_event,
10424 .init_hook = alc861vd_lenovo_automute,
10425 },
Kailang Yang272a5272007-05-14 11:00:38 +020010426 [ALC861VD_DALLAS] = {
10427 .mixers = { alc861vd_dallas_mixer },
10428 .init_verbs = { alc861vd_dallas_verbs },
10429 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10430 .dac_nids = alc861vd_dac_nids,
10431 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10432 .adc_nids = alc861vd_adc_nids,
10433 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10434 .channel_mode = alc861vd_3stack_2ch_modes,
10435 .input_mux = &alc861vd_dallas_capture_source,
10436 .unsol_event = alc861vd_dallas_unsol_event,
10437 .init_hook = alc861vd_dallas_automute,
10438 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010439};
10440
10441/*
10442 * BIOS auto configuration
10443 */
10444static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10445 hda_nid_t nid, int pin_type, int dac_idx)
10446{
10447 /* set as output */
10448 snd_hda_codec_write(codec, nid, 0,
10449 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10450 snd_hda_codec_write(codec, nid, 0,
10451 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10452}
10453
10454static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10455{
10456 struct alc_spec *spec = codec->spec;
10457 int i;
10458
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010459 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010460 for (i = 0; i <= HDA_SIDE; i++) {
10461 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010462 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010463 if (nid)
10464 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010465 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010466 }
10467}
10468
10469
10470static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10471{
10472 struct alc_spec *spec = codec->spec;
10473 hda_nid_t pin;
10474
10475 pin = spec->autocfg.hp_pins[0];
10476 if (pin) /* connect to front and use dac 0 */
10477 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10478}
10479
10480#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10481#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10482
10483static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10484{
10485 struct alc_spec *spec = codec->spec;
10486 int i;
10487
10488 for (i = 0; i < AUTO_PIN_LAST; i++) {
10489 hda_nid_t nid = spec->autocfg.input_pins[i];
10490 if (alc861vd_is_input_pin(nid)) {
10491 snd_hda_codec_write(codec, nid, 0,
10492 AC_VERB_SET_PIN_WIDGET_CONTROL,
10493 i <= AUTO_PIN_FRONT_MIC ?
10494 PIN_VREF80 : PIN_IN);
10495 if (nid != ALC861VD_PIN_CD_NID)
10496 snd_hda_codec_write(codec, nid, 0,
10497 AC_VERB_SET_AMP_GAIN_MUTE,
10498 AMP_OUT_MUTE);
10499 }
10500 }
10501}
10502
10503#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10504#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10505
10506/* add playback controls from the parsed DAC table */
10507/* Based on ALC880 version. But ALC861VD has separate,
10508 * different NIDs for mute/unmute switch and volume control */
10509static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10510 const struct auto_pin_cfg *cfg)
10511{
10512 char name[32];
10513 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10514 hda_nid_t nid_v, nid_s;
10515 int i, err;
10516
10517 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010518 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010519 continue;
10520 nid_v = alc861vd_idx_to_mixer_vol(
10521 alc880_dac_to_idx(
10522 spec->multiout.dac_nids[i]));
10523 nid_s = alc861vd_idx_to_mixer_switch(
10524 alc880_dac_to_idx(
10525 spec->multiout.dac_nids[i]));
10526
10527 if (i == 2) {
10528 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010529 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10530 "Center Playback Volume",
10531 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10532 HDA_OUTPUT));
10533 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010534 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010535 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10536 "LFE Playback Volume",
10537 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10538 HDA_OUTPUT));
10539 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010540 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010541 err = add_control(spec, ALC_CTL_BIND_MUTE,
10542 "Center Playback Switch",
10543 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10544 HDA_INPUT));
10545 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010547 err = add_control(spec, ALC_CTL_BIND_MUTE,
10548 "LFE Playback Switch",
10549 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10550 HDA_INPUT));
10551 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010552 return err;
10553 } else {
10554 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010555 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10556 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10557 HDA_OUTPUT));
10558 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010559 return err;
10560 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010561 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010562 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010563 HDA_INPUT));
10564 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010565 return err;
10566 }
10567 }
10568 return 0;
10569}
10570
10571/* add playback controls for speaker and HP outputs */
10572/* Based on ALC880 version. But ALC861VD has separate,
10573 * different NIDs for mute/unmute switch and volume control */
10574static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10575 hda_nid_t pin, const char *pfx)
10576{
10577 hda_nid_t nid_v, nid_s;
10578 int err;
10579 char name[32];
10580
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010581 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010582 return 0;
10583
10584 if (alc880_is_fixed_pin(pin)) {
10585 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10586 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010587 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010588 spec->multiout.hp_nid = nid_v;
10589 else
10590 spec->multiout.extra_out_nid[0] = nid_v;
10591 /* control HP volume/switch on the output mixer amp */
10592 nid_v = alc861vd_idx_to_mixer_vol(
10593 alc880_fixed_pin_idx(pin));
10594 nid_s = alc861vd_idx_to_mixer_switch(
10595 alc880_fixed_pin_idx(pin));
10596
10597 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010598 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10599 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10600 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010601 return err;
10602 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010603 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10604 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10605 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010606 return err;
10607 } else if (alc880_is_multi_pin(pin)) {
10608 /* set manual connection */
10609 /* we have only a switch on HP-out PIN */
10610 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010611 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10612 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10613 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010614 return err;
10615 }
10616 return 0;
10617}
10618
10619/* parse the BIOS configuration and set up the alc_spec
10620 * return 1 if successful, 0 if the proper config is not found,
10621 * or a negative error code
10622 * Based on ALC880 version - had to change it to override
10623 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10624static int alc861vd_parse_auto_config(struct hda_codec *codec)
10625{
10626 struct alc_spec *spec = codec->spec;
10627 int err;
10628 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10629
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010630 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10631 alc861vd_ignore);
10632 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010634 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010635 return 0; /* can't find valid BIOS pin config */
10636
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010637 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10638 if (err < 0)
10639 return err;
10640 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10641 if (err < 0)
10642 return err;
10643 err = alc861vd_auto_create_extra_out(spec,
10644 spec->autocfg.speaker_pins[0],
10645 "Speaker");
10646 if (err < 0)
10647 return err;
10648 err = alc861vd_auto_create_extra_out(spec,
10649 spec->autocfg.hp_pins[0],
10650 "Headphone");
10651 if (err < 0)
10652 return err;
10653 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10654 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010655 return err;
10656
10657 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10658
10659 if (spec->autocfg.dig_out_pin)
10660 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10661
10662 if (spec->kctl_alloc)
10663 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10664
10665 spec->init_verbs[spec->num_init_verbs++]
10666 = alc861vd_volume_init_verbs;
10667
10668 spec->num_mux_defs = 1;
10669 spec->input_mux = &spec->private_imux;
10670
10671 return 1;
10672}
10673
10674/* additional initialization for auto-configuration model */
10675static void alc861vd_auto_init(struct hda_codec *codec)
10676{
10677 alc861vd_auto_init_multi_out(codec);
10678 alc861vd_auto_init_hp_out(codec);
10679 alc861vd_auto_init_analog_input(codec);
10680}
10681
10682static int patch_alc861vd(struct hda_codec *codec)
10683{
10684 struct alc_spec *spec;
10685 int err, board_config;
10686
10687 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10688 if (spec == NULL)
10689 return -ENOMEM;
10690
10691 codec->spec = spec;
10692
10693 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10694 alc861vd_models,
10695 alc861vd_cfg_tbl);
10696
10697 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10698 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10699 "ALC861VD, trying auto-probe from BIOS...\n");
10700 board_config = ALC861VD_AUTO;
10701 }
10702
10703 if (board_config == ALC861VD_AUTO) {
10704 /* automatic parse from the BIOS config */
10705 err = alc861vd_parse_auto_config(codec);
10706 if (err < 0) {
10707 alc_free(codec);
10708 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010709 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010710 printk(KERN_INFO
10711 "hda_codec: Cannot set up configuration "
10712 "from BIOS. Using base mode...\n");
10713 board_config = ALC861VD_3ST;
10714 }
10715 }
10716
10717 if (board_config != ALC861VD_AUTO)
10718 setup_preset(spec, &alc861vd_presets[board_config]);
10719
10720 spec->stream_name_analog = "ALC861VD Analog";
10721 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10722 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10723
10724 spec->stream_name_digital = "ALC861VD Digital";
10725 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10726 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10727
10728 spec->adc_nids = alc861vd_adc_nids;
10729 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10730
10731 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10732 spec->num_mixers++;
10733
10734 codec->patch_ops = alc_patch_ops;
10735
10736 if (board_config == ALC861VD_AUTO)
10737 spec->init_hook = alc861vd_auto_init;
10738
10739 return 0;
10740}
10741
10742/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010743 * ALC662 support
10744 *
10745 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10746 * configuration. Each pin widget can choose any input DACs and a mixer.
10747 * Each ADC is connected from a mixer of all inputs. This makes possible
10748 * 6-channel independent captures.
10749 *
10750 * In addition, an independent DAC for the multi-playback (not used in this
10751 * driver yet).
10752 */
10753#define ALC662_DIGOUT_NID 0x06
10754#define ALC662_DIGIN_NID 0x0a
10755
10756static hda_nid_t alc662_dac_nids[4] = {
10757 /* front, rear, clfe, rear_surr */
10758 0x02, 0x03, 0x04
10759};
10760
10761static hda_nid_t alc662_adc_nids[1] = {
10762 /* ADC1-2 */
10763 0x09,
10764};
10765/* input MUX */
10766/* FIXME: should be a matrix-type input source selection */
10767
10768static struct hda_input_mux alc662_capture_source = {
10769 .num_items = 4,
10770 .items = {
10771 { "Mic", 0x0 },
10772 { "Front Mic", 0x1 },
10773 { "Line", 0x2 },
10774 { "CD", 0x4 },
10775 },
10776};
10777
10778static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10779 .num_items = 2,
10780 .items = {
10781 { "Mic", 0x1 },
10782 { "Line", 0x2 },
10783 },
10784};
10785#define alc662_mux_enum_info alc_mux_enum_info
10786#define alc662_mux_enum_get alc_mux_enum_get
10787
10788static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10789 struct snd_ctl_elem_value *ucontrol)
10790{
10791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10792 struct alc_spec *spec = codec->spec;
10793 const struct hda_input_mux *imux = spec->input_mux;
10794 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10795 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10796 hda_nid_t nid = capture_mixers[adc_idx];
10797 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10798 unsigned int i, idx;
10799
10800 idx = ucontrol->value.enumerated.item[0];
10801 if (idx >= imux->num_items)
10802 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010803 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010804 return 0;
10805 for (i = 0; i < imux->num_items; i++) {
10806 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10807 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10808 v | (imux->items[i].index << 8));
10809 }
10810 *cur_val = idx;
10811 return 1;
10812}
10813/*
10814 * 2ch mode
10815 */
10816static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10817 { 2, NULL }
10818};
10819
10820/*
10821 * 2ch mode
10822 */
10823static struct hda_verb alc662_3ST_ch2_init[] = {
10824 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10825 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10828 { } /* end */
10829};
10830
10831/*
10832 * 6ch mode
10833 */
10834static struct hda_verb alc662_3ST_ch6_init[] = {
10835 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10836 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10837 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10840 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10841 { } /* end */
10842};
10843
10844static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10845 { 2, alc662_3ST_ch2_init },
10846 { 6, alc662_3ST_ch6_init },
10847};
10848
10849/*
10850 * 2ch mode
10851 */
10852static struct hda_verb alc662_sixstack_ch6_init[] = {
10853 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10854 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10855 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10856 { } /* end */
10857};
10858
10859/*
10860 * 6ch mode
10861 */
10862static struct hda_verb alc662_sixstack_ch8_init[] = {
10863 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10864 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10865 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10866 { } /* end */
10867};
10868
10869static struct hda_channel_mode alc662_5stack_modes[2] = {
10870 { 2, alc662_sixstack_ch6_init },
10871 { 6, alc662_sixstack_ch8_init },
10872};
10873
10874/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10875 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10876 */
10877
10878static struct snd_kcontrol_new alc662_base_mixer[] = {
10879 /* output mixer control */
10880 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10881 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10883 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10889
10890 /*Input mixer control */
10891 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10892 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10893 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10894 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10895 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10896 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10897 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10899
10900 /* Capture mixer control */
10901 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10902 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10903 {
10904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10905 .name = "Capture Source",
10906 .count = 1,
10907 .info = alc_mux_enum_info,
10908 .get = alc_mux_enum_get,
10909 .put = alc_mux_enum_put,
10910 },
10911 { } /* end */
10912};
10913
10914static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10915 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10916 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10918 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10919 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10926 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10927 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10928 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10929 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10930 {
10931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10932 /* .name = "Capture Source", */
10933 .name = "Input Source",
10934 .count = 1,
10935 .info = alc662_mux_enum_info,
10936 .get = alc662_mux_enum_get,
10937 .put = alc662_mux_enum_put,
10938 },
10939 { } /* end */
10940};
10941
10942static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10944 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10946 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10960 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10961 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10962 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10963 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10964 {
10965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10966 /* .name = "Capture Source", */
10967 .name = "Input Source",
10968 .count = 1,
10969 .info = alc662_mux_enum_info,
10970 .get = alc662_mux_enum_get,
10971 .put = alc662_mux_enum_put,
10972 },
10973 { } /* end */
10974};
10975
10976static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10977 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10978 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10979 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10980 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10986 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10987 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10988 {
10989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10990 /* .name = "Capture Source", */
10991 .name = "Input Source",
10992 .count = 1,
10993 .info = alc662_mux_enum_info,
10994 .get = alc662_mux_enum_get,
10995 .put = alc662_mux_enum_put,
10996 },
10997 { } /* end */
10998};
10999
11000static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11001 {
11002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11003 .name = "Channel Mode",
11004 .info = alc_ch_mode_info,
11005 .get = alc_ch_mode_get,
11006 .put = alc_ch_mode_put,
11007 },
11008 { } /* end */
11009};
11010
11011static struct hda_verb alc662_init_verbs[] = {
11012 /* ADC: mute amp left and right */
11013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11014 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11015 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11016
11017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11022
11023 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11025 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11026 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11027 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11029
11030 /* Front Pin: output 0 (0x0c) */
11031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11033
11034 /* Rear Pin: output 1 (0x0d) */
11035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11037
11038 /* CLFE Pin: output 2 (0x0e) */
11039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11041
11042 /* Mic (rear) pin: input vref at 80% */
11043 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11045 /* Front Mic pin: input vref at 80% */
11046 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11048 /* Line In pin: input */
11049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11051 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11054 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11055 /* CD pin widget for input */
11056 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11057
11058 /* FIXME: use matrix-type input source selection */
11059 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11060 /* Input mixer */
11061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11065 { }
11066};
11067
11068static struct hda_verb alc662_sue_init_verbs[] = {
11069 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11070 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11071 {}
11072};
11073
11074/*
11075 * generic initialization of ADC, input mixers and output mixers
11076 */
11077static struct hda_verb alc662_auto_init_verbs[] = {
11078 /*
11079 * Unmute ADC and set the default input to mic-in
11080 */
11081 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11083
11084 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11085 * mixer widget
11086 * Note: PASD motherboards uses the Line In 2 as the input for front
11087 * panel mic (mic 2)
11088 */
11089 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11095
11096 /*
11097 * Set up output mixers (0x0c - 0x0f)
11098 */
11099 /* set vol=0 to output mixers */
11100 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11101 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11103
11104 /* set up input amps for analog loopback */
11105 /* Amp Indices: DAC = 0, mixer = 1 */
11106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11107 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11108 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11109 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11110 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11111 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11112
11113
11114 /* FIXME: use matrix-type input source selection */
11115 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11116 /* Input mixer */
11117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11120 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
11121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11122
11123 { }
11124};
11125
11126/* capture mixer elements */
11127static struct snd_kcontrol_new alc662_capture_mixer[] = {
11128 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11129 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11130 {
11131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11132 /* The multiple "Capture Source" controls confuse alsamixer
11133 * So call somewhat different..
11134 * FIXME: the controls appear in the "playback" view!
11135 */
11136 /* .name = "Capture Source", */
11137 .name = "Input Source",
11138 .count = 1,
11139 .info = alc882_mux_enum_info,
11140 .get = alc882_mux_enum_get,
11141 .put = alc882_mux_enum_put,
11142 },
11143 { } /* end */
11144};
11145
11146static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11147{
11148 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011149 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011150
11151 present = snd_hda_codec_read(codec, 0x14, 0,
11152 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011153 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011154 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011155 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011156 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011157 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011158}
11159
11160static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11161{
11162 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011163 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011164
11165 present = snd_hda_codec_read(codec, 0x1b, 0,
11166 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011167 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011168 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011169 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011170 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011171 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011172 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011173 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011174 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011175 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011176}
11177
11178static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11179 unsigned int res)
11180{
11181 if ((res >> 26) == ALC880_HP_EVENT)
11182 alc662_lenovo_101e_all_automute(codec);
11183 if ((res >> 26) == ALC880_FRONT_EVENT)
11184 alc662_lenovo_101e_ispeaker_automute(codec);
11185}
11186
11187
11188/* pcm configuration: identiacal with ALC880 */
11189#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11190#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11191#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11192#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11193
11194/*
11195 * configuration and preset
11196 */
11197static const char *alc662_models[ALC662_MODEL_LAST] = {
11198 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11199 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11200 [ALC662_3ST_6ch] = "3stack-6ch",
11201 [ALC662_5ST_DIG] = "6stack-dig",
11202 [ALC662_LENOVO_101E] = "lenovo-101e",
11203 [ALC662_AUTO] = "auto",
11204};
11205
11206static struct snd_pci_quirk alc662_cfg_tbl[] = {
11207 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11208 {}
11209};
11210
11211static struct alc_config_preset alc662_presets[] = {
11212 [ALC662_3ST_2ch_DIG] = {
11213 .mixers = { alc662_3ST_2ch_mixer },
11214 .init_verbs = { alc662_init_verbs },
11215 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11216 .dac_nids = alc662_dac_nids,
11217 .dig_out_nid = ALC662_DIGOUT_NID,
11218 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11219 .adc_nids = alc662_adc_nids,
11220 .dig_in_nid = ALC662_DIGIN_NID,
11221 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11222 .channel_mode = alc662_3ST_2ch_modes,
11223 .input_mux = &alc662_capture_source,
11224 },
11225 [ALC662_3ST_6ch_DIG] = {
11226 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11227 .init_verbs = { alc662_init_verbs },
11228 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11229 .dac_nids = alc662_dac_nids,
11230 .dig_out_nid = ALC662_DIGOUT_NID,
11231 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11232 .adc_nids = alc662_adc_nids,
11233 .dig_in_nid = ALC662_DIGIN_NID,
11234 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11235 .channel_mode = alc662_3ST_6ch_modes,
11236 .need_dac_fix = 1,
11237 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011238 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011239 [ALC662_3ST_6ch] = {
11240 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11241 .init_verbs = { alc662_init_verbs },
11242 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11243 .dac_nids = alc662_dac_nids,
11244 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11245 .adc_nids = alc662_adc_nids,
11246 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11247 .channel_mode = alc662_3ST_6ch_modes,
11248 .need_dac_fix = 1,
11249 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011250 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011251 [ALC662_5ST_DIG] = {
11252 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11253 .init_verbs = { alc662_init_verbs },
11254 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11255 .dac_nids = alc662_dac_nids,
11256 .dig_out_nid = ALC662_DIGOUT_NID,
11257 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11258 .adc_nids = alc662_adc_nids,
11259 .dig_in_nid = ALC662_DIGIN_NID,
11260 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11261 .channel_mode = alc662_5stack_modes,
11262 .input_mux = &alc662_capture_source,
11263 },
11264 [ALC662_LENOVO_101E] = {
11265 .mixers = { alc662_lenovo_101e_mixer },
11266 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11267 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11268 .dac_nids = alc662_dac_nids,
11269 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11270 .adc_nids = alc662_adc_nids,
11271 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11272 .channel_mode = alc662_3ST_2ch_modes,
11273 .input_mux = &alc662_lenovo_101e_capture_source,
11274 .unsol_event = alc662_lenovo_101e_unsol_event,
11275 .init_hook = alc662_lenovo_101e_all_automute,
11276 },
11277
11278};
11279
11280
11281/*
11282 * BIOS auto configuration
11283 */
11284
11285/* add playback controls from the parsed DAC table */
11286static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11287 const struct auto_pin_cfg *cfg)
11288{
11289 char name[32];
11290 static const char *chname[4] = {
11291 "Front", "Surround", NULL /*CLFE*/, "Side"
11292 };
11293 hda_nid_t nid;
11294 int i, err;
11295
11296 for (i = 0; i < cfg->line_outs; i++) {
11297 if (!spec->multiout.dac_nids[i])
11298 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011299 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011300 if (i == 2) {
11301 /* Center/LFE */
11302 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11303 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011304 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11305 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011306 if (err < 0)
11307 return err;
11308 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11309 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011310 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11311 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011312 if (err < 0)
11313 return err;
11314 err = add_control(spec, ALC_CTL_BIND_MUTE,
11315 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011316 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11317 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011318 if (err < 0)
11319 return err;
11320 err = add_control(spec, ALC_CTL_BIND_MUTE,
11321 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011322 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11323 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011324 if (err < 0)
11325 return err;
11326 } else {
11327 sprintf(name, "%s Playback Volume", chname[i]);
11328 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011329 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11330 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011331 if (err < 0)
11332 return err;
11333 sprintf(name, "%s Playback Switch", chname[i]);
11334 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011335 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11336 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011337 if (err < 0)
11338 return err;
11339 }
11340 }
11341 return 0;
11342}
11343
11344/* add playback controls for speaker and HP outputs */
11345static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11346 const char *pfx)
11347{
11348 hda_nid_t nid;
11349 int err;
11350 char name[32];
11351
11352 if (!pin)
11353 return 0;
11354
11355 if (alc880_is_fixed_pin(pin)) {
11356 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11357 /* printk("DAC nid=%x\n",nid); */
11358 /* specify the DAC as the extra output */
11359 if (!spec->multiout.hp_nid)
11360 spec->multiout.hp_nid = nid;
11361 else
11362 spec->multiout.extra_out_nid[0] = nid;
11363 /* control HP volume/switch on the output mixer amp */
11364 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11365 sprintf(name, "%s Playback Volume", pfx);
11366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11367 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11368 if (err < 0)
11369 return err;
11370 sprintf(name, "%s Playback Switch", pfx);
11371 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11372 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11373 if (err < 0)
11374 return err;
11375 } else if (alc880_is_multi_pin(pin)) {
11376 /* set manual connection */
11377 /* we have only a switch on HP-out PIN */
11378 sprintf(name, "%s Playback Switch", pfx);
11379 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11380 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11381 if (err < 0)
11382 return err;
11383 }
11384 return 0;
11385}
11386
11387/* create playback/capture controls for input pins */
11388static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11389 const struct auto_pin_cfg *cfg)
11390{
11391 struct hda_input_mux *imux = &spec->private_imux;
11392 int i, err, idx;
11393
11394 for (i = 0; i < AUTO_PIN_LAST; i++) {
11395 if (alc880_is_input_pin(cfg->input_pins[i])) {
11396 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11397 err = new_analog_input(spec, cfg->input_pins[i],
11398 auto_pin_cfg_labels[i],
11399 idx, 0x0b);
11400 if (err < 0)
11401 return err;
11402 imux->items[imux->num_items].label =
11403 auto_pin_cfg_labels[i];
11404 imux->items[imux->num_items].index =
11405 alc880_input_pin_idx(cfg->input_pins[i]);
11406 imux->num_items++;
11407 }
11408 }
11409 return 0;
11410}
11411
11412static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11413 hda_nid_t nid, int pin_type,
11414 int dac_idx)
11415{
11416 /* set as output */
11417 snd_hda_codec_write(codec, nid, 0,
11418 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11419 snd_hda_codec_write(codec, nid, 0,
11420 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11421 /* need the manual connection? */
11422 if (alc880_is_multi_pin(nid)) {
11423 struct alc_spec *spec = codec->spec;
11424 int idx = alc880_multi_pin_idx(nid);
11425 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11426 AC_VERB_SET_CONNECT_SEL,
11427 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11428 }
11429}
11430
11431static void alc662_auto_init_multi_out(struct hda_codec *codec)
11432{
11433 struct alc_spec *spec = codec->spec;
11434 int i;
11435
11436 for (i = 0; i <= HDA_SIDE; i++) {
11437 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011438 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011439 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011440 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011441 i);
11442 }
11443}
11444
11445static void alc662_auto_init_hp_out(struct hda_codec *codec)
11446{
11447 struct alc_spec *spec = codec->spec;
11448 hda_nid_t pin;
11449
11450 pin = spec->autocfg.hp_pins[0];
11451 if (pin) /* connect to front */
11452 /* use dac 0 */
11453 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11454}
11455
11456#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11457#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11458
11459static void alc662_auto_init_analog_input(struct hda_codec *codec)
11460{
11461 struct alc_spec *spec = codec->spec;
11462 int i;
11463
11464 for (i = 0; i < AUTO_PIN_LAST; i++) {
11465 hda_nid_t nid = spec->autocfg.input_pins[i];
11466 if (alc662_is_input_pin(nid)) {
11467 snd_hda_codec_write(codec, nid, 0,
11468 AC_VERB_SET_PIN_WIDGET_CONTROL,
11469 (i <= AUTO_PIN_FRONT_MIC ?
11470 PIN_VREF80 : PIN_IN));
11471 if (nid != ALC662_PIN_CD_NID)
11472 snd_hda_codec_write(codec, nid, 0,
11473 AC_VERB_SET_AMP_GAIN_MUTE,
11474 AMP_OUT_MUTE);
11475 }
11476 }
11477}
11478
11479static int alc662_parse_auto_config(struct hda_codec *codec)
11480{
11481 struct alc_spec *spec = codec->spec;
11482 int err;
11483 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11484
11485 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11486 alc662_ignore);
11487 if (err < 0)
11488 return err;
11489 if (!spec->autocfg.line_outs)
11490 return 0; /* can't find valid BIOS pin config */
11491
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011492 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11493 if (err < 0)
11494 return err;
11495 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11496 if (err < 0)
11497 return err;
11498 err = alc662_auto_create_extra_out(spec,
11499 spec->autocfg.speaker_pins[0],
11500 "Speaker");
11501 if (err < 0)
11502 return err;
11503 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11504 "Headphone");
11505 if (err < 0)
11506 return err;
11507 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11508 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011509 return err;
11510
11511 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11512
11513 if (spec->autocfg.dig_out_pin)
11514 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11515
11516 if (spec->kctl_alloc)
11517 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11518
11519 spec->num_mux_defs = 1;
11520 spec->input_mux = &spec->private_imux;
11521
Takashi Iwai8c872862007-06-19 12:11:16 +020011522 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011523 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11524 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020011525 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011526}
11527
11528/* additional initialization for auto-configuration model */
11529static void alc662_auto_init(struct hda_codec *codec)
11530{
11531 alc662_auto_init_multi_out(codec);
11532 alc662_auto_init_hp_out(codec);
11533 alc662_auto_init_analog_input(codec);
11534}
11535
11536static int patch_alc662(struct hda_codec *codec)
11537{
11538 struct alc_spec *spec;
11539 int err, board_config;
11540
11541 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11542 if (!spec)
11543 return -ENOMEM;
11544
11545 codec->spec = spec;
11546
11547 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11548 alc662_models,
11549 alc662_cfg_tbl);
11550 if (board_config < 0) {
11551 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11552 "trying auto-probe from BIOS...\n");
11553 board_config = ALC662_AUTO;
11554 }
11555
11556 if (board_config == ALC662_AUTO) {
11557 /* automatic parse from the BIOS config */
11558 err = alc662_parse_auto_config(codec);
11559 if (err < 0) {
11560 alc_free(codec);
11561 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020011562 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011563 printk(KERN_INFO
11564 "hda_codec: Cannot set up configuration "
11565 "from BIOS. Using base mode...\n");
11566 board_config = ALC662_3ST_2ch_DIG;
11567 }
11568 }
11569
11570 if (board_config != ALC662_AUTO)
11571 setup_preset(spec, &alc662_presets[board_config]);
11572
11573 spec->stream_name_analog = "ALC662 Analog";
11574 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11575 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11576
11577 spec->stream_name_digital = "ALC662 Digital";
11578 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11579 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11580
11581 if (!spec->adc_nids && spec->input_mux) {
11582 spec->adc_nids = alc662_adc_nids;
11583 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11584 }
11585
11586 codec->patch_ops = alc_patch_ops;
11587 if (board_config == ALC662_AUTO)
11588 spec->init_hook = alc662_auto_init;
11589
11590 return 0;
11591}
11592
11593/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011594 * patch entries
11595 */
11596struct hda_codec_preset snd_hda_preset_realtek[] = {
11597 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011598 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011599 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011600 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011601 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011602 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11603 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11604 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011605 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11606 .patch = patch_alc883 },
11607 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11608 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011609 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011610 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011611 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011612 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011613 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011614 {} /* terminator */
11615};