blob: 39c08bb670d1472f5dbaafcbfe1d48444daa3bc1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010074 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010076 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020077 ALC260_WILL,
78 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010079#ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020083 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Kailang Yangdf694da2005-12-05 19:42:22 +010086/* ALC262 models */
87enum {
88 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020089 ALC262_HIPPO,
90 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010091 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020092 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010093 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020095 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020096 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020097 ALC262_BENQ_T31,
Kailang Yangdf694da2005-12-05 19:42:22 +010098 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */
100};
101
Kailang Yanga361d842007-06-05 12:30:55 +0200102/* ALC268 models */
103enum {
104 ALC268_3ST,
105 ALC268_AUTO,
106 ALC268_MODEL_LAST /* last tag */
107};
108
Kailang Yangdf694da2005-12-05 19:42:22 +0100109/* ALC861 models */
110enum {
111 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200112 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100113 ALC861_3ST_DIG,
114 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200115 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200116 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200117 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100118 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100119 ALC861_AUTO,
120 ALC861_MODEL_LAST,
121};
122
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100123/* ALC861-VD models */
124enum {
125 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200126 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100127 ALC861VD_3ST,
128 ALC861VD_3ST_DIG,
129 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200130 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200131 ALC861VD_DALLAS,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100132 ALC861VD_AUTO,
133 ALC861VD_MODEL_LAST,
134};
135
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200136/* ALC662 models */
137enum {
138 ALC662_3ST_2ch_DIG,
139 ALC662_3ST_6ch_DIG,
140 ALC662_3ST_6ch,
141 ALC662_5ST_DIG,
142 ALC662_LENOVO_101E,
143 ALC662_AUTO,
144 ALC662_MODEL_LAST,
145};
146
Kailang Yangdf694da2005-12-05 19:42:22 +0100147/* ALC882 models */
148enum {
149 ALC882_3ST_DIG,
150 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200151 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200152 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200153 ALC882_TARGA,
154 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100155 ALC885_MACPRO,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200156 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200157 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100158 ALC882_MODEL_LAST,
159};
160
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200161/* ALC883 models */
162enum {
163 ALC883_3ST_2ch_DIG,
164 ALC883_3ST_6ch_DIG,
165 ALC883_3ST_6ch,
166 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200167 ALC883_TARGA_DIG,
168 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200169 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200170 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200171 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200172 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100173 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200174 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200175 ALC883_LENOVO_NB0763,
176 ALC888_LENOVO_MS7195_DIG,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200177 ALC888_6ST_HP,
178 ALC888_3ST_HP,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200179 ALC883_AUTO,
180 ALC883_MODEL_LAST,
181};
182
Kailang Yangdf694da2005-12-05 19:42:22 +0100183/* for GPIO Poll */
184#define GPIO_MASK 0x03
185
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186struct alc_spec {
187 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100188 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 unsigned int num_mixers;
190
Kailang Yangdf694da2005-12-05 19:42:22 +0100191 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200192 * don't forget NULL
193 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200194 */
195 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
Takashi Iwai16ded522005-06-10 19:58:24 +0200197 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 struct hda_pcm_stream *stream_analog_playback;
199 struct hda_pcm_stream *stream_analog_capture;
200
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200201 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 struct hda_pcm_stream *stream_digital_playback;
203 struct hda_pcm_stream *stream_digital_capture;
204
205 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200206 struct hda_multi_out multiout; /* playback set-up
207 * max_channels, dacs must be set
208 * dig_out_nid and hp_nid are optional
209 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
211 /* capture */
212 unsigned int num_adc_nids;
213 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200214 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
216 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200217 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 const struct hda_input_mux *input_mux;
219 unsigned int cur_mux[3];
220
221 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100222 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200224 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100227 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200228
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200229 /* dynamic controls, init_verbs and input_mux */
230 struct auto_pin_cfg autocfg;
231 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100232 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200233 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100234 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100235
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100236 /* hooks */
237 void (*init_hook)(struct hda_codec *codec);
238 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
239
Takashi Iwai834be882006-03-01 14:16:17 +0100240 /* for pin sensing */
241 unsigned int sense_updated: 1;
242 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100243};
244
245/*
246 * configuration template - to be copied to the spec instance
247 */
248struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200249 struct snd_kcontrol_new *mixers[5]; /* should be identical size
250 * with spec
251 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100252 const struct hda_verb *init_verbs[5];
253 unsigned int num_dacs;
254 hda_nid_t *dac_nids;
255 hda_nid_t dig_out_nid; /* optional */
256 hda_nid_t hp_nid; /* optional */
257 unsigned int num_adc_nids;
258 hda_nid_t *adc_nids;
259 hda_nid_t dig_in_nid;
260 unsigned int num_channel_mode;
261 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200262 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200263 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100264 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100265 void (*unsol_event)(struct hda_codec *, unsigned int);
266 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267};
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270/*
271 * input MUX handling
272 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200273static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
274 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275{
276 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
277 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200278 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
279 if (mux_idx >= spec->num_mux_defs)
280 mux_idx = 0;
281 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282}
283
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200284static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
285 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286{
287 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
288 struct alc_spec *spec = codec->spec;
289 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
290
291 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
292 return 0;
293}
294
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200295static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
296 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297{
298 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
299 struct alc_spec *spec = codec->spec;
300 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200301 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
302 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200303 spec->adc_nids[adc_idx],
304 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305}
306
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200307
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308/*
309 * channel mode setting
310 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200311static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
312 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313{
314 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
315 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100316 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
317 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318}
319
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200320static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
321 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322{
323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
324 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100325 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200326 spec->num_channel_mode,
327 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328}
329
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200330static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
331 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
334 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200335 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
336 spec->num_channel_mode,
337 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200338 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200339 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
340 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341}
342
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100344 * Control the mode of pin widget settings via the mixer. "pc" is used
345 * instead of "%" to avoid consequences of accidently treating the % as
346 * being part of a format specifier. Maximum allowed length of a value is
347 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100348 *
349 * Note: some retasking pin complexes seem to ignore requests for input
350 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
351 * are requested. Therefore order this list so that this behaviour will not
352 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200353 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
354 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200355 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100357 "Mic 50pc bias", "Mic 80pc bias",
358 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100359};
360static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100361 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100362};
363/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200364 * in the pin being assumed to be exclusively an input or an output pin. In
365 * addition, "input" pins may or may not process the mic bias option
366 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
367 * accept requests for bias as of chip versions up to March 2006) and/or
368 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100369 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200370#define ALC_PIN_DIR_IN 0x00
371#define ALC_PIN_DIR_OUT 0x01
372#define ALC_PIN_DIR_INOUT 0x02
373#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
374#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100375
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200376/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100377 * For each direction the minimum and maximum values are given.
378 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200379static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100380 { 0, 2 }, /* ALC_PIN_DIR_IN */
381 { 3, 4 }, /* ALC_PIN_DIR_OUT */
382 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200383 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
384 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100385};
386#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
387#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
388#define alc_pin_mode_n_items(_dir) \
389 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
390
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200393{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100394 unsigned int item_num = uinfo->value.enumerated.item;
395 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
396
397 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200398 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100399 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
400
401 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
402 item_num = alc_pin_mode_min(dir);
403 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200404 return 0;
405}
406
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200407static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200409{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100410 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
412 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200414 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200415 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
416 AC_VERB_GET_PIN_WIDGET_CONTROL,
417 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200418
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100419 /* Find enumerated value for current pinctl setting */
420 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200421 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100422 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200423 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100424 return 0;
425}
426
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100429{
430 signed int change;
431 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
432 hda_nid_t nid = kcontrol->private_value & 0xffff;
433 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
434 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
436 AC_VERB_GET_PIN_WIDGET_CONTROL,
437 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100438
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200439 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100440 val = alc_pin_mode_min(dir);
441
442 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100443 if (change) {
444 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200445 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100447
448 /* Also enable the retasking pin's input/output as required
449 * for the requested pin mode. Enum values of 2 or less are
450 * input modes.
451 *
452 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200453 * reduces noise slightly (particularly on input) so we'll
454 * do it. However, having both input and output buffers
455 * enabled simultaneously doesn't seem to be problematic if
456 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100457 */
458 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459 snd_hda_codec_write(codec, nid, 0,
460 AC_VERB_SET_AMP_GAIN_MUTE,
461 AMP_OUT_MUTE);
462 snd_hda_codec_write(codec, nid, 0,
463 AC_VERB_SET_AMP_GAIN_MUTE,
464 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100465 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200466 snd_hda_codec_write(codec, nid, 0,
467 AC_VERB_SET_AMP_GAIN_MUTE,
468 AMP_IN_MUTE(0));
469 snd_hda_codec_write(codec, nid, 0,
470 AC_VERB_SET_AMP_GAIN_MUTE,
471 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100472 }
473 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200474 return change;
475}
476
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100477#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200478 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100479 .info = alc_pin_mode_info, \
480 .get = alc_pin_mode_get, \
481 .put = alc_pin_mode_put, \
482 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100483
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100484/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
485 * together using a mask with more than one bit set. This control is
486 * currently used only by the ALC260 test model. At this stage they are not
487 * needed for any "production" models.
488 */
489#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200490#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200491
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200492static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
493 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100494{
495 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
496 hda_nid_t nid = kcontrol->private_value & 0xffff;
497 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
498 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200499 unsigned int val = snd_hda_codec_read(codec, nid, 0,
500 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100501
502 *valp = (val & mask) != 0;
503 return 0;
504}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200505static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100507{
508 signed int change;
509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
510 hda_nid_t nid = kcontrol->private_value & 0xffff;
511 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
512 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200513 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
514 AC_VERB_GET_GPIO_DATA,
515 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100516
517 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200518 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
519 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100520 gpio_data &= ~mask;
521 else
522 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100524
525 return change;
526}
527#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
528 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
529 .info = alc_gpio_data_info, \
530 .get = alc_gpio_data_get, \
531 .put = alc_gpio_data_put, \
532 .private_value = nid | (mask<<16) }
533#endif /* CONFIG_SND_DEBUG */
534
Jonathan Woithe92621f12006-02-28 11:47:47 +0100535/* A switch control to allow the enabling of the digital IO pins on the
536 * ALC260. This is incredibly simplistic; the intention of this control is
537 * to provide something in the test model allowing digital outputs to be
538 * identified if present. If models are found which can utilise these
539 * outputs a more complete mixer control can be devised for those models if
540 * necessary.
541 */
542#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200543#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200544
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200545static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100547{
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 hda_nid_t nid = kcontrol->private_value & 0xffff;
550 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
551 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200552 unsigned int val = snd_hda_codec_read(codec, nid, 0,
553 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100554
555 *valp = (val & mask) != 0;
556 return 0;
557}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100560{
561 signed int change;
562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 hda_nid_t nid = kcontrol->private_value & 0xffff;
564 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
565 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200566 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
567 AC_VERB_GET_DIGI_CONVERT,
568 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100569
570 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100572 if (val==0)
573 ctrl_data &= ~mask;
574 else
575 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
577 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100578
579 return change;
580}
581#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
582 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
583 .info = alc_spdif_ctrl_info, \
584 .get = alc_spdif_ctrl_get, \
585 .put = alc_spdif_ctrl_put, \
586 .private_value = nid | (mask<<16) }
587#endif /* CONFIG_SND_DEBUG */
588
Kailang Yangdf694da2005-12-05 19:42:22 +0100589/*
590 * set up from the preset table
591 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200592static void setup_preset(struct alc_spec *spec,
593 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100594{
595 int i;
596
597 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
598 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
600 i++)
601 spec->init_verbs[spec->num_init_verbs++] =
602 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100603
604 spec->channel_mode = preset->channel_mode;
605 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200606 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100607
608 spec->multiout.max_channels = spec->channel_mode[0].channels;
609
610 spec->multiout.num_dacs = preset->num_dacs;
611 spec->multiout.dac_nids = preset->dac_nids;
612 spec->multiout.dig_out_nid = preset->dig_out_nid;
613 spec->multiout.hp_nid = preset->hp_nid;
614
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200615 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200616 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200617 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100618 spec->input_mux = preset->input_mux;
619
620 spec->num_adc_nids = preset->num_adc_nids;
621 spec->adc_nids = preset->adc_nids;
622 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100623
624 spec->unsol_event = preset->unsol_event;
625 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100626}
627
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200628/* Enable GPIO mask and set output */
629static struct hda_verb alc_gpio1_init_verbs[] = {
630 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
631 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
632 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
633 { }
634};
635
636static struct hda_verb alc_gpio2_init_verbs[] = {
637 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
638 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
639 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
640 { }
641};
642
Kailang Yangbdd148a2007-05-08 15:19:08 +0200643static struct hda_verb alc_gpio3_init_verbs[] = {
644 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
645 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
646 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
647 { }
648};
649
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200650/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
651 * 31 ~ 16 : Manufacture ID
652 * 15 ~ 8 : SKU ID
653 * 7 ~ 0 : Assembly ID
654 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
655 */
656static void alc_subsystem_id(struct hda_codec *codec,
657 unsigned int porta, unsigned int porte,
658 unsigned int portd)
659{
660 unsigned int ass, tmp;
661
662 ass = codec->subsystem_id;
663 if (!(ass & 1))
664 return;
665
666 /* Override */
667 tmp = (ass & 0x38) >> 3; /* external Amp control */
668 switch (tmp) {
669 case 1:
670 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
671 break;
672 case 3:
673 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
674 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200675 case 7:
676 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
677 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200678 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200679 switch (codec->vendor_id) {
680 case 0x10ec0862:
681 case 0x10ec0660:
682 case 0x10ec0662:
683 case 0x10ec0267:
684 case 0x10ec0268:
685 snd_hda_codec_write(codec, 0x14, 0,
686 AC_VERB_SET_EAPD_BTLENABLE, 2);
687 snd_hda_codec_write(codec, 0x15, 0,
688 AC_VERB_SET_EAPD_BTLENABLE, 2);
689 return;
690 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200691 case 6:
692 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
693 hda_nid_t port = 0;
694 tmp = (ass & 0x1800) >> 11;
695 switch (tmp) {
696 case 0: port = porta; break;
697 case 1: port = porte; break;
698 case 2: port = portd; break;
699 }
700 if (port)
701 snd_hda_codec_write(codec, port, 0,
702 AC_VERB_SET_EAPD_BTLENABLE,
703 2);
704 }
705 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
706 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
707 (tmp == 5 ? 0x3040 : 0x3050));
708 break;
709 }
710}
711
Takashi Iwai41e41f12005-06-08 14:48:49 +0200712/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200713 * Fix-up pin default configurations
714 */
715
716struct alc_pincfg {
717 hda_nid_t nid;
718 u32 val;
719};
720
721static void alc_fix_pincfg(struct hda_codec *codec,
722 const struct snd_pci_quirk *quirk,
723 const struct alc_pincfg **pinfix)
724{
725 const struct alc_pincfg *cfg;
726
727 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
728 if (!quirk)
729 return;
730
731 cfg = pinfix[quirk->value];
732 for (; cfg->nid; cfg++) {
733 int i;
734 u32 val = cfg->val;
735 for (i = 0; i < 4; i++) {
736 snd_hda_codec_write(codec, cfg->nid, 0,
737 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
738 val & 0xff);
739 val >>= 8;
740 }
741 }
742}
743
744/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200745 * ALC880 3-stack model
746 *
747 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200748 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
749 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 */
751
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200752static hda_nid_t alc880_dac_nids[4] = {
753 /* front, rear, clfe, rear_surr */
754 0x02, 0x05, 0x04, 0x03
755};
756
757static hda_nid_t alc880_adc_nids[3] = {
758 /* ADC0-2 */
759 0x07, 0x08, 0x09,
760};
761
762/* The datasheet says the node 0x07 is connected from inputs,
763 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100764 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200766static hda_nid_t alc880_adc_nids_alt[2] = {
767 /* ADC1-2 */
768 0x08, 0x09,
769};
770
771#define ALC880_DIGOUT_NID 0x06
772#define ALC880_DIGIN_NID 0x0a
773
774static struct hda_input_mux alc880_capture_source = {
775 .num_items = 4,
776 .items = {
777 { "Mic", 0x0 },
778 { "Front Mic", 0x3 },
779 { "Line", 0x2 },
780 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200782};
783
784/* channel source setting (2/6 channel selection for 3-stack) */
785/* 2ch mode */
786static struct hda_verb alc880_threestack_ch2_init[] = {
787 /* set line-in to input, mute it */
788 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
789 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
790 /* set mic-in to input vref 80%, mute it */
791 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
792 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 { } /* end */
794};
795
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200796/* 6ch mode */
797static struct hda_verb alc880_threestack_ch6_init[] = {
798 /* set line-in to output, unmute it */
799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
801 /* set mic-in to output, unmute it */
802 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
803 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
804 { } /* end */
805};
806
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100807static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200808 { 2, alc880_threestack_ch2_init },
809 { 6, alc880_threestack_ch6_init },
810};
811
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100812static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200813 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100814 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200815 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100816 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200817 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
818 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100819 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
820 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
822 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
823 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
824 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
827 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
828 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
829 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
830 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200832 {
833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
834 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100835 .info = alc_ch_mode_info,
836 .get = alc_ch_mode_get,
837 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200838 },
839 { } /* end */
840};
841
842/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100843static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200844 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
845 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
846 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
847 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
848 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
849 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
850 {
851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
852 /* The multiple "Capture Source" controls confuse alsamixer
853 * So call somewhat different..
854 * FIXME: the controls appear in the "playback" view!
855 */
856 /* .name = "Capture Source", */
857 .name = "Input Source",
858 .count = 3,
859 .info = alc_mux_enum_info,
860 .get = alc_mux_enum_get,
861 .put = alc_mux_enum_put,
862 },
863 { } /* end */
864};
865
866/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100867static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200868 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
869 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
870 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
871 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 {
873 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
874 /* The multiple "Capture Source" controls confuse alsamixer
875 * So call somewhat different..
876 * FIXME: the controls appear in the "playback" view!
877 */
878 /* .name = "Capture Source", */
879 .name = "Input Source",
880 .count = 2,
881 .info = alc_mux_enum_info,
882 .get = alc_mux_enum_get,
883 .put = alc_mux_enum_put,
884 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 { } /* end */
886};
887
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200888
889
890/*
891 * ALC880 5-stack model
892 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200893 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
894 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200895 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
896 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
897 */
898
899/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100900static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200901 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100902 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 { } /* end */
904};
905
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200906/* channel source setting (6/8 channel selection for 5-stack) */
907/* 6ch mode */
908static struct hda_verb alc880_fivestack_ch6_init[] = {
909 /* set line-in to input, mute it */
910 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
911 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200912 { } /* end */
913};
914
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200915/* 8ch mode */
916static struct hda_verb alc880_fivestack_ch8_init[] = {
917 /* set line-in to output, unmute it */
918 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
919 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
920 { } /* end */
921};
922
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100923static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200924 { 6, alc880_fivestack_ch6_init },
925 { 8, alc880_fivestack_ch8_init },
926};
927
928
929/*
930 * ALC880 6-stack model
931 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200932 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
933 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200934 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
935 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
936 */
937
938static hda_nid_t alc880_6st_dac_nids[4] = {
939 /* front, rear, clfe, rear_surr */
940 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200941};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200942
943static struct hda_input_mux alc880_6stack_capture_source = {
944 .num_items = 4,
945 .items = {
946 { "Mic", 0x0 },
947 { "Front Mic", 0x1 },
948 { "Line", 0x2 },
949 { "CD", 0x4 },
950 },
951};
952
953/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100954static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200955 { 8, NULL },
956};
957
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100958static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100962 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200963 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
964 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100965 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
966 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200967 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100968 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
975 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
977 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
978 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200979 {
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
981 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100982 .info = alc_ch_mode_info,
983 .get = alc_ch_mode_get,
984 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200985 },
986 { } /* end */
987};
988
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200989
990/*
991 * ALC880 W810 model
992 *
993 * W810 has rear IO for:
994 * Front (DAC 02)
995 * Surround (DAC 03)
996 * Center/LFE (DAC 04)
997 * Digital out (06)
998 *
999 * The system also has a pair of internal speakers, and a headphone jack.
1000 * These are both connected to Line2 on the codec, hence to DAC 02.
1001 *
1002 * There is a variable resistor to control the speaker or headphone
1003 * volume. This is a hardware-only device without a software API.
1004 *
1005 * Plugging headphones in will disable the internal speakers. This is
1006 * implemented in hardware, not via the driver using jack sense. In
1007 * a similar fashion, plugging into the rear socket marked "front" will
1008 * disable both the speakers and headphones.
1009 *
1010 * For input, there's a microphone jack, and an "audio in" jack.
1011 * These may not do anything useful with this driver yet, because I
1012 * haven't setup any initialization verbs for these yet...
1013 */
1014
1015static hda_nid_t alc880_w810_dac_nids[3] = {
1016 /* front, rear/surround, clfe */
1017 0x02, 0x03, 0x04
1018};
1019
1020/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001021static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001022 { 6, NULL }
1023};
1024
1025/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001026static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001028 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001029 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001030 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001031 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001033 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1034 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001035 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1036 { } /* end */
1037};
1038
1039
1040/*
1041 * Z710V model
1042 *
1043 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001044 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1045 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001046 */
1047
1048static hda_nid_t alc880_z71v_dac_nids[1] = {
1049 0x02
1050};
1051#define ALC880_Z71V_HP_DAC 0x03
1052
1053/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001054static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001055 { 2, NULL }
1056};
1057
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001058static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001059 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001060 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001061 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001062 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001063 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1064 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1066 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1067 { } /* end */
1068};
1069
1070
1071/* FIXME! */
1072/*
1073 * ALC880 F1734 model
1074 *
1075 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1076 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1077 */
1078
1079static hda_nid_t alc880_f1734_dac_nids[1] = {
1080 0x03
1081};
1082#define ALC880_F1734_HP_DAC 0x02
1083
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001084static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001085 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001086 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001087 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001088 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001093 { } /* end */
1094};
1095
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001096
1097/* FIXME! */
1098/*
1099 * ALC880 ASUS model
1100 *
1101 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1102 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1103 * Mic = 0x18, Line = 0x1a
1104 */
1105
1106#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1107#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1108
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001109static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001111 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001113 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001114 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1115 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001116 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1117 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001124 {
1125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1126 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001127 .info = alc_ch_mode_info,
1128 .get = alc_ch_mode_get,
1129 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001130 },
1131 { } /* end */
1132};
1133
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001134/* FIXME! */
1135/*
1136 * ALC880 ASUS W1V model
1137 *
1138 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1139 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1140 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1141 */
1142
1143/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001144static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001145 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1146 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001147 { } /* end */
1148};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001149
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001150/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001151static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001152 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1153 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1154 { } /* end */
1155};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001156
Kailang Yangdf694da2005-12-05 19:42:22 +01001157/* TCL S700 */
1158static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1159 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1160 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1161 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1163 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1166 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1167 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1168 {
1169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1170 /* The multiple "Capture Source" controls confuse alsamixer
1171 * So call somewhat different..
1172 * FIXME: the controls appear in the "playback" view!
1173 */
1174 /* .name = "Capture Source", */
1175 .name = "Input Source",
1176 .count = 1,
1177 .info = alc_mux_enum_info,
1178 .get = alc_mux_enum_get,
1179 .put = alc_mux_enum_put,
1180 },
1181 { } /* end */
1182};
1183
Kailang Yangccc656c2006-10-17 12:32:26 +02001184/* Uniwill */
1185static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1186 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1187 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1188 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1189 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1190 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1191 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1192 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1193 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1194 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1195 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1200 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1201 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1202 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1203 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1204 {
1205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1206 .name = "Channel Mode",
1207 .info = alc_ch_mode_info,
1208 .get = alc_ch_mode_get,
1209 .put = alc_ch_mode_put,
1210 },
1211 { } /* end */
1212};
1213
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001214static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1215 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1216 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1217 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1218 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1221 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1222 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1223 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1224 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1225 { } /* end */
1226};
1227
Kailang Yangccc656c2006-10-17 12:32:26 +02001228static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1229 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1230 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1231 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1232 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1234 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1235 { } /* end */
1236};
1237
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001239 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240 */
1241static int alc_build_controls(struct hda_codec *codec)
1242{
1243 struct alc_spec *spec = codec->spec;
1244 int err;
1245 int i;
1246
1247 for (i = 0; i < spec->num_mixers; i++) {
1248 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1249 if (err < 0)
1250 return err;
1251 }
1252
1253 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001254 err = snd_hda_create_spdif_out_ctls(codec,
1255 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001256 if (err < 0)
1257 return err;
1258 }
1259 if (spec->dig_in_nid) {
1260 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1261 if (err < 0)
1262 return err;
1263 }
1264 return 0;
1265}
1266
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001267
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268/*
1269 * initialize the codec volumes, etc
1270 */
1271
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001272/*
1273 * generic initialization of ADC, input mixers and output mixers
1274 */
1275static struct hda_verb alc880_volume_init_verbs[] = {
1276 /*
1277 * Unmute ADC0-2 and set the default input to mic-in
1278 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001279 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001281 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001282 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001283 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001284 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1287 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001288 * Note: PASD motherboards uses the Line In 2 as the input for front
1289 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298 /*
1299 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001301 /* set vol=0 to output mixers */
1302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1303 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1304 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1305 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1306 /* set up input amps for analog loopback */
1307 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1313 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001314 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1315 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316
1317 { }
1318};
1319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001320/*
1321 * 3-stack pin configuration:
1322 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1323 */
1324static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1325 /*
1326 * preset connection lists of input pins
1327 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1328 */
1329 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1330 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1331 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1332
1333 /*
1334 * Set pin mode and muting
1335 */
1336 /* set front pin widgets 0x14 for output */
1337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1338 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1339 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1340 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1341 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1342 /* Mic2 (as headphone out) for HP output */
1343 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1344 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1345 /* Line In pin widget for input */
1346 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1347 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1348 /* Line2 (as front mic) pin widget for input and vref at 80% */
1349 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1350 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1351 /* CD pin widget for input */
1352 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1353
1354 { }
1355};
1356
1357/*
1358 * 5-stack pin configuration:
1359 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1360 * line-in/side = 0x1a, f-mic = 0x1b
1361 */
1362static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1363 /*
1364 * preset connection lists of input pins
1365 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1366 */
1367 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1368 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1369
1370 /*
1371 * Set pin mode and muting
1372 */
1373 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1376 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1377 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001378 /* unmute pins for output (no gain on this amp) */
1379 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1380 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1381 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1382 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1383
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001385 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001386 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1387 /* Mic2 (as headphone out) for HP output */
1388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001389 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001390 /* Line In pin widget for input */
1391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1393 /* Line2 (as front mic) pin widget for input and vref at 80% */
1394 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1395 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1396 /* CD pin widget for input */
1397 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398
1399 { }
1400};
1401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001402/*
1403 * W810 pin configuration:
1404 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1405 */
1406static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 /* hphone/speaker input selector: front DAC */
1408 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1409
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1415 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1416
1417 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001418 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 { }
1421};
1422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001423/*
1424 * Z71V pin configuration:
1425 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1426 */
1427static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001429 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001432
Takashi Iwai16ded522005-06-10 19:58:24 +02001433 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001434 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001435 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001436 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001437
1438 { }
1439};
1440
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001441/*
1442 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001443 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1444 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001445 */
1446static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1447 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1448
Takashi Iwai16ded522005-06-10 19:58:24 +02001449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001450 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001455 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001456 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1457
Takashi Iwai16ded522005-06-10 19:58:24 +02001458 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001460 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001462 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001463 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001466 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1467
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001468 { }
1469};
Takashi Iwai16ded522005-06-10 19:58:24 +02001470
Kailang Yangccc656c2006-10-17 12:32:26 +02001471/*
1472 * Uniwill pin configuration:
1473 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1474 * line = 0x1a
1475 */
1476static struct hda_verb alc880_uniwill_init_verbs[] = {
1477 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1478
1479 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1482 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1483 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1484 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1485 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1486 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1490 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1493
1494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1495 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1496 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1499 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1500 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1501 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1502 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1503
1504 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1505 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1506
1507 { }
1508};
1509
1510/*
1511* Uniwill P53
1512* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1513 */
1514static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1515 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1516
1517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1521 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1522 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1526 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1528 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1529
1530 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1531 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1533 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1534 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1535 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1536
1537 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1538 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1539
1540 { }
1541};
1542
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001543static struct hda_verb alc880_beep_init_verbs[] = {
1544 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1545 { }
1546};
1547
Kailang Yangccc656c2006-10-17 12:32:26 +02001548/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001549static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001550{
1551 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001552 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001553
1554 present = snd_hda_codec_read(codec, 0x14, 0,
1555 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001556 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001557 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001558 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001559 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001560 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001561 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001562 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001563 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001564 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001565}
1566
1567/* auto-toggle front mic */
1568static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1569{
1570 unsigned int present;
1571 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001572
1573 present = snd_hda_codec_read(codec, 0x18, 0,
1574 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001575 bits = present ? 0x80 : 0;
1576 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1577 0x80, bits);
1578 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1579 0x80, bits);
1580}
1581
1582static void alc880_uniwill_automute(struct hda_codec *codec)
1583{
1584 alc880_uniwill_hp_automute(codec);
1585 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001586}
1587
1588static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1589 unsigned int res)
1590{
1591 /* Looks like the unsol event is incompatible with the standard
1592 * definition. 4bit tag is placed at 28 bit!
1593 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001594 switch (res >> 28) {
1595 case ALC880_HP_EVENT:
1596 alc880_uniwill_hp_automute(codec);
1597 break;
1598 case ALC880_MIC_EVENT:
1599 alc880_uniwill_mic_automute(codec);
1600 break;
1601 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001602}
1603
1604static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1605{
1606 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001607 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001608
1609 present = snd_hda_codec_read(codec, 0x14, 0,
1610 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001611 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001612 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001613 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001614 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001615 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001616}
1617
1618static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1619{
1620 unsigned int present;
1621
1622 present = snd_hda_codec_read(codec, 0x21, 0,
1623 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1624
1625 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1626 0x7f, present);
1627 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1628 0x7f, present);
1629
1630 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1631 0x7f, present);
1632 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1633 0x7f, present);
1634
1635}
1636static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1637 unsigned int res)
1638{
1639 /* Looks like the unsol event is incompatible with the standard
1640 * definition. 4bit tag is placed at 28 bit!
1641 */
1642 if ((res >> 28) == ALC880_HP_EVENT)
1643 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001644 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001645 alc880_uniwill_p53_dcvol_automute(codec);
1646}
1647
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001648/* FIXME! */
1649/*
1650 * F1734 pin configuration:
1651 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1652 */
1653static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1654 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1655 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1656 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1657 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1658
1659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663
1664 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1666 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1667 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1671 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001673
1674 { }
1675};
1676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001677/* FIXME! */
1678/*
1679 * ASUS pin configuration:
1680 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1681 */
1682static struct hda_verb alc880_pin_asus_init_verbs[] = {
1683 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1684 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1685 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1687
1688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696
1697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1701 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1703 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1706
1707 { }
1708};
1709
1710/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001711#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1712#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001713
Kailang Yangdf694da2005-12-05 19:42:22 +01001714/* Clevo m520g init */
1715static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1716 /* headphone output */
1717 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1718 /* line-out */
1719 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1721 /* Line-in */
1722 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1724 /* CD */
1725 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1726 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1727 /* Mic1 (rear panel) */
1728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1730 /* Mic2 (front panel) */
1731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733 /* headphone */
1734 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1735 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1736 /* change to EAPD mode */
1737 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1738 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1739
1740 { }
1741};
1742
1743static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001744 /* change to EAPD mode */
1745 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1746 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1747
Kailang Yangdf694da2005-12-05 19:42:22 +01001748 /* Headphone output */
1749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1750 /* Front output*/
1751 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1752 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1753
1754 /* Line In pin widget for input */
1755 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1756 /* CD pin widget for input */
1757 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1758 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1759 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1760
1761 /* change to EAPD mode */
1762 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1763 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1764
1765 { }
1766};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001767
1768/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001769 * LG m1 express dual
1770 *
1771 * Pin assignment:
1772 * Rear Line-In/Out (blue): 0x14
1773 * Build-in Mic-In: 0x15
1774 * Speaker-out: 0x17
1775 * HP-Out (green): 0x1b
1776 * Mic-In/Out (red): 0x19
1777 * SPDIF-Out: 0x1e
1778 */
1779
1780/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1781static hda_nid_t alc880_lg_dac_nids[3] = {
1782 0x05, 0x02, 0x03
1783};
1784
1785/* seems analog CD is not working */
1786static struct hda_input_mux alc880_lg_capture_source = {
1787 .num_items = 3,
1788 .items = {
1789 { "Mic", 0x1 },
1790 { "Line", 0x5 },
1791 { "Internal Mic", 0x6 },
1792 },
1793};
1794
1795/* 2,4,6 channel modes */
1796static struct hda_verb alc880_lg_ch2_init[] = {
1797 /* set line-in and mic-in to input */
1798 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1799 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1800 { }
1801};
1802
1803static struct hda_verb alc880_lg_ch4_init[] = {
1804 /* set line-in to out and mic-in to input */
1805 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1806 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1807 { }
1808};
1809
1810static struct hda_verb alc880_lg_ch6_init[] = {
1811 /* set line-in and mic-in to output */
1812 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1813 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1814 { }
1815};
1816
1817static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1818 { 2, alc880_lg_ch2_init },
1819 { 4, alc880_lg_ch4_init },
1820 { 6, alc880_lg_ch6_init },
1821};
1822
1823static struct snd_kcontrol_new alc880_lg_mixer[] = {
1824 /* FIXME: it's not really "master" but front channels */
1825 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1826 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1827 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1828 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1830 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1831 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1832 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1835 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1836 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1837 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1838 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1839 {
1840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1841 .name = "Channel Mode",
1842 .info = alc_ch_mode_info,
1843 .get = alc_ch_mode_get,
1844 .put = alc_ch_mode_put,
1845 },
1846 { } /* end */
1847};
1848
1849static struct hda_verb alc880_lg_init_verbs[] = {
1850 /* set capture source to mic-in */
1851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1852 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1854 /* mute all amp mixer inputs */
1855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1858 /* line-in to input */
1859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1860 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1861 /* built-in mic */
1862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1864 /* speaker-out */
1865 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 /* mic-in to input */
1868 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1869 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1870 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1871 /* HP-out */
1872 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1873 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1874 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1875 /* jack sense */
1876 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1877 { }
1878};
1879
1880/* toggle speaker-output according to the hp-jack state */
1881static void alc880_lg_automute(struct hda_codec *codec)
1882{
1883 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001884 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001885
1886 present = snd_hda_codec_read(codec, 0x1b, 0,
1887 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001888 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001889 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001890 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001891 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001892 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001893}
1894
1895static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1896{
1897 /* Looks like the unsol event is incompatible with the standard
1898 * definition. 4bit tag is placed at 28 bit!
1899 */
1900 if ((res >> 28) == 0x01)
1901 alc880_lg_automute(codec);
1902}
1903
1904/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001905 * LG LW20
1906 *
1907 * Pin assignment:
1908 * Speaker-out: 0x14
1909 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001910 * Built-in Mic-In: 0x19
1911 * Line-In: 0x1b
1912 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01001913 * SPDIF-Out: 0x1e
1914 */
1915
Takashi Iwaid6815182006-03-23 16:06:23 +01001916static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001917 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01001918 .items = {
1919 { "Mic", 0x0 },
1920 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001921 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001922 },
1923};
1924
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001925#define alc880_lg_lw_modes alc880_threestack_modes
1926
Takashi Iwaid6815182006-03-23 16:06:23 +01001927static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1931 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1932 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1933 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1934 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1935 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1936 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1937 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001938 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1939 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1940 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1941 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001942 {
1943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1944 .name = "Channel Mode",
1945 .info = alc_ch_mode_info,
1946 .get = alc_ch_mode_get,
1947 .put = alc_ch_mode_put,
1948 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001949 { } /* end */
1950};
1951
1952static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001953 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1954 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1955 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1956
Takashi Iwaid6815182006-03-23 16:06:23 +01001957 /* set capture source to mic-in */
1958 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1959 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1960 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1961 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1962 /* speaker-out */
1963 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1965 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1967 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 /* mic-in to input */
1969 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1970 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 /* built-in mic */
1972 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1973 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1974 /* jack sense */
1975 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1976 { }
1977};
1978
1979/* toggle speaker-output according to the hp-jack state */
1980static void alc880_lg_lw_automute(struct hda_codec *codec)
1981{
1982 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001983 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001984
1985 present = snd_hda_codec_read(codec, 0x1b, 0,
1986 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001987 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001988 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001989 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001990 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001991 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001992}
1993
1994static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1995{
1996 /* Looks like the unsol event is incompatible with the standard
1997 * definition. 4bit tag is placed at 28 bit!
1998 */
1999 if ((res >> 28) == 0x01)
2000 alc880_lg_lw_automute(codec);
2001}
2002
2003/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002004 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002005 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002006
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007static int alc_init(struct hda_codec *codec)
2008{
2009 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002010 unsigned int i;
2011
2012 for (i = 0; i < spec->num_init_verbs; i++)
2013 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002014
2015 if (spec->init_hook)
2016 spec->init_hook(codec);
2017
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018 return 0;
2019}
2020
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002021static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2022{
2023 struct alc_spec *spec = codec->spec;
2024
2025 if (spec->unsol_event)
2026 spec->unsol_event(codec, res);
2027}
2028
Linus Torvalds1da177e2005-04-16 15:20:36 -07002029#ifdef CONFIG_PM
2030/*
2031 * resume
2032 */
2033static int alc_resume(struct hda_codec *codec)
2034{
2035 struct alc_spec *spec = codec->spec;
2036 int i;
2037
2038 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002039 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002041 if (spec->multiout.dig_out_nid)
2042 snd_hda_resume_spdif_out(codec);
2043 if (spec->dig_in_nid)
2044 snd_hda_resume_spdif_in(codec);
2045
2046 return 0;
2047}
2048#endif
2049
2050/*
2051 * Analog playback callbacks
2052 */
2053static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2054 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002055 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056{
2057 struct alc_spec *spec = codec->spec;
2058 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2059}
2060
2061static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2062 struct hda_codec *codec,
2063 unsigned int stream_tag,
2064 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002065 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066{
2067 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002068 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2069 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002070}
2071
2072static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2073 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002074 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002075{
2076 struct alc_spec *spec = codec->spec;
2077 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2078}
2079
2080/*
2081 * Digital out
2082 */
2083static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2084 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002085 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086{
2087 struct alc_spec *spec = codec->spec;
2088 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2089}
2090
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002091static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2092 struct hda_codec *codec,
2093 unsigned int stream_tag,
2094 unsigned int format,
2095 struct snd_pcm_substream *substream)
2096{
2097 struct alc_spec *spec = codec->spec;
2098 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2099 stream_tag, format, substream);
2100}
2101
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2103 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002104 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105{
2106 struct alc_spec *spec = codec->spec;
2107 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2108}
2109
2110/*
2111 * Analog capture
2112 */
2113static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2114 struct hda_codec *codec,
2115 unsigned int stream_tag,
2116 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002117 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118{
2119 struct alc_spec *spec = codec->spec;
2120
2121 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2122 stream_tag, 0, format);
2123 return 0;
2124}
2125
2126static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2127 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002128 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129{
2130 struct alc_spec *spec = codec->spec;
2131
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002132 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2133 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 return 0;
2135}
2136
2137
2138/*
2139 */
2140static struct hda_pcm_stream alc880_pcm_analog_playback = {
2141 .substreams = 1,
2142 .channels_min = 2,
2143 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002144 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145 .ops = {
2146 .open = alc880_playback_pcm_open,
2147 .prepare = alc880_playback_pcm_prepare,
2148 .cleanup = alc880_playback_pcm_cleanup
2149 },
2150};
2151
2152static struct hda_pcm_stream alc880_pcm_analog_capture = {
2153 .substreams = 2,
2154 .channels_min = 2,
2155 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002156 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157 .ops = {
2158 .prepare = alc880_capture_pcm_prepare,
2159 .cleanup = alc880_capture_pcm_cleanup
2160 },
2161};
2162
2163static struct hda_pcm_stream alc880_pcm_digital_playback = {
2164 .substreams = 1,
2165 .channels_min = 2,
2166 .channels_max = 2,
2167 /* NID is set in alc_build_pcms */
2168 .ops = {
2169 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002170 .close = alc880_dig_playback_pcm_close,
2171 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172 },
2173};
2174
2175static struct hda_pcm_stream alc880_pcm_digital_capture = {
2176 .substreams = 1,
2177 .channels_min = 2,
2178 .channels_max = 2,
2179 /* NID is set in alc_build_pcms */
2180};
2181
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002182/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2183static struct hda_pcm_stream alc_pcm_null_playback = {
2184 .substreams = 0,
2185 .channels_min = 0,
2186 .channels_max = 0,
2187};
2188
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189static int alc_build_pcms(struct hda_codec *codec)
2190{
2191 struct alc_spec *spec = codec->spec;
2192 struct hda_pcm *info = spec->pcm_rec;
2193 int i;
2194
2195 codec->num_pcms = 1;
2196 codec->pcm_info = info;
2197
2198 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002199 if (spec->stream_analog_playback) {
2200 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2201 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2202 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2203 }
2204 if (spec->stream_analog_capture) {
2205 snd_assert(spec->adc_nids, return -EINVAL);
2206 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2207 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2208 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209
Takashi Iwai4a471b72005-12-07 13:56:29 +01002210 if (spec->channel_mode) {
2211 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2212 for (i = 0; i < spec->num_channel_mode; i++) {
2213 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2214 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2215 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 }
2217 }
2218
Takashi Iwaie08a0072006-09-07 17:52:14 +02002219 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002220 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002221 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002222 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002223 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002224 if (spec->multiout.dig_out_nid &&
2225 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002226 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2227 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2228 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002229 if (spec->dig_in_nid &&
2230 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002231 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2232 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2233 }
2234 }
2235
Takashi Iwaie08a0072006-09-07 17:52:14 +02002236 /* If the use of more than one ADC is requested for the current
2237 * model, configure a second analog capture-only PCM.
2238 */
2239 /* Additional Analaog capture for index #2 */
2240 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2241 spec->adc_nids) {
2242 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002243 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002244 info->name = spec->stream_name_analog;
2245 /* No playback stream for second PCM */
2246 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2247 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2248 if (spec->stream_analog_capture) {
2249 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2250 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2251 }
2252 }
2253
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254 return 0;
2255}
2256
2257static void alc_free(struct hda_codec *codec)
2258{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002259 struct alc_spec *spec = codec->spec;
2260 unsigned int i;
2261
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002262 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002263 return;
2264
2265 if (spec->kctl_alloc) {
2266 for (i = 0; i < spec->num_kctl_used; i++)
2267 kfree(spec->kctl_alloc[i].name);
2268 kfree(spec->kctl_alloc);
2269 }
2270 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271}
2272
2273/*
2274 */
2275static struct hda_codec_ops alc_patch_ops = {
2276 .build_controls = alc_build_controls,
2277 .build_pcms = alc_build_pcms,
2278 .init = alc_init,
2279 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002280 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281#ifdef CONFIG_PM
2282 .resume = alc_resume,
2283#endif
2284};
2285
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002286
2287/*
2288 * Test configuration for debugging
2289 *
2290 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2291 * enum controls.
2292 */
2293#ifdef CONFIG_SND_DEBUG
2294static hda_nid_t alc880_test_dac_nids[4] = {
2295 0x02, 0x03, 0x04, 0x05
2296};
2297
2298static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002299 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002300 .items = {
2301 { "In-1", 0x0 },
2302 { "In-2", 0x1 },
2303 { "In-3", 0x2 },
2304 { "In-4", 0x3 },
2305 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002306 { "Front", 0x5 },
2307 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002308 },
2309};
2310
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002311static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002312 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002313 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002314 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002315 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002316};
2317
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002318static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2319 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002320{
2321 static char *texts[] = {
2322 "N/A", "Line Out", "HP Out",
2323 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2324 };
2325 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2326 uinfo->count = 1;
2327 uinfo->value.enumerated.items = 8;
2328 if (uinfo->value.enumerated.item >= 8)
2329 uinfo->value.enumerated.item = 7;
2330 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2331 return 0;
2332}
2333
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002334static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2335 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002336{
2337 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2338 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2339 unsigned int pin_ctl, item = 0;
2340
2341 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2342 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2343 if (pin_ctl & AC_PINCTL_OUT_EN) {
2344 if (pin_ctl & AC_PINCTL_HP_EN)
2345 item = 2;
2346 else
2347 item = 1;
2348 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2349 switch (pin_ctl & AC_PINCTL_VREFEN) {
2350 case AC_PINCTL_VREF_HIZ: item = 3; break;
2351 case AC_PINCTL_VREF_50: item = 4; break;
2352 case AC_PINCTL_VREF_GRD: item = 5; break;
2353 case AC_PINCTL_VREF_80: item = 6; break;
2354 case AC_PINCTL_VREF_100: item = 7; break;
2355 }
2356 }
2357 ucontrol->value.enumerated.item[0] = item;
2358 return 0;
2359}
2360
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002361static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2362 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002363{
2364 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2365 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2366 static unsigned int ctls[] = {
2367 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2368 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2369 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2372 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2373 };
2374 unsigned int old_ctl, new_ctl;
2375
2376 old_ctl = snd_hda_codec_read(codec, nid, 0,
2377 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2378 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2379 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002380 snd_hda_codec_write(codec, nid, 0,
2381 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002382 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002383 (ucontrol->value.enumerated.item[0] >= 3 ?
2384 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002385 return 1;
2386 }
2387 return 0;
2388}
2389
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002390static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2391 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002392{
2393 static char *texts[] = {
2394 "Front", "Surround", "CLFE", "Side"
2395 };
2396 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2397 uinfo->count = 1;
2398 uinfo->value.enumerated.items = 4;
2399 if (uinfo->value.enumerated.item >= 4)
2400 uinfo->value.enumerated.item = 3;
2401 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2402 return 0;
2403}
2404
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002405static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2406 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002407{
2408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2409 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2410 unsigned int sel;
2411
2412 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2413 ucontrol->value.enumerated.item[0] = sel & 3;
2414 return 0;
2415}
2416
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002417static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2418 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002419{
2420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2421 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2422 unsigned int sel;
2423
2424 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2425 if (ucontrol->value.enumerated.item[0] != sel) {
2426 sel = ucontrol->value.enumerated.item[0] & 3;
2427 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2428 return 1;
2429 }
2430 return 0;
2431}
2432
2433#define PIN_CTL_TEST(xname,nid) { \
2434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2435 .name = xname, \
2436 .info = alc_test_pin_ctl_info, \
2437 .get = alc_test_pin_ctl_get, \
2438 .put = alc_test_pin_ctl_put, \
2439 .private_value = nid \
2440 }
2441
2442#define PIN_SRC_TEST(xname,nid) { \
2443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2444 .name = xname, \
2445 .info = alc_test_pin_src_info, \
2446 .get = alc_test_pin_src_get, \
2447 .put = alc_test_pin_src_put, \
2448 .private_value = nid \
2449 }
2450
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002451static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2453 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2454 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2455 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002456 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2457 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2458 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2459 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002460 PIN_CTL_TEST("Front Pin Mode", 0x14),
2461 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2462 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2463 PIN_CTL_TEST("Side Pin Mode", 0x17),
2464 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2465 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2466 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2467 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2468 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2469 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2470 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2471 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2472 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2473 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2474 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2475 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2476 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2477 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2478 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2479 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2480 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2481 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002482 {
2483 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2484 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002485 .info = alc_ch_mode_info,
2486 .get = alc_ch_mode_get,
2487 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002488 },
2489 { } /* end */
2490};
2491
2492static struct hda_verb alc880_test_init_verbs[] = {
2493 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2497 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2499 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2500 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2501 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002502 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2506 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002507 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002508 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2510 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2511 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002512 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002513 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2514 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2515 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2516 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002517 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002518 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2519 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002520 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2521 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2522 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002523 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002524 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2525 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2526 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2527 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002528 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002530 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002532 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002533 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002534 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002535 /* Analog input/passthru */
2536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002541 { }
2542};
2543#endif
2544
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545/*
2546 */
2547
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002548static const char *alc880_models[ALC880_MODEL_LAST] = {
2549 [ALC880_3ST] = "3stack",
2550 [ALC880_TCL_S700] = "tcl",
2551 [ALC880_3ST_DIG] = "3stack-digout",
2552 [ALC880_CLEVO] = "clevo",
2553 [ALC880_5ST] = "5stack",
2554 [ALC880_5ST_DIG] = "5stack-digout",
2555 [ALC880_W810] = "w810",
2556 [ALC880_Z71V] = "z71v",
2557 [ALC880_6ST] = "6stack",
2558 [ALC880_6ST_DIG] = "6stack-digout",
2559 [ALC880_ASUS] = "asus",
2560 [ALC880_ASUS_W1V] = "asus-w1v",
2561 [ALC880_ASUS_DIG] = "asus-dig",
2562 [ALC880_ASUS_DIG2] = "asus-dig2",
2563 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002564 [ALC880_UNIWILL_P53] = "uniwill-p53",
2565 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002566 [ALC880_F1734] = "F1734",
2567 [ALC880_LG] = "lg",
2568 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002569#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002570 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002571#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002572 [ALC880_AUTO] = "auto",
2573};
2574
2575static struct snd_pci_quirk alc880_cfg_tbl[] = {
2576 /* Broken BIOS configuration */
2577 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2578 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2579
2580 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2581 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002582 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002583 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2584 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2585 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2586 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2587 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2588 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2589
2590 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2591 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2592
2593 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2594 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2595 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2596 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2597 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2598 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2599 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2600 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2601 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2602 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002603 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002604 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2605 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2606 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2607 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2608
2609 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2610 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2611 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2612 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2613 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2614 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2615 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2616 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2617 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2618 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2619 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2620 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2621 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2622 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2623 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2624 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2625 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2626 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2627
2628 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2629 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2630 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2631 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2632
2633 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2634 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2635 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002636 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002637
2638 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2639 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2640 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2641 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2642
2643 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2644 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2645 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2646 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2647 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2648 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2649 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2653 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002654
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 {}
2656};
2657
Takashi Iwai16ded522005-06-10 19:58:24 +02002658/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002659 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002661static struct alc_config_preset alc880_presets[] = {
2662 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002664 .init_verbs = { alc880_volume_init_verbs,
2665 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002666 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002668 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2669 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002670 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002671 .input_mux = &alc880_capture_source,
2672 },
2673 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002674 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002675 .init_verbs = { alc880_volume_init_verbs,
2676 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002678 .dac_nids = alc880_dac_nids,
2679 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002680 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2681 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002682 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 .input_mux = &alc880_capture_source,
2684 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002685 [ALC880_TCL_S700] = {
2686 .mixers = { alc880_tcl_s700_mixer },
2687 .init_verbs = { alc880_volume_init_verbs,
2688 alc880_pin_tcl_S700_init_verbs,
2689 alc880_gpio2_init_verbs },
2690 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2691 .dac_nids = alc880_dac_nids,
2692 .hp_nid = 0x03,
2693 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2694 .channel_mode = alc880_2_jack_modes,
2695 .input_mux = &alc880_capture_source,
2696 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002697 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002698 .mixers = { alc880_three_stack_mixer,
2699 alc880_five_stack_mixer},
2700 .init_verbs = { alc880_volume_init_verbs,
2701 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002702 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2703 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002704 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2705 .channel_mode = alc880_fivestack_modes,
2706 .input_mux = &alc880_capture_source,
2707 },
2708 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002709 .mixers = { alc880_three_stack_mixer,
2710 alc880_five_stack_mixer },
2711 .init_verbs = { alc880_volume_init_verbs,
2712 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002713 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2714 .dac_nids = alc880_dac_nids,
2715 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002716 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2717 .channel_mode = alc880_fivestack_modes,
2718 .input_mux = &alc880_capture_source,
2719 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002720 [ALC880_6ST] = {
2721 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002722 .init_verbs = { alc880_volume_init_verbs,
2723 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002724 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2725 .dac_nids = alc880_6st_dac_nids,
2726 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2727 .channel_mode = alc880_sixstack_modes,
2728 .input_mux = &alc880_6stack_capture_source,
2729 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002730 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002731 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002732 .init_verbs = { alc880_volume_init_verbs,
2733 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002734 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2735 .dac_nids = alc880_6st_dac_nids,
2736 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002737 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2738 .channel_mode = alc880_sixstack_modes,
2739 .input_mux = &alc880_6stack_capture_source,
2740 },
2741 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002742 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002743 .init_verbs = { alc880_volume_init_verbs,
2744 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002745 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002746 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2747 .dac_nids = alc880_w810_dac_nids,
2748 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002749 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2750 .channel_mode = alc880_w810_modes,
2751 .input_mux = &alc880_capture_source,
2752 },
2753 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002755 .init_verbs = { alc880_volume_init_verbs,
2756 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002757 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2758 .dac_nids = alc880_z71v_dac_nids,
2759 .dig_out_nid = ALC880_DIGOUT_NID,
2760 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002761 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2762 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002763 .input_mux = &alc880_capture_source,
2764 },
2765 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002767 .init_verbs = { alc880_volume_init_verbs,
2768 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002769 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2770 .dac_nids = alc880_f1734_dac_nids,
2771 .hp_nid = 0x02,
2772 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2773 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002774 .input_mux = &alc880_capture_source,
2775 },
2776 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002777 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002778 .init_verbs = { alc880_volume_init_verbs,
2779 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780 alc880_gpio1_init_verbs },
2781 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2782 .dac_nids = alc880_asus_dac_nids,
2783 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2784 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002785 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002786 .input_mux = &alc880_capture_source,
2787 },
2788 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002789 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002790 .init_verbs = { alc880_volume_init_verbs,
2791 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002792 alc880_gpio1_init_verbs },
2793 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2794 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002795 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2797 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002798 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002799 .input_mux = &alc880_capture_source,
2800 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002801 [ALC880_ASUS_DIG2] = {
2802 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002803 .init_verbs = { alc880_volume_init_verbs,
2804 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002805 alc880_gpio2_init_verbs }, /* use GPIO2 */
2806 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2807 .dac_nids = alc880_asus_dac_nids,
2808 .dig_out_nid = ALC880_DIGOUT_NID,
2809 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2810 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002811 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002812 .input_mux = &alc880_capture_source,
2813 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002814 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002815 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002816 .init_verbs = { alc880_volume_init_verbs,
2817 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002818 alc880_gpio1_init_verbs },
2819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2820 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002821 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002822 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2823 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002824 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002825 .input_mux = &alc880_capture_source,
2826 },
2827 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002828 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002829 .init_verbs = { alc880_volume_init_verbs,
2830 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002831 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2832 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002833 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002834 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2835 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002836 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002837 .input_mux = &alc880_capture_source,
2838 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002839 [ALC880_UNIWILL] = {
2840 .mixers = { alc880_uniwill_mixer },
2841 .init_verbs = { alc880_volume_init_verbs,
2842 alc880_uniwill_init_verbs },
2843 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2844 .dac_nids = alc880_asus_dac_nids,
2845 .dig_out_nid = ALC880_DIGOUT_NID,
2846 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2847 .channel_mode = alc880_threestack_modes,
2848 .need_dac_fix = 1,
2849 .input_mux = &alc880_capture_source,
2850 .unsol_event = alc880_uniwill_unsol_event,
2851 .init_hook = alc880_uniwill_automute,
2852 },
2853 [ALC880_UNIWILL_P53] = {
2854 .mixers = { alc880_uniwill_p53_mixer },
2855 .init_verbs = { alc880_volume_init_verbs,
2856 alc880_uniwill_p53_init_verbs },
2857 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2858 .dac_nids = alc880_asus_dac_nids,
2859 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002860 .channel_mode = alc880_threestack_modes,
2861 .input_mux = &alc880_capture_source,
2862 .unsol_event = alc880_uniwill_p53_unsol_event,
2863 .init_hook = alc880_uniwill_p53_hp_automute,
2864 },
2865 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002866 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002867 alc880_pcbeep_mixer, },
2868 .init_verbs = { alc880_volume_init_verbs,
2869 alc880_uniwill_p53_init_verbs,
2870 alc880_beep_init_verbs },
2871 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2872 .dac_nids = alc880_dac_nids,
2873 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2874 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002875 .input_mux = &alc880_capture_source,
2876 .unsol_event = alc880_uniwill_p53_unsol_event,
2877 .init_hook = alc880_uniwill_p53_hp_automute,
2878 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002879 [ALC880_CLEVO] = {
2880 .mixers = { alc880_three_stack_mixer },
2881 .init_verbs = { alc880_volume_init_verbs,
2882 alc880_pin_clevo_init_verbs },
2883 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2884 .dac_nids = alc880_dac_nids,
2885 .hp_nid = 0x03,
2886 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2887 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002888 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002889 .input_mux = &alc880_capture_source,
2890 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002891 [ALC880_LG] = {
2892 .mixers = { alc880_lg_mixer },
2893 .init_verbs = { alc880_volume_init_verbs,
2894 alc880_lg_init_verbs },
2895 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2896 .dac_nids = alc880_lg_dac_nids,
2897 .dig_out_nid = ALC880_DIGOUT_NID,
2898 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2899 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002900 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002901 .input_mux = &alc880_lg_capture_source,
2902 .unsol_event = alc880_lg_unsol_event,
2903 .init_hook = alc880_lg_automute,
2904 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002905 [ALC880_LG_LW] = {
2906 .mixers = { alc880_lg_lw_mixer },
2907 .init_verbs = { alc880_volume_init_verbs,
2908 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002909 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002910 .dac_nids = alc880_dac_nids,
2911 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002912 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2913 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002914 .input_mux = &alc880_lg_lw_capture_source,
2915 .unsol_event = alc880_lg_lw_unsol_event,
2916 .init_hook = alc880_lg_lw_automute,
2917 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002918#ifdef CONFIG_SND_DEBUG
2919 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002920 .mixers = { alc880_test_mixer },
2921 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002922 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2923 .dac_nids = alc880_test_dac_nids,
2924 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002925 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2926 .channel_mode = alc880_test_modes,
2927 .input_mux = &alc880_test_capture_source,
2928 },
2929#endif
2930};
2931
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002932/*
2933 * Automatic parse of I/O pins from the BIOS configuration
2934 */
2935
2936#define NUM_CONTROL_ALLOC 32
2937#define NUM_VERB_ALLOC 32
2938
2939enum {
2940 ALC_CTL_WIDGET_VOL,
2941 ALC_CTL_WIDGET_MUTE,
2942 ALC_CTL_BIND_MUTE,
2943};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002944static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002945 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2946 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002947 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002948};
2949
2950/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002951static int add_control(struct alc_spec *spec, int type, const char *name,
2952 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002953{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002954 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002955
2956 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2957 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2958
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002959 /* array + terminator */
2960 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2961 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002962 return -ENOMEM;
2963 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002964 memcpy(knew, spec->kctl_alloc,
2965 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966 kfree(spec->kctl_alloc);
2967 }
2968 spec->kctl_alloc = knew;
2969 spec->num_kctl_alloc = num;
2970 }
2971
2972 knew = &spec->kctl_alloc[spec->num_kctl_used];
2973 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002974 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002975 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002976 return -ENOMEM;
2977 knew->private_value = val;
2978 spec->num_kctl_used++;
2979 return 0;
2980}
2981
2982#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2983#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2984#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2985#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2986#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2987#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2988#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2989#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2990#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2991#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2992#define ALC880_PIN_CD_NID 0x1c
2993
2994/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002995static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2996 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002997{
2998 hda_nid_t nid;
2999 int assigned[4];
3000 int i, j;
3001
3002 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003003 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003004
3005 /* check the pins hardwired to audio widget */
3006 for (i = 0; i < cfg->line_outs; i++) {
3007 nid = cfg->line_out_pins[i];
3008 if (alc880_is_fixed_pin(nid)) {
3009 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003010 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003011 assigned[idx] = 1;
3012 }
3013 }
3014 /* left pins can be connect to any audio widget */
3015 for (i = 0; i < cfg->line_outs; i++) {
3016 nid = cfg->line_out_pins[i];
3017 if (alc880_is_fixed_pin(nid))
3018 continue;
3019 /* search for an empty channel */
3020 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003021 if (!assigned[j]) {
3022 spec->multiout.dac_nids[i] =
3023 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003024 assigned[j] = 1;
3025 break;
3026 }
3027 }
3028 }
3029 spec->multiout.num_dacs = cfg->line_outs;
3030 return 0;
3031}
3032
3033/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003034static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3035 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003036{
3037 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003038 static const char *chname[4] = {
3039 "Front", "Surround", NULL /*CLFE*/, "Side"
3040 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003041 hda_nid_t nid;
3042 int i, err;
3043
3044 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003045 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003046 continue;
3047 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3048 if (i == 2) {
3049 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003050 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3051 "Center Playback Volume",
3052 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3053 HDA_OUTPUT));
3054 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003055 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003056 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3057 "LFE Playback Volume",
3058 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3059 HDA_OUTPUT));
3060 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003061 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003062 err = add_control(spec, ALC_CTL_BIND_MUTE,
3063 "Center Playback Switch",
3064 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3065 HDA_INPUT));
3066 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003067 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003068 err = add_control(spec, ALC_CTL_BIND_MUTE,
3069 "LFE Playback Switch",
3070 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3071 HDA_INPUT));
3072 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073 return err;
3074 } else {
3075 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003076 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3077 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3078 HDA_OUTPUT));
3079 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003080 return err;
3081 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003082 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3083 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3084 HDA_INPUT));
3085 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 return err;
3087 }
3088 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089 return 0;
3090}
3091
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003092/* add playback controls for speaker and HP outputs */
3093static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3094 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003095{
3096 hda_nid_t nid;
3097 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003098 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003099
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003100 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 return 0;
3102
3103 if (alc880_is_fixed_pin(pin)) {
3104 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003105 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003106 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003108 else
3109 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110 /* control HP volume/switch on the output mixer amp */
3111 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003112 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003113 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3114 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3115 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003117 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003118 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3119 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3120 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003121 return err;
3122 } else if (alc880_is_multi_pin(pin)) {
3123 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003125 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003126 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3127 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3128 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003129 return err;
3130 }
3131 return 0;
3132}
3133
3134/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003135static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3136 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003137 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003138{
3139 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003140 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003141
3142 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003143 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3144 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3145 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146 return err;
3147 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003148 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3149 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3150 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003151 return err;
3152 return 0;
3153}
3154
3155/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003156static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3157 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003158{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003159 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003160 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161
3162 for (i = 0; i < AUTO_PIN_LAST; i++) {
3163 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003164 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003165 err = new_analog_input(spec, cfg->input_pins[i],
3166 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003167 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003168 if (err < 0)
3169 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003170 imux->items[imux->num_items].label =
3171 auto_pin_cfg_labels[i];
3172 imux->items[imux->num_items].index =
3173 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174 imux->num_items++;
3175 }
3176 }
3177 return 0;
3178}
3179
Kailang Yangdf694da2005-12-05 19:42:22 +01003180static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3181 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003182 int dac_idx)
3183{
3184 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003185 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3186 pin_type);
3187 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3188 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003189 /* need the manual connection? */
3190 if (alc880_is_multi_pin(nid)) {
3191 struct alc_spec *spec = codec->spec;
3192 int idx = alc880_multi_pin_idx(nid);
3193 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3194 AC_VERB_SET_CONNECT_SEL,
3195 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3196 }
3197}
3198
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003199static int get_pin_type(int line_out_type)
3200{
3201 if (line_out_type == AUTO_PIN_HP_OUT)
3202 return PIN_HP;
3203 else
3204 return PIN_OUT;
3205}
3206
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003207static void alc880_auto_init_multi_out(struct hda_codec *codec)
3208{
3209 struct alc_spec *spec = codec->spec;
3210 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003211
3212 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213 for (i = 0; i < spec->autocfg.line_outs; i++) {
3214 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003215 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3216 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003217 }
3218}
3219
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003220static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003221{
3222 struct alc_spec *spec = codec->spec;
3223 hda_nid_t pin;
3224
Takashi Iwai82bc9552006-03-21 11:24:42 +01003225 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003226 if (pin) /* connect to front */
3227 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003228 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229 if (pin) /* connect to front */
3230 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3231}
3232
3233static void alc880_auto_init_analog_input(struct hda_codec *codec)
3234{
3235 struct alc_spec *spec = codec->spec;
3236 int i;
3237
3238 for (i = 0; i < AUTO_PIN_LAST; i++) {
3239 hda_nid_t nid = spec->autocfg.input_pins[i];
3240 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003241 snd_hda_codec_write(codec, nid, 0,
3242 AC_VERB_SET_PIN_WIDGET_CONTROL,
3243 i <= AUTO_PIN_FRONT_MIC ?
3244 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003245 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003246 snd_hda_codec_write(codec, nid, 0,
3247 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003248 AMP_OUT_MUTE);
3249 }
3250 }
3251}
3252
3253/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003254/* return 1 if successful, 0 if the proper config is not found,
3255 * or a negative error code
3256 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257static int alc880_parse_auto_config(struct hda_codec *codec)
3258{
3259 struct alc_spec *spec = codec->spec;
3260 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003261 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003263 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3264 alc880_ignore);
3265 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003267 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003269
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003270 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3271 if (err < 0)
3272 return err;
3273 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3274 if (err < 0)
3275 return err;
3276 err = alc880_auto_create_extra_out(spec,
3277 spec->autocfg.speaker_pins[0],
3278 "Speaker");
3279 if (err < 0)
3280 return err;
3281 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3282 "Headphone");
3283 if (err < 0)
3284 return err;
3285 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3286 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003287 return err;
3288
3289 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3290
3291 if (spec->autocfg.dig_out_pin)
3292 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3293 if (spec->autocfg.dig_in_pin)
3294 spec->dig_in_nid = ALC880_DIGIN_NID;
3295
3296 if (spec->kctl_alloc)
3297 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3298
3299 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3300
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003301 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003302 spec->input_mux = &spec->private_imux;
3303
3304 return 1;
3305}
3306
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003307/* additional initialization for auto-configuration model */
3308static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003309{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003310 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003311 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003312 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003313}
3314
3315/*
3316 * OK, here we have finally the patch for ALC880
3317 */
3318
Linus Torvalds1da177e2005-04-16 15:20:36 -07003319static int patch_alc880(struct hda_codec *codec)
3320{
3321 struct alc_spec *spec;
3322 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003323 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003324
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003325 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003326 if (spec == NULL)
3327 return -ENOMEM;
3328
3329 codec->spec = spec;
3330
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003331 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3332 alc880_models,
3333 alc880_cfg_tbl);
3334 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003335 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3336 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003337 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003338 }
3339
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003340 if (board_config == ALC880_AUTO) {
3341 /* automatic parse from the BIOS config */
3342 err = alc880_parse_auto_config(codec);
3343 if (err < 0) {
3344 alc_free(codec);
3345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003346 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003347 printk(KERN_INFO
3348 "hda_codec: Cannot set up configuration "
3349 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003350 board_config = ALC880_3ST;
3351 }
3352 }
3353
Kailang Yangdf694da2005-12-05 19:42:22 +01003354 if (board_config != ALC880_AUTO)
3355 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003356
3357 spec->stream_name_analog = "ALC880 Analog";
3358 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3359 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3360
3361 spec->stream_name_digital = "ALC880 Digital";
3362 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3363 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3364
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003365 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003366 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003367 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003368 /* get type */
3369 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003370 if (wcap != AC_WID_AUD_IN) {
3371 spec->adc_nids = alc880_adc_nids_alt;
3372 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003373 spec->mixers[spec->num_mixers] =
3374 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003375 spec->num_mixers++;
3376 } else {
3377 spec->adc_nids = alc880_adc_nids;
3378 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3379 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3380 spec->num_mixers++;
3381 }
3382 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003383
3384 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003386 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003387
3388 return 0;
3389}
3390
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003391
Linus Torvalds1da177e2005-04-16 15:20:36 -07003392/*
3393 * ALC260 support
3394 */
3395
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003396static hda_nid_t alc260_dac_nids[1] = {
3397 /* front */
3398 0x02,
3399};
3400
3401static hda_nid_t alc260_adc_nids[1] = {
3402 /* ADC0 */
3403 0x04,
3404};
3405
Kailang Yangdf694da2005-12-05 19:42:22 +01003406static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003407 /* ADC1 */
3408 0x05,
3409};
3410
Kailang Yangdf694da2005-12-05 19:42:22 +01003411static hda_nid_t alc260_hp_adc_nids[2] = {
3412 /* ADC1, 0 */
3413 0x05, 0x04
3414};
3415
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003416/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3417 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3418 */
3419static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003420 /* ADC0, ADC1 */
3421 0x04, 0x05
3422};
3423
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003424#define ALC260_DIGOUT_NID 0x03
3425#define ALC260_DIGIN_NID 0x06
3426
3427static struct hda_input_mux alc260_capture_source = {
3428 .num_items = 4,
3429 .items = {
3430 { "Mic", 0x0 },
3431 { "Front Mic", 0x1 },
3432 { "Line", 0x2 },
3433 { "CD", 0x4 },
3434 },
3435};
3436
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003437/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003438 * headphone jack and the internal CD lines since these are the only pins at
3439 * which audio can appear. For flexibility, also allow the option of
3440 * recording the mixer output on the second ADC (ADC0 doesn't have a
3441 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003442 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003443static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3444 {
3445 .num_items = 3,
3446 .items = {
3447 { "Mic/Line", 0x0 },
3448 { "CD", 0x4 },
3449 { "Headphone", 0x2 },
3450 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003451 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003452 {
3453 .num_items = 4,
3454 .items = {
3455 { "Mic/Line", 0x0 },
3456 { "CD", 0x4 },
3457 { "Headphone", 0x2 },
3458 { "Mixer", 0x5 },
3459 },
3460 },
3461
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003462};
3463
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003464/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3465 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003466 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003467static struct hda_input_mux alc260_acer_capture_sources[2] = {
3468 {
3469 .num_items = 4,
3470 .items = {
3471 { "Mic", 0x0 },
3472 { "Line", 0x2 },
3473 { "CD", 0x4 },
3474 { "Headphone", 0x5 },
3475 },
3476 },
3477 {
3478 .num_items = 5,
3479 .items = {
3480 { "Mic", 0x0 },
3481 { "Line", 0x2 },
3482 { "CD", 0x4 },
3483 { "Headphone", 0x6 },
3484 { "Mixer", 0x5 },
3485 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003486 },
3487};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003488/*
3489 * This is just place-holder, so there's something for alc_build_pcms to look
3490 * at when it calculates the maximum number of channels. ALC260 has no mixer
3491 * element which allows changing the channel mode, so the verb list is
3492 * never used.
3493 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003494static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003495 { 2, NULL },
3496};
3497
Kailang Yangdf694da2005-12-05 19:42:22 +01003498
3499/* Mixer combinations
3500 *
3501 * basic: base_output + input + pc_beep + capture
3502 * HP: base_output + input + capture_alt
3503 * HP_3013: hp_3013 + input + capture
3504 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003505 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003506 */
3507
3508static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003509 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003510 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003511 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3512 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3513 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3514 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3515 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003516};
Kailang Yangdf694da2005-12-05 19:42:22 +01003517
3518static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003519 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3520 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3521 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3522 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3523 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3524 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3525 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3526 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003527 { } /* end */
3528};
3529
Kailang Yangdf694da2005-12-05 19:42:22 +01003530static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3531 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3532 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3533 { } /* end */
3534};
3535
3536static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3537 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3538 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3539 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3540 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3541 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3542 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3543 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3544 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003545 { } /* end */
3546};
3547
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003548/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3549 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3550 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003551static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003552 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003553 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003554 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003555 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3556 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3557 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3558 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003559 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003560 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3561 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3562 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003563 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003564 { } /* end */
3565};
3566
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003567/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3568 * versions of the ALC260 don't act on requests to enable mic bias from NID
3569 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3570 * datasheet doesn't mention this restriction. At this stage it's not clear
3571 * whether this behaviour is intentional or is a hardware bug in chip
3572 * revisions available in early 2006. Therefore for now allow the
3573 * "Headphone Jack Mode" control to span all choices, but if it turns out
3574 * that the lack of mic bias for this NID is intentional we could change the
3575 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3576 *
3577 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3578 * don't appear to make the mic bias available from the "line" jack, even
3579 * though the NID used for this jack (0x14) can supply it. The theory is
3580 * that perhaps Acer have included blocking capacitors between the ALC260
3581 * and the output jack. If this turns out to be the case for all such
3582 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3583 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003584 *
3585 * The C20x Tablet series have a mono internal speaker which is controlled
3586 * via the chip's Mono sum widget and pin complex, so include the necessary
3587 * controls for such models. On models without a "mono speaker" the control
3588 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003589 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003590static struct snd_kcontrol_new alc260_acer_mixer[] = {
3591 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3592 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003593 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003594 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3595 HDA_OUTPUT),
3596 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3597 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003598 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3599 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3601 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3602 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3603 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3604 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3605 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3606 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3607 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3608 { } /* end */
3609};
3610
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003611/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3612 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3613 */
3614static struct snd_kcontrol_new alc260_will_mixer[] = {
3615 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3616 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3618 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3619 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3620 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3621 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3622 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3623 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3624 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3625 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3626 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3627 { } /* end */
3628};
3629
3630/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3631 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3632 */
3633static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3634 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3635 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3637 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3638 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3639 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3640 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3641 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3642 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3643 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3644 { } /* end */
3645};
3646
Kailang Yangdf694da2005-12-05 19:42:22 +01003647/* capture mixer elements */
3648static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003649 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3650 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003651 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3652 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003653 {
3654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003655 /* The multiple "Capture Source" controls confuse alsamixer
3656 * So call somewhat different..
3657 * FIXME: the controls appear in the "playback" view!
3658 */
3659 /* .name = "Capture Source", */
3660 .name = "Input Source",
3661 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003662 .info = alc_mux_enum_info,
3663 .get = alc_mux_enum_get,
3664 .put = alc_mux_enum_put,
3665 },
3666 { } /* end */
3667};
3668
Kailang Yangdf694da2005-12-05 19:42:22 +01003669static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3670 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3671 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3672 {
3673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3674 /* The multiple "Capture Source" controls confuse alsamixer
3675 * So call somewhat different..
3676 * FIXME: the controls appear in the "playback" view!
3677 */
3678 /* .name = "Capture Source", */
3679 .name = "Input Source",
3680 .count = 1,
3681 .info = alc_mux_enum_info,
3682 .get = alc_mux_enum_get,
3683 .put = alc_mux_enum_put,
3684 },
3685 { } /* end */
3686};
3687
3688/*
3689 * initialization verbs
3690 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003691static struct hda_verb alc260_init_verbs[] = {
3692 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003694 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003695 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003696 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003697 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003698 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003699 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003700 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003701 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003702 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003703 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003704 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003705 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003706 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003707 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003708 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003709 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3710 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003711 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003712 /* set connection select to line in (default select for this ADC) */
3713 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003714 /* mute capture amp left and right */
3715 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3716 /* set connection select to line in (default select for this ADC) */
3717 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003718 /* set vol=0 Line-Out mixer amp left and right */
3719 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3720 /* unmute pin widget amp left and right (no gain on this amp) */
3721 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3722 /* set vol=0 HP mixer amp left and right */
3723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3724 /* unmute pin widget amp left and right (no gain on this amp) */
3725 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3726 /* set vol=0 Mono mixer amp left and right */
3727 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3728 /* unmute pin widget amp left and right (no gain on this amp) */
3729 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3730 /* unmute LINE-2 out pin */
3731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003732 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3733 * Line In 2 = 0x03
3734 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003735 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003737 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003739 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003741 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003742 /* mute Front out path */
3743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3744 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3745 /* mute Headphone out path */
3746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3747 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3748 /* mute Mono out path */
3749 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3750 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003751 { }
3752};
3753
Takashi Iwai474167d2006-05-17 17:17:43 +02003754#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003755static struct hda_verb alc260_hp_init_verbs[] = {
3756 /* Headphone and output */
3757 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3758 /* mono output */
3759 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3760 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3761 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3762 /* Mic2 (front panel) pin widget for input and vref at 80% */
3763 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3764 /* Line In pin widget for input */
3765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3766 /* Line-2 pin widget for output */
3767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3768 /* CD pin widget for input */
3769 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3770 /* unmute amp left and right */
3771 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3772 /* set connection select to line in (default select for this ADC) */
3773 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3774 /* unmute Line-Out mixer amp left and right (volume = 0) */
3775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3776 /* mute pin widget amp left and right (no gain on this amp) */
3777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3778 /* unmute HP mixer amp left and right (volume = 0) */
3779 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3780 /* mute pin widget amp left and right (no gain on this amp) */
3781 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003782 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3783 * Line In 2 = 0x03
3784 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003785 /* unmute CD */
3786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3787 /* unmute Line In */
3788 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3789 /* unmute Mic */
3790 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3791 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3792 /* Unmute Front out path */
3793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3795 /* Unmute Headphone out path */
3796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3798 /* Unmute Mono out path */
3799 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3800 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3801 { }
3802};
Takashi Iwai474167d2006-05-17 17:17:43 +02003803#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003804
3805static struct hda_verb alc260_hp_3013_init_verbs[] = {
3806 /* Line out and output */
3807 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3808 /* mono output */
3809 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3810 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3811 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3812 /* Mic2 (front panel) pin widget for input and vref at 80% */
3813 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3814 /* Line In pin widget for input */
3815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3816 /* Headphone pin widget for output */
3817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3818 /* CD pin widget for input */
3819 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3820 /* unmute amp left and right */
3821 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3822 /* set connection select to line in (default select for this ADC) */
3823 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3824 /* unmute Line-Out mixer amp left and right (volume = 0) */
3825 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3826 /* mute pin widget amp left and right (no gain on this amp) */
3827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3828 /* unmute HP mixer amp left and right (volume = 0) */
3829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3830 /* mute pin widget amp left and right (no gain on this amp) */
3831 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003832 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3833 * Line In 2 = 0x03
3834 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003835 /* unmute CD */
3836 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3837 /* unmute Line In */
3838 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3839 /* unmute Mic */
3840 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3841 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3842 /* Unmute Front out path */
3843 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3845 /* Unmute Headphone out path */
3846 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3847 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3848 /* Unmute Mono out path */
3849 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3850 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3851 { }
3852};
3853
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003854/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003855 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3856 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003857 */
3858static struct hda_verb alc260_fujitsu_init_verbs[] = {
3859 /* Disable all GPIOs */
3860 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3861 /* Internal speaker is connected to headphone pin */
3862 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3863 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3864 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003865 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3866 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3867 /* Ensure all other unused pins are disabled and muted. */
3868 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3869 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003870 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003871 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003872 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003873 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3875 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003876
Jonathan Woithef7ace402006-02-28 11:46:14 +01003877 /* Disable digital (SPDIF) pins */
3878 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3879 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003880
Jonathan Woithef7ace402006-02-28 11:46:14 +01003881 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3882 * when acting as an output.
3883 */
3884 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3885
3886 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003887 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3892 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3893 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3894 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3895 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003896
Jonathan Woithef7ace402006-02-28 11:46:14 +01003897 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3898 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3899 /* Unmute Line1 pin widget output buffer since it starts as an output.
3900 * If the pin mode is changed by the user the pin mode control will
3901 * take care of enabling the pin's input/output buffers as needed.
3902 * Therefore there's no need to enable the input buffer at this
3903 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003904 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003906 /* Unmute input buffer of pin widget used for Line-in (no equiv
3907 * mixer ctrl)
3908 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003909 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003910
Jonathan Woithef7ace402006-02-28 11:46:14 +01003911 /* Mute capture amp left and right */
3912 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3913 /* Set ADC connection select to match default mixer setting - line
3914 * in (on mic1 pin)
3915 */
3916 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003917
Jonathan Woithef7ace402006-02-28 11:46:14 +01003918 /* Do the same for the second ADC: mute capture input amp and
3919 * set ADC connection to line in (on mic1 pin)
3920 */
3921 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3922 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003923
Jonathan Woithef7ace402006-02-28 11:46:14 +01003924 /* Mute all inputs to mixer widget (even unconnected ones) */
3925 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3926 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003933
3934 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003935};
3936
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003937/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3938 * similar laptops (adapted from Fujitsu init verbs).
3939 */
3940static struct hda_verb alc260_acer_init_verbs[] = {
3941 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3942 * the headphone jack. Turn this on and rely on the standard mute
3943 * methods whenever the user wants to turn these outputs off.
3944 */
3945 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3946 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3947 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3948 /* Internal speaker/Headphone jack is connected to Line-out pin */
3949 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3950 /* Internal microphone/Mic jack is connected to Mic1 pin */
3951 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3952 /* Line In jack is connected to Line1 pin */
3953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003954 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3955 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003956 /* Ensure all other unused pins are disabled and muted. */
3957 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3958 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003959 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3960 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3963 /* Disable digital (SPDIF) pins */
3964 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3965 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3966
3967 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3968 * bus when acting as outputs.
3969 */
3970 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3971 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3972
3973 /* Start with output sum widgets muted and their output gains at min */
3974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3976 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3978 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3979 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3980 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3981 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3982 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3983
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003984 /* Unmute Line-out pin widget amp left and right
3985 * (no equiv mixer ctrl)
3986 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003987 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003988 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3989 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003990 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3991 * inputs. If the pin mode is changed by the user the pin mode control
3992 * will take care of enabling the pin's input/output buffers as needed.
3993 * Therefore there's no need to enable the input buffer at this
3994 * stage.
3995 */
3996 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3997 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3998
3999 /* Mute capture amp left and right */
4000 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4001 /* Set ADC connection select to match default mixer setting - mic
4002 * (on mic1 pin)
4003 */
4004 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4005
4006 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004007 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004008 */
4009 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004010 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004011
4012 /* Mute all inputs to mixer widget (even unconnected ones) */
4013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4014 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4021
4022 { }
4023};
4024
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004025static struct hda_verb alc260_will_verbs[] = {
4026 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4027 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4028 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4029 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4030 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4031 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4032 {}
4033};
4034
4035static struct hda_verb alc260_replacer_672v_verbs[] = {
4036 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4037 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4038 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4039
4040 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4041 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4042 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4043
4044 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4045 {}
4046};
4047
4048/* toggle speaker-output according to the hp-jack state */
4049static void alc260_replacer_672v_automute(struct hda_codec *codec)
4050{
4051 unsigned int present;
4052
4053 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4054 present = snd_hda_codec_read(codec, 0x0f, 0,
4055 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4056 if (present) {
4057 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4058 snd_hda_codec_write(codec, 0x0f, 0,
4059 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4060 } else {
4061 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4062 snd_hda_codec_write(codec, 0x0f, 0,
4063 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4064 }
4065}
4066
4067static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4068 unsigned int res)
4069{
4070 if ((res >> 26) == ALC880_HP_EVENT)
4071 alc260_replacer_672v_automute(codec);
4072}
4073
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004074/* Test configuration for debugging, modelled after the ALC880 test
4075 * configuration.
4076 */
4077#ifdef CONFIG_SND_DEBUG
4078static hda_nid_t alc260_test_dac_nids[1] = {
4079 0x02,
4080};
4081static hda_nid_t alc260_test_adc_nids[2] = {
4082 0x04, 0x05,
4083};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004084/* For testing the ALC260, each input MUX needs its own definition since
4085 * the signal assignments are different. This assumes that the first ADC
4086 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004087 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004088static struct hda_input_mux alc260_test_capture_sources[2] = {
4089 {
4090 .num_items = 7,
4091 .items = {
4092 { "MIC1 pin", 0x0 },
4093 { "MIC2 pin", 0x1 },
4094 { "LINE1 pin", 0x2 },
4095 { "LINE2 pin", 0x3 },
4096 { "CD pin", 0x4 },
4097 { "LINE-OUT pin", 0x5 },
4098 { "HP-OUT pin", 0x6 },
4099 },
4100 },
4101 {
4102 .num_items = 8,
4103 .items = {
4104 { "MIC1 pin", 0x0 },
4105 { "MIC2 pin", 0x1 },
4106 { "LINE1 pin", 0x2 },
4107 { "LINE2 pin", 0x3 },
4108 { "CD pin", 0x4 },
4109 { "Mixer", 0x5 },
4110 { "LINE-OUT pin", 0x6 },
4111 { "HP-OUT pin", 0x7 },
4112 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004113 },
4114};
4115static struct snd_kcontrol_new alc260_test_mixer[] = {
4116 /* Output driver widgets */
4117 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4118 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4119 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4120 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4121 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4122 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4123
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004124 /* Modes for retasking pin widgets
4125 * Note: the ALC260 doesn't seem to act on requests to enable mic
4126 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4127 * mention this restriction. At this stage it's not clear whether
4128 * this behaviour is intentional or is a hardware bug in chip
4129 * revisions available at least up until early 2006. Therefore for
4130 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4131 * choices, but if it turns out that the lack of mic bias for these
4132 * NIDs is intentional we could change their modes from
4133 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4134 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004135 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4136 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4137 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4138 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4139 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4140 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4141
4142 /* Loopback mixer controls */
4143 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4144 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4145 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4146 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4147 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4148 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4149 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4150 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4151 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4152 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4153 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4154 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4155 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4156 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4157 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4158 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004159
4160 /* Controls for GPIO pins, assuming they are configured as outputs */
4161 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4162 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4163 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4164 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4165
Jonathan Woithe92621f12006-02-28 11:47:47 +01004166 /* Switches to allow the digital IO pins to be enabled. The datasheet
4167 * is ambigious as to which NID is which; testing on laptops which
4168 * make this output available should provide clarification.
4169 */
4170 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4171 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4172
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004173 { } /* end */
4174};
4175static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004176 /* Enable all GPIOs as outputs with an initial value of 0 */
4177 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4178 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4179 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4180
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004181 /* Enable retasking pins as output, initially without power amp */
4182 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4183 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4186 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4187 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4188
Jonathan Woithe92621f12006-02-28 11:47:47 +01004189 /* Disable digital (SPDIF) pins initially, but users can enable
4190 * them via a mixer switch. In the case of SPDIF-out, this initverb
4191 * payload also sets the generation to 0, output to be in "consumer"
4192 * PCM format, copyright asserted, no pre-emphasis and no validity
4193 * control.
4194 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004195 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4196 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4197
Jonathan Woithef7ace402006-02-28 11:46:14 +01004198 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004199 * OUT1 sum bus when acting as an output.
4200 */
4201 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4202 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4203 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4204 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4205
4206 /* Start with output sum widgets muted and their output gains at min */
4207 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4208 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4211 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4212 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4213 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4214 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4215 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4216
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004217 /* Unmute retasking pin widget output buffers since the default
4218 * state appears to be output. As the pin mode is changed by the
4219 * user the pin mode control will take care of enabling the pin's
4220 * input/output buffers as needed.
4221 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004222 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4223 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4226 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4227 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4228 /* Also unmute the mono-out pin widget */
4229 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4230
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004231 /* Mute capture amp left and right */
4232 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004233 /* Set ADC connection select to match default mixer setting (mic1
4234 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004235 */
4236 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4237
4238 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004239 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004240 */
4241 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4242 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4243
4244 /* Mute all inputs to mixer widget (even unconnected ones) */
4245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4253
4254 { }
4255};
4256#endif
4257
Linus Torvalds1da177e2005-04-16 15:20:36 -07004258static struct hda_pcm_stream alc260_pcm_analog_playback = {
4259 .substreams = 1,
4260 .channels_min = 2,
4261 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004262};
4263
4264static struct hda_pcm_stream alc260_pcm_analog_capture = {
4265 .substreams = 1,
4266 .channels_min = 2,
4267 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004268};
4269
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004270#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4271#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4272
Kailang Yangdf694da2005-12-05 19:42:22 +01004273/*
4274 * for BIOS auto-configuration
4275 */
4276
4277static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4278 const char *pfx)
4279{
4280 hda_nid_t nid_vol;
4281 unsigned long vol_val, sw_val;
4282 char name[32];
4283 int err;
4284
4285 if (nid >= 0x0f && nid < 0x11) {
4286 nid_vol = nid - 0x7;
4287 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4288 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4289 } else if (nid == 0x11) {
4290 nid_vol = nid - 0x7;
4291 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4292 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4293 } else if (nid >= 0x12 && nid <= 0x15) {
4294 nid_vol = 0x08;
4295 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4296 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4297 } else
4298 return 0; /* N/A */
4299
4300 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004301 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4302 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004303 return err;
4304 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004305 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4306 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004307 return err;
4308 return 1;
4309}
4310
4311/* add playback controls from the parsed DAC table */
4312static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4313 const struct auto_pin_cfg *cfg)
4314{
4315 hda_nid_t nid;
4316 int err;
4317
4318 spec->multiout.num_dacs = 1;
4319 spec->multiout.dac_nids = spec->private_dac_nids;
4320 spec->multiout.dac_nids[0] = 0x02;
4321
4322 nid = cfg->line_out_pins[0];
4323 if (nid) {
4324 err = alc260_add_playback_controls(spec, nid, "Front");
4325 if (err < 0)
4326 return err;
4327 }
4328
Takashi Iwai82bc9552006-03-21 11:24:42 +01004329 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004330 if (nid) {
4331 err = alc260_add_playback_controls(spec, nid, "Speaker");
4332 if (err < 0)
4333 return err;
4334 }
4335
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004336 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004337 if (nid) {
4338 err = alc260_add_playback_controls(spec, nid, "Headphone");
4339 if (err < 0)
4340 return err;
4341 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004342 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004343}
4344
4345/* create playback/capture controls for input pins */
4346static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4347 const struct auto_pin_cfg *cfg)
4348{
Kailang Yangdf694da2005-12-05 19:42:22 +01004349 struct hda_input_mux *imux = &spec->private_imux;
4350 int i, err, idx;
4351
4352 for (i = 0; i < AUTO_PIN_LAST; i++) {
4353 if (cfg->input_pins[i] >= 0x12) {
4354 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004355 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004356 auto_pin_cfg_labels[i], idx,
4357 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004358 if (err < 0)
4359 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004360 imux->items[imux->num_items].label =
4361 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004362 imux->items[imux->num_items].index = idx;
4363 imux->num_items++;
4364 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004365 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004366 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004367 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004368 auto_pin_cfg_labels[i], idx,
4369 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004370 if (err < 0)
4371 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004372 imux->items[imux->num_items].label =
4373 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004374 imux->items[imux->num_items].index = idx;
4375 imux->num_items++;
4376 }
4377 }
4378 return 0;
4379}
4380
4381static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4382 hda_nid_t nid, int pin_type,
4383 int sel_idx)
4384{
4385 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004386 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4387 pin_type);
4388 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4389 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004390 /* need the manual connection? */
4391 if (nid >= 0x12) {
4392 int idx = nid - 0x12;
4393 snd_hda_codec_write(codec, idx + 0x0b, 0,
4394 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004395 }
4396}
4397
4398static void alc260_auto_init_multi_out(struct hda_codec *codec)
4399{
4400 struct alc_spec *spec = codec->spec;
4401 hda_nid_t nid;
4402
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004403 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004404 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004405 if (nid) {
4406 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4407 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4408 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004409
Takashi Iwai82bc9552006-03-21 11:24:42 +01004410 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004411 if (nid)
4412 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4413
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004414 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004415 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004416 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004417}
Kailang Yangdf694da2005-12-05 19:42:22 +01004418
4419#define ALC260_PIN_CD_NID 0x16
4420static void alc260_auto_init_analog_input(struct hda_codec *codec)
4421{
4422 struct alc_spec *spec = codec->spec;
4423 int i;
4424
4425 for (i = 0; i < AUTO_PIN_LAST; i++) {
4426 hda_nid_t nid = spec->autocfg.input_pins[i];
4427 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004428 snd_hda_codec_write(codec, nid, 0,
4429 AC_VERB_SET_PIN_WIDGET_CONTROL,
4430 i <= AUTO_PIN_FRONT_MIC ?
4431 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004432 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004433 snd_hda_codec_write(codec, nid, 0,
4434 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004435 AMP_OUT_MUTE);
4436 }
4437 }
4438}
4439
4440/*
4441 * generic initialization of ADC, input mixers and output mixers
4442 */
4443static struct hda_verb alc260_volume_init_verbs[] = {
4444 /*
4445 * Unmute ADC0-1 and set the default input to mic-in
4446 */
4447 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4448 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4449 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4450 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4451
4452 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4453 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004454 * Note: PASD motherboards uses the Line In 2 as the input for
4455 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004456 */
4457 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4463
4464 /*
4465 * Set up output mixers (0x08 - 0x0a)
4466 */
4467 /* set vol=0 to output mixers */
4468 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4471 /* set up input amps for analog loopback */
4472 /* Amp Indices: DAC = 0, mixer = 1 */
4473 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4474 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4475 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4476 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4477 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4478 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4479
4480 { }
4481};
4482
4483static int alc260_parse_auto_config(struct hda_codec *codec)
4484{
4485 struct alc_spec *spec = codec->spec;
4486 unsigned int wcap;
4487 int err;
4488 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4489
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004490 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4491 alc260_ignore);
4492 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004493 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004494 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4495 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004496 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004497 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004498 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004499 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4500 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004501 return err;
4502
4503 spec->multiout.max_channels = 2;
4504
4505 if (spec->autocfg.dig_out_pin)
4506 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4507 if (spec->kctl_alloc)
4508 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4509
4510 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4511
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004512 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004513 spec->input_mux = &spec->private_imux;
4514
4515 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004516 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004517 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4518 if (wcap != AC_WID_AUD_IN) {
4519 spec->adc_nids = alc260_adc_nids_alt;
4520 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4521 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004522 } else {
4523 spec->adc_nids = alc260_adc_nids;
4524 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4525 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004526 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004527 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004528
4529 return 1;
4530}
4531
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004532/* additional initialization for auto-configuration model */
4533static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004534{
Kailang Yangdf694da2005-12-05 19:42:22 +01004535 alc260_auto_init_multi_out(codec);
4536 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004537}
4538
4539/*
4540 * ALC260 configurations
4541 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004542static const char *alc260_models[ALC260_MODEL_LAST] = {
4543 [ALC260_BASIC] = "basic",
4544 [ALC260_HP] = "hp",
4545 [ALC260_HP_3013] = "hp-3013",
4546 [ALC260_FUJITSU_S702X] = "fujitsu",
4547 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004548 [ALC260_WILL] = "will",
4549 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004550#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004551 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004552#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004553 [ALC260_AUTO] = "auto",
4554};
4555
4556static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004557 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004558 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004559 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004560 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004561 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4562 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4563 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4564 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4565 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4566 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4567 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4568 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4569 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4570 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4571 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4572 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004573 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4574 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004575 {}
4576};
4577
Kailang Yangdf694da2005-12-05 19:42:22 +01004578static struct alc_config_preset alc260_presets[] = {
4579 [ALC260_BASIC] = {
4580 .mixers = { alc260_base_output_mixer,
4581 alc260_input_mixer,
4582 alc260_pc_beep_mixer,
4583 alc260_capture_mixer },
4584 .init_verbs = { alc260_init_verbs },
4585 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4586 .dac_nids = alc260_dac_nids,
4587 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4588 .adc_nids = alc260_adc_nids,
4589 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4590 .channel_mode = alc260_modes,
4591 .input_mux = &alc260_capture_source,
4592 },
4593 [ALC260_HP] = {
4594 .mixers = { alc260_base_output_mixer,
4595 alc260_input_mixer,
4596 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004597 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004598 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4599 .dac_nids = alc260_dac_nids,
4600 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4601 .adc_nids = alc260_hp_adc_nids,
4602 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4603 .channel_mode = alc260_modes,
4604 .input_mux = &alc260_capture_source,
4605 },
4606 [ALC260_HP_3013] = {
4607 .mixers = { alc260_hp_3013_mixer,
4608 alc260_input_mixer,
4609 alc260_capture_alt_mixer },
4610 .init_verbs = { alc260_hp_3013_init_verbs },
4611 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4612 .dac_nids = alc260_dac_nids,
4613 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4614 .adc_nids = alc260_hp_adc_nids,
4615 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4616 .channel_mode = alc260_modes,
4617 .input_mux = &alc260_capture_source,
4618 },
4619 [ALC260_FUJITSU_S702X] = {
4620 .mixers = { alc260_fujitsu_mixer,
4621 alc260_capture_mixer },
4622 .init_verbs = { alc260_fujitsu_init_verbs },
4623 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4624 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004625 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4626 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004627 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4628 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004629 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4630 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004631 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004632 [ALC260_ACER] = {
4633 .mixers = { alc260_acer_mixer,
4634 alc260_capture_mixer },
4635 .init_verbs = { alc260_acer_init_verbs },
4636 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4637 .dac_nids = alc260_dac_nids,
4638 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4639 .adc_nids = alc260_dual_adc_nids,
4640 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4641 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004642 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4643 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004644 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004645 [ALC260_WILL] = {
4646 .mixers = { alc260_will_mixer,
4647 alc260_capture_mixer },
4648 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4649 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4650 .dac_nids = alc260_dac_nids,
4651 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4652 .adc_nids = alc260_adc_nids,
4653 .dig_out_nid = ALC260_DIGOUT_NID,
4654 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4655 .channel_mode = alc260_modes,
4656 .input_mux = &alc260_capture_source,
4657 },
4658 [ALC260_REPLACER_672V] = {
4659 .mixers = { alc260_replacer_672v_mixer,
4660 alc260_capture_mixer },
4661 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4662 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4663 .dac_nids = alc260_dac_nids,
4664 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4665 .adc_nids = alc260_adc_nids,
4666 .dig_out_nid = ALC260_DIGOUT_NID,
4667 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4668 .channel_mode = alc260_modes,
4669 .input_mux = &alc260_capture_source,
4670 .unsol_event = alc260_replacer_672v_unsol_event,
4671 .init_hook = alc260_replacer_672v_automute,
4672 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004673#ifdef CONFIG_SND_DEBUG
4674 [ALC260_TEST] = {
4675 .mixers = { alc260_test_mixer,
4676 alc260_capture_mixer },
4677 .init_verbs = { alc260_test_init_verbs },
4678 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4679 .dac_nids = alc260_test_dac_nids,
4680 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4681 .adc_nids = alc260_test_adc_nids,
4682 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4683 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004684 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4685 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004686 },
4687#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004688};
4689
Linus Torvalds1da177e2005-04-16 15:20:36 -07004690static int patch_alc260(struct hda_codec *codec)
4691{
4692 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004693 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004694
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004695 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004696 if (spec == NULL)
4697 return -ENOMEM;
4698
4699 codec->spec = spec;
4700
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004701 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4702 alc260_models,
4703 alc260_cfg_tbl);
4704 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004705 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4706 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004707 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004708 }
4709
Kailang Yangdf694da2005-12-05 19:42:22 +01004710 if (board_config == ALC260_AUTO) {
4711 /* automatic parse from the BIOS config */
4712 err = alc260_parse_auto_config(codec);
4713 if (err < 0) {
4714 alc_free(codec);
4715 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004716 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004717 printk(KERN_INFO
4718 "hda_codec: Cannot set up configuration "
4719 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004720 board_config = ALC260_BASIC;
4721 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004722 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004723
Kailang Yangdf694da2005-12-05 19:42:22 +01004724 if (board_config != ALC260_AUTO)
4725 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004726
4727 spec->stream_name_analog = "ALC260 Analog";
4728 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4729 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4730
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004731 spec->stream_name_digital = "ALC260 Digital";
4732 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4733 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4734
Linus Torvalds1da177e2005-04-16 15:20:36 -07004735 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004736 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004737 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004738
4739 return 0;
4740}
4741
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004742
Linus Torvalds1da177e2005-04-16 15:20:36 -07004743/*
4744 * ALC882 support
4745 *
4746 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4747 * configuration. Each pin widget can choose any input DACs and a mixer.
4748 * Each ADC is connected from a mixer of all inputs. This makes possible
4749 * 6-channel independent captures.
4750 *
4751 * In addition, an independent DAC for the multi-playback (not used in this
4752 * driver yet).
4753 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004754#define ALC882_DIGOUT_NID 0x06
4755#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004756
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004757static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004758 { 8, NULL }
4759};
4760
4761static hda_nid_t alc882_dac_nids[4] = {
4762 /* front, rear, clfe, rear_surr */
4763 0x02, 0x03, 0x04, 0x05
4764};
4765
Kailang Yangdf694da2005-12-05 19:42:22 +01004766/* identical with ALC880 */
4767#define alc882_adc_nids alc880_adc_nids
4768#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004769
4770/* input MUX */
4771/* FIXME: should be a matrix-type input source selection */
4772
4773static struct hda_input_mux alc882_capture_source = {
4774 .num_items = 4,
4775 .items = {
4776 { "Mic", 0x0 },
4777 { "Front Mic", 0x1 },
4778 { "Line", 0x2 },
4779 { "CD", 0x4 },
4780 },
4781};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004782#define alc882_mux_enum_info alc_mux_enum_info
4783#define alc882_mux_enum_get alc_mux_enum_get
4784
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004785static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4786 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004787{
4788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4789 struct alc_spec *spec = codec->spec;
4790 const struct hda_input_mux *imux = spec->input_mux;
4791 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4792 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4793 hda_nid_t nid = capture_mixers[adc_idx];
4794 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4795 unsigned int i, idx;
4796
4797 idx = ucontrol->value.enumerated.item[0];
4798 if (idx >= imux->num_items)
4799 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004800 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004801 return 0;
4802 for (i = 0; i < imux->num_items; i++) {
4803 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4804 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4805 v | (imux->items[i].index << 8));
4806 }
4807 *cur_val = idx;
4808 return 1;
4809}
4810
Kailang Yangdf694da2005-12-05 19:42:22 +01004811/*
Kailang Yang272a5272007-05-14 11:00:38 +02004812 * 2ch mode
4813 */
4814static struct hda_verb alc882_3ST_ch2_init[] = {
4815 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4816 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4817 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4818 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4819 { } /* end */
4820};
4821
4822/*
4823 * 6ch mode
4824 */
4825static struct hda_verb alc882_3ST_ch6_init[] = {
4826 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4827 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4828 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4829 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4830 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4831 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4832 { } /* end */
4833};
4834
4835static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4836 { 2, alc882_3ST_ch2_init },
4837 { 6, alc882_3ST_ch6_init },
4838};
4839
4840/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004841 * 6ch mode
4842 */
4843static struct hda_verb alc882_sixstack_ch6_init[] = {
4844 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4845 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4846 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4847 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4848 { } /* end */
4849};
4850
4851/*
4852 * 8ch mode
4853 */
4854static struct hda_verb alc882_sixstack_ch8_init[] = {
4855 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4856 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4857 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4858 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4859 { } /* end */
4860};
4861
4862static struct hda_channel_mode alc882_sixstack_modes[2] = {
4863 { 6, alc882_sixstack_ch6_init },
4864 { 8, alc882_sixstack_ch8_init },
4865};
4866
Linus Torvalds1da177e2005-04-16 15:20:36 -07004867/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4868 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4869 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004870static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004871 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004872 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004873 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004874 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004875 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4876 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004877 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4878 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004879 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004880 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004887 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004888 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4889 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004890 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004891 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4892 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4893 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004894 { } /* end */
4895};
4896
Kailang Yangbdd148a2007-05-08 15:19:08 +02004897static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4899 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4900 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4901 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4902 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4903 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4905 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, 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),
4909 { } /* end */
4910};
4911
Kailang Yang272a5272007-05-14 11:00:38 +02004912static struct snd_kcontrol_new alc882_targa_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_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4923 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4924 { } /* end */
4925};
4926
4927/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4928 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4929 */
4930static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4931 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4932 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4934 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4935 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4936 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4937 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4938 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4939 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4940 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4943 { } /* end */
4944};
4945
Kailang Yangdf694da2005-12-05 19:42:22 +01004946static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4947 {
4948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4949 .name = "Channel Mode",
4950 .info = alc_ch_mode_info,
4951 .get = alc_ch_mode_get,
4952 .put = alc_ch_mode_put,
4953 },
4954 { } /* end */
4955};
4956
Linus Torvalds1da177e2005-04-16 15:20:36 -07004957static struct hda_verb alc882_init_verbs[] = {
4958 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004962 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4964 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004966 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4969 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004970 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004971 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4972 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4973 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004974
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004975 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004978 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004979 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004980 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004983 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004984 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004985 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004986 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004987 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004988 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004989 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004990 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004991 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004992 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004993 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4994 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004995 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4997 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004998 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004999 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5000 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5001 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5002 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5003 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005004 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005005 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005006
5007 /* FIXME: use matrix-type input source selection */
5008 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5009 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005010 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005014 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5018 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005019 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5024 /* ADC1: mute amp left and right */
5025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005026 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005027 /* ADC2: mute amp left and right */
5028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005029 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005030 /* ADC3: mute amp left and right */
5031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005032 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005033
5034 { }
5035};
5036
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005037static struct hda_verb alc882_eapd_verbs[] = {
5038 /* change to EAPD mode */
5039 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005040 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005041 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005042};
5043
Tobin Davis9102cd12006-12-15 10:02:12 +01005044/* Mac Pro test */
5045static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5046 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5047 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5048 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5051 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5052 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5053 { } /* end */
5054};
5055
5056static struct hda_verb alc882_macpro_init_verbs[] = {
5057 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5061 /* Front Pin: output 0 (0x0c) */
5062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5064 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5065 /* Front Mic pin: input vref at 80% */
5066 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5067 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5068 /* Speaker: output */
5069 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5070 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5071 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5072 /* Headphone output (output 0 - 0x0c) */
5073 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5075 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5076
5077 /* FIXME: use matrix-type input source selection */
5078 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5079 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5080 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5084 /* Input mixer2 */
5085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5087 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5089 /* Input mixer3 */
5090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5094 /* ADC1: mute amp left and right */
5095 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5096 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5097 /* ADC2: mute amp left and right */
5098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5099 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5100 /* ADC3: mute amp left and right */
5101 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5102 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5103
5104 { }
5105};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005106
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005107/* iMac 24 mixer. */
5108static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5109 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5110 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5111 { } /* end */
5112};
5113
5114/* iMac 24 init verbs. */
5115static struct hda_verb alc885_imac24_init_verbs[] = {
5116 /* Internal speakers: output 0 (0x0c) */
5117 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5118 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5119 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5120 /* Internal speakers: output 0 (0x0c) */
5121 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5122 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5123 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5124 /* Headphone: output 0 (0x0c) */
5125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5126 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5127 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5128 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5129 /* Front Mic: input vref at 80% */
5130 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5131 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5132 { }
5133};
5134
5135/* Toggle speaker-output according to the hp-jack state */
5136static void alc885_imac24_automute(struct hda_codec *codec)
5137{
5138 unsigned int present;
5139
5140 present = snd_hda_codec_read(codec, 0x14, 0,
5141 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5142 snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
5143 0x80, present ? 0x80 : 0);
5144 snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
5145 0x80, present ? 0x80 : 0);
5146 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
5147 0x80, present ? 0x80 : 0);
5148 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
5149 0x80, present ? 0x80 : 0);
5150}
5151
5152/* Processes unsolicited events. */
5153static void alc885_imac24_unsol_event(struct hda_codec *codec,
5154 unsigned int res)
5155{
5156 /* Headphone insertion or removal. */
5157 if ((res >> 26) == ALC880_HP_EVENT)
5158 alc885_imac24_automute(codec);
5159}
5160
Kailang Yang272a5272007-05-14 11:00:38 +02005161static struct hda_verb alc882_targa_verbs[] = {
5162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5164
5165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5166 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5167
5168 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5169 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5170 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5171
5172 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5173 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5174 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5175 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5176 { } /* end */
5177};
5178
5179/* toggle speaker-output according to the hp-jack state */
5180static void alc882_targa_automute(struct hda_codec *codec)
5181{
5182 unsigned int present;
5183
5184 present = snd_hda_codec_read(codec, 0x14, 0,
5185 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5186 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5187 0x80, present ? 0x80 : 0);
5188 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5189 0x80, present ? 0x80 : 0);
5190 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5191}
5192
5193static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5194{
5195 /* Looks like the unsol event is incompatible with the standard
5196 * definition. 4bit tag is placed at 26 bit!
5197 */
5198 if (((res >> 26) == ALC880_HP_EVENT)) {
5199 alc882_targa_automute(codec);
5200 }
5201}
5202
5203static struct hda_verb alc882_asus_a7j_verbs[] = {
5204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5206
5207 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5209 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5210
5211 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5212 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5213 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5214
5215 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5216 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5217 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5218 { } /* end */
5219};
5220
Tobin Davis9102cd12006-12-15 10:02:12 +01005221static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5222{
5223 unsigned int gpiostate, gpiomask, gpiodir;
5224
5225 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5226 AC_VERB_GET_GPIO_DATA, 0);
5227
5228 if (!muted)
5229 gpiostate |= (1 << pin);
5230 else
5231 gpiostate &= ~(1 << pin);
5232
5233 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5234 AC_VERB_GET_GPIO_MASK, 0);
5235 gpiomask |= (1 << pin);
5236
5237 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5238 AC_VERB_GET_GPIO_DIRECTION, 0);
5239 gpiodir |= (1 << pin);
5240
5241
5242 snd_hda_codec_write(codec, codec->afg, 0,
5243 AC_VERB_SET_GPIO_MASK, gpiomask);
5244 snd_hda_codec_write(codec, codec->afg, 0,
5245 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5246
5247 msleep(1);
5248
5249 snd_hda_codec_write(codec, codec->afg, 0,
5250 AC_VERB_SET_GPIO_DATA, gpiostate);
5251}
5252
Kailang Yangdf694da2005-12-05 19:42:22 +01005253/*
5254 * generic initialization of ADC, input mixers and output mixers
5255 */
5256static struct hda_verb alc882_auto_init_verbs[] = {
5257 /*
5258 * Unmute ADC0-2 and set the default input to mic-in
5259 */
5260 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5262 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5264 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5266
5267 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5268 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005269 * Note: PASD motherboards uses the Line In 2 as the input for
5270 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005271 */
5272 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5278
5279 /*
5280 * Set up output mixers (0x0c - 0x0f)
5281 */
5282 /* set vol=0 to output mixers */
5283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5286 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5287 /* set up input amps for analog loopback */
5288 /* Amp Indices: DAC = 0, mixer = 1 */
5289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5291 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5292 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5296 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5297 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5298 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5299
5300 /* FIXME: use matrix-type input source selection */
5301 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5302 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5307 /* Input mixer2 */
5308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5312 /* Input mixer3 */
5313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5317
5318 { }
5319};
5320
5321/* capture mixer elements */
5322static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5323 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5324 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5325 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5326 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5327 {
5328 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5329 /* The multiple "Capture Source" controls confuse alsamixer
5330 * So call somewhat different..
5331 * FIXME: the controls appear in the "playback" view!
5332 */
5333 /* .name = "Capture Source", */
5334 .name = "Input Source",
5335 .count = 2,
5336 .info = alc882_mux_enum_info,
5337 .get = alc882_mux_enum_get,
5338 .put = alc882_mux_enum_put,
5339 },
5340 { } /* end */
5341};
5342
5343static struct snd_kcontrol_new alc882_capture_mixer[] = {
5344 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5345 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5346 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5347 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5348 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5349 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5350 {
5351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5352 /* The multiple "Capture Source" controls confuse alsamixer
5353 * So call somewhat different..
5354 * FIXME: the controls appear in the "playback" view!
5355 */
5356 /* .name = "Capture Source", */
5357 .name = "Input Source",
5358 .count = 3,
5359 .info = alc882_mux_enum_info,
5360 .get = alc882_mux_enum_get,
5361 .put = alc882_mux_enum_put,
5362 },
5363 { } /* end */
5364};
5365
5366/* pcm configuration: identiacal with ALC880 */
5367#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5368#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5369#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5370#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5371
5372/*
5373 * configuration and preset
5374 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005375static const char *alc882_models[ALC882_MODEL_LAST] = {
5376 [ALC882_3ST_DIG] = "3stack-dig",
5377 [ALC882_6ST_DIG] = "6stack-dig",
5378 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005379 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005380 [ALC885_MACPRO] = "macpro",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005381 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005382 [ALC882_AUTO] = "auto",
5383};
5384
5385static struct snd_pci_quirk alc882_cfg_tbl[] = {
5386 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5387 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5388 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005389 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005390 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005391 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005392 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005393 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005394 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005395 {}
5396};
5397
5398static struct alc_config_preset alc882_presets[] = {
5399 [ALC882_3ST_DIG] = {
5400 .mixers = { alc882_base_mixer },
5401 .init_verbs = { alc882_init_verbs },
5402 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5403 .dac_nids = alc882_dac_nids,
5404 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005405 .dig_in_nid = ALC882_DIGIN_NID,
5406 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5407 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005408 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005409 .input_mux = &alc882_capture_source,
5410 },
5411 [ALC882_6ST_DIG] = {
5412 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5413 .init_verbs = { alc882_init_verbs },
5414 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5415 .dac_nids = alc882_dac_nids,
5416 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005417 .dig_in_nid = ALC882_DIGIN_NID,
5418 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5419 .channel_mode = alc882_sixstack_modes,
5420 .input_mux = &alc882_capture_source,
5421 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005422 [ALC882_ARIMA] = {
5423 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5424 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5425 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5426 .dac_nids = alc882_dac_nids,
5427 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5428 .channel_mode = alc882_sixstack_modes,
5429 .input_mux = &alc882_capture_source,
5430 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005431 [ALC882_W2JC] = {
5432 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5433 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5434 alc880_gpio1_init_verbs },
5435 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5436 .dac_nids = alc882_dac_nids,
5437 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5438 .channel_mode = alc880_threestack_modes,
5439 .need_dac_fix = 1,
5440 .input_mux = &alc882_capture_source,
5441 .dig_out_nid = ALC882_DIGOUT_NID,
5442 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005443 [ALC885_MACPRO] = {
5444 .mixers = { alc882_macpro_mixer },
5445 .init_verbs = { alc882_macpro_init_verbs },
5446 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5447 .dac_nids = alc882_dac_nids,
5448 .dig_out_nid = ALC882_DIGOUT_NID,
5449 .dig_in_nid = ALC882_DIGIN_NID,
5450 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5451 .channel_mode = alc882_ch_modes,
5452 .input_mux = &alc882_capture_source,
5453 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005454 [ALC885_IMAC24] = {
5455 .mixers = { alc885_imac24_mixer },
5456 .init_verbs = { alc885_imac24_init_verbs },
5457 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5458 .dac_nids = alc882_dac_nids,
5459 .dig_out_nid = ALC882_DIGOUT_NID,
5460 .dig_in_nid = ALC882_DIGIN_NID,
5461 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5462 .channel_mode = alc882_ch_modes,
5463 .input_mux = &alc882_capture_source,
5464 .unsol_event = alc885_imac24_unsol_event,
5465 .init_hook = alc885_imac24_automute,
5466 },
Kailang Yang272a5272007-05-14 11:00:38 +02005467 [ALC882_TARGA] = {
5468 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5469 alc882_capture_mixer },
5470 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5471 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5472 .dac_nids = alc882_dac_nids,
5473 .dig_out_nid = ALC882_DIGOUT_NID,
5474 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5475 .adc_nids = alc882_adc_nids,
5476 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5477 .channel_mode = alc882_3ST_6ch_modes,
5478 .need_dac_fix = 1,
5479 .input_mux = &alc882_capture_source,
5480 .unsol_event = alc882_targa_unsol_event,
5481 .init_hook = alc882_targa_automute,
5482 },
5483 [ALC882_ASUS_A7J] = {
5484 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5485 alc882_capture_mixer },
5486 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5487 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5488 .dac_nids = alc882_dac_nids,
5489 .dig_out_nid = ALC882_DIGOUT_NID,
5490 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5491 .adc_nids = alc882_adc_nids,
5492 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5493 .channel_mode = alc882_3ST_6ch_modes,
5494 .need_dac_fix = 1,
5495 .input_mux = &alc882_capture_source,
5496 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005497};
5498
5499
5500/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005501 * Pin config fixes
5502 */
5503enum {
5504 PINFIX_ABIT_AW9D_MAX
5505};
5506
5507static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5508 { 0x15, 0x01080104 }, /* side */
5509 { 0x16, 0x01011012 }, /* rear */
5510 { 0x17, 0x01016011 }, /* clfe */
5511 { }
5512};
5513
5514static const struct alc_pincfg *alc882_pin_fixes[] = {
5515 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5516};
5517
5518static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5519 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5520 {}
5521};
5522
5523/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005524 * BIOS auto configuration
5525 */
5526static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5527 hda_nid_t nid, int pin_type,
5528 int dac_idx)
5529{
5530 /* set as output */
5531 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005532 int idx;
5533
Kailang Yangdf694da2005-12-05 19:42:22 +01005534 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5535 idx = 4;
5536 else
5537 idx = spec->multiout.dac_nids[dac_idx] - 2;
5538
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005539 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5540 pin_type);
5541 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5542 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005543 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5544
5545}
5546
5547static void alc882_auto_init_multi_out(struct hda_codec *codec)
5548{
5549 struct alc_spec *spec = codec->spec;
5550 int i;
5551
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005552 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005553 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005554 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005555 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005556 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005557 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005558 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005559 }
5560}
5561
5562static void alc882_auto_init_hp_out(struct hda_codec *codec)
5563{
5564 struct alc_spec *spec = codec->spec;
5565 hda_nid_t pin;
5566
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005567 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005568 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005569 /* use dac 0 */
5570 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005571}
5572
5573#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5574#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5575
5576static void alc882_auto_init_analog_input(struct hda_codec *codec)
5577{
5578 struct alc_spec *spec = codec->spec;
5579 int i;
5580
5581 for (i = 0; i < AUTO_PIN_LAST; i++) {
5582 hda_nid_t nid = spec->autocfg.input_pins[i];
5583 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005584 snd_hda_codec_write(codec, nid, 0,
5585 AC_VERB_SET_PIN_WIDGET_CONTROL,
5586 i <= AUTO_PIN_FRONT_MIC ?
5587 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005588 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005589 snd_hda_codec_write(codec, nid, 0,
5590 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005591 AMP_OUT_MUTE);
5592 }
5593 }
5594}
5595
5596/* almost identical with ALC880 parser... */
5597static int alc882_parse_auto_config(struct hda_codec *codec)
5598{
5599 struct alc_spec *spec = codec->spec;
5600 int err = alc880_parse_auto_config(codec);
5601
5602 if (err < 0)
5603 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005604 else if (err > 0)
5605 /* hack - override the init verbs */
5606 spec->init_verbs[0] = alc882_auto_init_verbs;
5607 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005608}
5609
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005610/* additional initialization for auto-configuration model */
5611static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005612{
Kailang Yangdf694da2005-12-05 19:42:22 +01005613 alc882_auto_init_multi_out(codec);
5614 alc882_auto_init_hp_out(codec);
5615 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005616}
5617
Linus Torvalds1da177e2005-04-16 15:20:36 -07005618static int patch_alc882(struct hda_codec *codec)
5619{
5620 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005621 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005622
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005623 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005624 if (spec == NULL)
5625 return -ENOMEM;
5626
Linus Torvalds1da177e2005-04-16 15:20:36 -07005627 codec->spec = spec;
5628
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005629 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5630 alc882_models,
5631 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005632
Kailang Yangdf694da2005-12-05 19:42:22 +01005633 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005634 /* Pick up systems that don't supply PCI SSID */
5635 switch (codec->subsystem_id) {
5636 case 0x106b0c00: /* Mac Pro */
5637 board_config = ALC885_MACPRO;
5638 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005639 case 0x106b1000: /* iMac 24 */
5640 board_config = ALC885_IMAC24;
5641 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01005642 default:
5643 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5644 "trying auto-probe from BIOS...\n");
5645 board_config = ALC882_AUTO;
5646 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005647 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005648
Takashi Iwaif95474e2007-07-10 00:47:43 +02005649 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5650
Kailang Yangdf694da2005-12-05 19:42:22 +01005651 if (board_config == ALC882_AUTO) {
5652 /* automatic parse from the BIOS config */
5653 err = alc882_parse_auto_config(codec);
5654 if (err < 0) {
5655 alc_free(codec);
5656 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005657 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005658 printk(KERN_INFO
5659 "hda_codec: Cannot set up configuration "
5660 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005661 board_config = ALC882_3ST_DIG;
5662 }
5663 }
5664
5665 if (board_config != ALC882_AUTO)
5666 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005667
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005668 if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
Tobin Davis9102cd12006-12-15 10:02:12 +01005669 alc882_gpio_mute(codec, 0, 0);
5670 alc882_gpio_mute(codec, 1, 0);
5671 }
5672
Linus Torvalds1da177e2005-04-16 15:20:36 -07005673 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005674 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5675 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005676
5677 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005678 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5679 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005680
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005681 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005682 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005683 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005684 /* get type */
5685 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005686 if (wcap != AC_WID_AUD_IN) {
5687 spec->adc_nids = alc882_adc_nids_alt;
5688 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005689 spec->mixers[spec->num_mixers] =
5690 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005691 spec->num_mixers++;
5692 } else {
5693 spec->adc_nids = alc882_adc_nids;
5694 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5695 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5696 spec->num_mixers++;
5697 }
5698 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005699
5700 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005701 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005702 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005703
5704 return 0;
5705}
5706
5707/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005708 * ALC883 support
5709 *
5710 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5711 * configuration. Each pin widget can choose any input DACs and a mixer.
5712 * Each ADC is connected from a mixer of all inputs. This makes possible
5713 * 6-channel independent captures.
5714 *
5715 * In addition, an independent DAC for the multi-playback (not used in this
5716 * driver yet).
5717 */
5718#define ALC883_DIGOUT_NID 0x06
5719#define ALC883_DIGIN_NID 0x0a
5720
5721static hda_nid_t alc883_dac_nids[4] = {
5722 /* front, rear, clfe, rear_surr */
5723 0x02, 0x04, 0x03, 0x05
5724};
5725
5726static hda_nid_t alc883_adc_nids[2] = {
5727 /* ADC1-2 */
5728 0x08, 0x09,
5729};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005730
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005731/* input MUX */
5732/* FIXME: should be a matrix-type input source selection */
5733
5734static struct hda_input_mux alc883_capture_source = {
5735 .num_items = 4,
5736 .items = {
5737 { "Mic", 0x0 },
5738 { "Front Mic", 0x1 },
5739 { "Line", 0x2 },
5740 { "CD", 0x4 },
5741 },
5742};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005743
5744static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5745 .num_items = 2,
5746 .items = {
5747 { "Mic", 0x1 },
5748 { "Line", 0x2 },
5749 },
5750};
5751
Kailang Yang272a5272007-05-14 11:00:38 +02005752static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5753 .num_items = 4,
5754 .items = {
5755 { "Mic", 0x0 },
5756 { "iMic", 0x1 },
5757 { "Line", 0x2 },
5758 { "CD", 0x4 },
5759 },
5760};
5761
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005762#define alc883_mux_enum_info alc_mux_enum_info
5763#define alc883_mux_enum_get alc_mux_enum_get
5764
5765static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5766 struct snd_ctl_elem_value *ucontrol)
5767{
5768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5769 struct alc_spec *spec = codec->spec;
5770 const struct hda_input_mux *imux = spec->input_mux;
5771 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5772 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5773 hda_nid_t nid = capture_mixers[adc_idx];
5774 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5775 unsigned int i, idx;
5776
5777 idx = ucontrol->value.enumerated.item[0];
5778 if (idx >= imux->num_items)
5779 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005780 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005781 return 0;
5782 for (i = 0; i < imux->num_items; i++) {
5783 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5784 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5785 v | (imux->items[i].index << 8));
5786 }
5787 *cur_val = idx;
5788 return 1;
5789}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005790
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005791/*
5792 * 2ch mode
5793 */
5794static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5795 { 2, NULL }
5796};
5797
5798/*
5799 * 2ch mode
5800 */
5801static struct hda_verb alc883_3ST_ch2_init[] = {
5802 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5803 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5804 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5805 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5806 { } /* end */
5807};
5808
5809/*
5810 * 6ch mode
5811 */
5812static struct hda_verb alc883_3ST_ch6_init[] = {
5813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5815 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5816 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5817 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5818 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5819 { } /* end */
5820};
5821
5822static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5823 { 2, alc883_3ST_ch2_init },
5824 { 6, alc883_3ST_ch6_init },
5825};
5826
5827/*
5828 * 6ch mode
5829 */
5830static struct hda_verb alc883_sixstack_ch6_init[] = {
5831 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5832 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5833 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5834 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5835 { } /* end */
5836};
5837
5838/*
5839 * 8ch mode
5840 */
5841static struct hda_verb alc883_sixstack_ch8_init[] = {
5842 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5843 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5844 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5845 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5846 { } /* end */
5847};
5848
5849static struct hda_channel_mode alc883_sixstack_modes[2] = {
5850 { 6, alc883_sixstack_ch6_init },
5851 { 8, alc883_sixstack_ch8_init },
5852};
5853
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005854static struct hda_verb alc883_medion_eapd_verbs[] = {
5855 /* eanable EAPD on medion laptop */
5856 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5857 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5858 { }
5859};
5860
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005861/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5862 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5863 */
5864
5865static struct snd_kcontrol_new alc883_base_mixer[] = {
5866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5867 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5868 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5869 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5870 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5871 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5872 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5873 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5874 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5875 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5876 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005882 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5884 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005885 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005886 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5887 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5888 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5889 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5890 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5891 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5892 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5893 {
5894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5895 /* .name = "Capture Source", */
5896 .name = "Input Source",
5897 .count = 2,
5898 .info = alc883_mux_enum_info,
5899 .get = alc883_mux_enum_get,
5900 .put = alc883_mux_enum_put,
5901 },
5902 { } /* end */
5903};
5904
5905static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5909 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5910 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005914 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005917 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5919 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5920 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5921 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5922 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5923 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5924 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5925 {
5926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5927 /* .name = "Capture Source", */
5928 .name = "Input Source",
5929 .count = 2,
5930 .info = alc883_mux_enum_info,
5931 .get = alc883_mux_enum_get,
5932 .put = alc883_mux_enum_put,
5933 },
5934 { } /* end */
5935};
5936
5937static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5938 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5939 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5940 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5941 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5942 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5943 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5944 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5945 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005952 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5954 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005955 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005956 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5957 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5958 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5959 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5960 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5961 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5962 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5963 {
5964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5965 /* .name = "Capture Source", */
5966 .name = "Input Source",
5967 .count = 2,
5968 .info = alc883_mux_enum_info,
5969 .get = alc883_mux_enum_get,
5970 .put = alc883_mux_enum_put,
5971 },
5972 { } /* end */
5973};
5974
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005975static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005976 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5977 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5978 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5979 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5980 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5981 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5982 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5983 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5984 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005990 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5992 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005993 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005994 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5995 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5996 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5997 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5998 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5999
6000 {
6001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6002 /* .name = "Capture Source", */
6003 .name = "Input Source",
6004 .count = 1,
6005 .info = alc883_mux_enum_info,
6006 .get = alc883_mux_enum_get,
6007 .put = alc883_mux_enum_put,
6008 },
6009 { } /* end */
6010};
6011
Kailang Yangccc656c2006-10-17 12:32:26 +02006012static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6013 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6015 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6016 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6017 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6018 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6019 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6020 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6021 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6022 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6023 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6026 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6029 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6030 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6031 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6032 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6033 {
6034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6035 /* .name = "Capture Source", */
6036 .name = "Input Source",
6037 .count = 2,
6038 .info = alc883_mux_enum_info,
6039 .get = alc883_mux_enum_get,
6040 .put = alc883_mux_enum_put,
6041 },
6042 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006043};
Kailang Yangccc656c2006-10-17 12:32:26 +02006044
6045static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6046 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6048 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6049 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6050 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6054 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6055 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6056 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6057 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6058 {
6059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6060 /* .name = "Capture Source", */
6061 .name = "Input Source",
6062 .count = 2,
6063 .info = alc883_mux_enum_info,
6064 .get = alc883_mux_enum_get,
6065 .put = alc883_mux_enum_put,
6066 },
6067 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006068};
Kailang Yangccc656c2006-10-17 12:32:26 +02006069
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006070static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6071 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6072 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6073 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6074 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6079 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6080 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6081 {
6082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6083 /* .name = "Capture Source", */
6084 .name = "Input Source",
6085 .count = 1,
6086 .info = alc883_mux_enum_info,
6087 .get = alc883_mux_enum_get,
6088 .put = alc883_mux_enum_put,
6089 },
6090 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006091};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006092
Kailang Yang272a5272007-05-14 11:00:38 +02006093static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6094 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6095 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6101 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6102 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6103 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6104 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6105 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6106 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6107 {
6108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6109 /* .name = "Capture Source", */
6110 .name = "Input Source",
6111 .count = 2,
6112 .info = alc883_mux_enum_info,
6113 .get = alc883_mux_enum_get,
6114 .put = alc883_mux_enum_put,
6115 },
6116 { } /* end */
6117};
6118
6119static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6122 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6129 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6130 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6131 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6132 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6133 {
6134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6135 /* .name = "Capture Source", */
6136 .name = "Input Source",
6137 .count = 2,
6138 .info = alc883_mux_enum_info,
6139 .get = alc883_mux_enum_get,
6140 .put = alc883_mux_enum_put,
6141 },
6142 { } /* end */
6143};
6144
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006145static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6147 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6148 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6149 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6150 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6152 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6153 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6154 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6155 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6157 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6158 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6160 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6165 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6166 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6167 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6168 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6169 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6170 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6171 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6172 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6173 {
6174 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6175 /* .name = "Capture Source", */
6176 .name = "Input Source",
6177 .count = 2,
6178 .info = alc883_mux_enum_info,
6179 .get = alc883_mux_enum_get,
6180 .put = alc883_mux_enum_put,
6181 },
6182 { } /* end */
6183};
6184
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006185static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006186 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6187 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6188 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6189 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6190 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6191 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6192 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6193 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6195 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6196 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6200 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6203 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6205 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6206 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6207 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6208 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6209 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6210 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6211 {
6212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6213 /* .name = "Capture Source", */
6214 .name = "Input Source",
6215 .count = 2,
6216 .info = alc883_mux_enum_info,
6217 .get = alc883_mux_enum_get,
6218 .put = alc883_mux_enum_put,
6219 },
6220 { } /* end */
6221};
6222
Tobin Davis2880a862007-08-07 11:50:26 +02006223static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6225 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6232 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6233 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6234 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6235 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6236 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6237 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6238 {
6239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6240 /* .name = "Capture Source", */
6241 .name = "Input Source",
6242 .count = 2,
6243 .info = alc883_mux_enum_info,
6244 .get = alc883_mux_enum_get,
6245 .put = alc883_mux_enum_put,
6246 },
6247 { } /* end */
6248};
6249
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006250static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6251 {
6252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6253 .name = "Channel Mode",
6254 .info = alc_ch_mode_info,
6255 .get = alc_ch_mode_get,
6256 .put = alc_ch_mode_put,
6257 },
6258 { } /* end */
6259};
6260
6261static struct hda_verb alc883_init_verbs[] = {
6262 /* ADC1: mute amp left and right */
6263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6265 /* ADC2: mute amp left and right */
6266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6267 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6268 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6270 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6272 /* Rear mixer */
6273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6275 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6276 /* CLFE mixer */
6277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6279 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6280 /* Side mixer */
6281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6284
6285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6290
6291 /* Front Pin: output 0 (0x0c) */
6292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6294 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6295 /* Rear Pin: output 1 (0x0d) */
6296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6299 /* CLFE Pin: output 2 (0x0e) */
6300 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6301 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6302 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6303 /* Side Pin: output 3 (0x0f) */
6304 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6305 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6306 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6307 /* Mic (rear) pin: input vref at 80% */
6308 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6310 /* Front Mic pin: input vref at 80% */
6311 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6313 /* Line In pin: input */
6314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6316 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6319 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6320 /* CD pin widget for input */
6321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6322
6323 /* FIXME: use matrix-type input source selection */
6324 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6325 /* Input mixer2 */
6326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6330 /* Input mixer3 */
6331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6335 { }
6336};
6337
Kailang Yangccc656c2006-10-17 12:32:26 +02006338static struct hda_verb alc883_tagra_verbs[] = {
6339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6341
6342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6343 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6344
6345 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6346 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6347 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6348
6349 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006350 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6351 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6352 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006353
6354 { } /* end */
6355};
6356
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006357static struct hda_verb alc883_lenovo_101e_verbs[] = {
6358 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6359 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6360 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6361 { } /* end */
6362};
6363
Kailang Yang272a5272007-05-14 11:00:38 +02006364static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6365 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6367 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6368 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6369 { } /* end */
6370};
6371
6372static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6375 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6376 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6377 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6378 { } /* end */
6379};
6380
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006381static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006382 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6384 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6385 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6386 { }
6387};
6388
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006389static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006390 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6391 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6392 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6393 { }
6394};
6395
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006396static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006397 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6398 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6399 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6400 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6401 { }
6402};
6403
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006404static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006405 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6406 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6407 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6408 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6409 { }
6410};
6411
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006412static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6413 { 2, alc888_3st_hp_2ch_init },
6414 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006415};
6416
Kailang Yang272a5272007-05-14 11:00:38 +02006417/* toggle front-jack and RCA according to the hp-jack state */
6418static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6419{
6420 unsigned int present;
6421
6422 present = snd_hda_codec_read(codec, 0x1b, 0,
6423 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6424 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6425 0x80, present ? 0x80 : 0);
6426 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6427 0x80, present ? 0x80 : 0);
6428 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6429 0x80, present ? 0x80 : 0);
6430 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6431 0x80, present ? 0x80 : 0);
6432
6433}
6434
6435/* toggle RCA according to the front-jack state */
6436static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6437{
6438 unsigned int present;
6439
6440 present = snd_hda_codec_read(codec, 0x14, 0,
6441 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6442 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6443 0x80, present ? 0x80 : 0);
6444 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6445 0x80, present ? 0x80 : 0);
6446
6447}
6448static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6449 unsigned int res)
6450{
6451 if ((res >> 26) == ALC880_HP_EVENT)
6452 alc888_lenovo_ms7195_front_automute(codec);
6453 if ((res >> 26) == ALC880_FRONT_EVENT)
6454 alc888_lenovo_ms7195_rca_automute(codec);
6455}
6456
6457static struct hda_verb alc883_medion_md2_verbs[] = {
6458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6460
6461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6462
6463 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6464 { } /* end */
6465};
6466
Tobin Davis2880a862007-08-07 11:50:26 +02006467static struct hda_verb alc883_acer_aspire_verbs[] = {
6468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6472
6473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6474
6475 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6476 { } /* end */
6477};
6478
Kailang Yang272a5272007-05-14 11:00:38 +02006479/* toggle speaker-output according to the hp-jack state */
6480static void alc883_medion_md2_automute(struct hda_codec *codec)
6481{
6482 unsigned int present;
6483
6484 present = snd_hda_codec_read(codec, 0x14, 0,
6485 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6486 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6487 0x80, present ? 0x80 : 0);
6488 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6489 0x80, present ? 0x80 : 0);
6490}
6491
6492static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6493 unsigned int res)
6494{
6495 if ((res >> 26) == ALC880_HP_EVENT)
6496 alc883_medion_md2_automute(codec);
6497}
6498
Kailang Yangccc656c2006-10-17 12:32:26 +02006499/* toggle speaker-output according to the hp-jack state */
6500static void alc883_tagra_automute(struct hda_codec *codec)
6501{
6502 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006503 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006504
6505 present = snd_hda_codec_read(codec, 0x14, 0,
6506 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006507 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006508 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006509 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006510 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006511 0x80, bits);
6512 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6513 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006514}
6515
6516static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6517{
6518 if ((res >> 26) == ALC880_HP_EVENT)
6519 alc883_tagra_automute(codec);
6520}
6521
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006522static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6523{
6524 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006525 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006526
6527 present = snd_hda_codec_read(codec, 0x14, 0,
6528 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006529 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006530 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006531 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006532 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006533 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006534}
6535
6536static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6537{
6538 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006539 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006540
6541 present = snd_hda_codec_read(codec, 0x1b, 0,
6542 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006543 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006544 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006545 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006546 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006547 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006548 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006549 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006550 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006551 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006552}
6553
6554static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6555 unsigned int res)
6556{
6557 if ((res >> 26) == ALC880_HP_EVENT)
6558 alc883_lenovo_101e_all_automute(codec);
6559 if ((res >> 26) == ALC880_FRONT_EVENT)
6560 alc883_lenovo_101e_ispeaker_automute(codec);
6561}
6562
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006563/*
6564 * generic initialization of ADC, input mixers and output mixers
6565 */
6566static struct hda_verb alc883_auto_init_verbs[] = {
6567 /*
6568 * Unmute ADC0-2 and set the default input to mic-in
6569 */
6570 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6572 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6573 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6574
6575 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6576 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006577 * Note: PASD motherboards uses the Line In 2 as the input for
6578 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006579 */
6580 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6584 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6586
6587 /*
6588 * Set up output mixers (0x0c - 0x0f)
6589 */
6590 /* set vol=0 to output mixers */
6591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6595 /* set up input amps for analog loopback */
6596 /* Amp Indices: DAC = 0, mixer = 1 */
6597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6600 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6601 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6602 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6603 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6604 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6605 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6606 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6607
6608 /* FIXME: use matrix-type input source selection */
6609 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6610 /* Input mixer1 */
6611 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006614 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6616 /* Input mixer2 */
6617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006620 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006621 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6622
6623 { }
6624};
6625
6626/* capture mixer elements */
6627static struct snd_kcontrol_new alc883_capture_mixer[] = {
6628 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6629 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6630 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6631 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6632 {
6633 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6634 /* The multiple "Capture Source" controls confuse alsamixer
6635 * So call somewhat different..
6636 * FIXME: the controls appear in the "playback" view!
6637 */
6638 /* .name = "Capture Source", */
6639 .name = "Input Source",
6640 .count = 2,
6641 .info = alc882_mux_enum_info,
6642 .get = alc882_mux_enum_get,
6643 .put = alc882_mux_enum_put,
6644 },
6645 { } /* end */
6646};
6647
6648/* pcm configuration: identiacal with ALC880 */
6649#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6650#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6651#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6652#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6653
6654/*
6655 * configuration and preset
6656 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006657static const char *alc883_models[ALC883_MODEL_LAST] = {
6658 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6659 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6660 [ALC883_3ST_6ch] = "3stack-6ch",
6661 [ALC883_6ST_DIG] = "6stack-dig",
6662 [ALC883_TARGA_DIG] = "targa-dig",
6663 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006664 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02006665 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006666 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006667 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006668 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006669 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006670 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6671 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006672 [ALC888_6ST_HP] = "6stack-hp",
6673 [ALC888_3ST_HP] = "3stack-hp",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006674 [ALC883_AUTO] = "auto",
6675};
6676
6677static struct snd_pci_quirk alc883_cfg_tbl[] = {
6678 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006679 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006680 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6681 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6682 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006683 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006684 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6685 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006686 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006687 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02006688 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006689 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006690 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006691 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006692 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6693 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6694 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6695 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6696 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6697 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6698 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6699 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6700 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Tobin Davis2880a862007-08-07 11:50:26 +02006701 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006702 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006703 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006704 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6705 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6706 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006707 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6708 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6709 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006710 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6711 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6712 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
Kailang Yang272a5272007-05-14 11:00:38 +02006713 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006714 {}
6715};
6716
6717static struct alc_config_preset alc883_presets[] = {
6718 [ALC883_3ST_2ch_DIG] = {
6719 .mixers = { alc883_3ST_2ch_mixer },
6720 .init_verbs = { alc883_init_verbs },
6721 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6722 .dac_nids = alc883_dac_nids,
6723 .dig_out_nid = ALC883_DIGOUT_NID,
6724 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6725 .adc_nids = alc883_adc_nids,
6726 .dig_in_nid = ALC883_DIGIN_NID,
6727 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6728 .channel_mode = alc883_3ST_2ch_modes,
6729 .input_mux = &alc883_capture_source,
6730 },
6731 [ALC883_3ST_6ch_DIG] = {
6732 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6733 .init_verbs = { alc883_init_verbs },
6734 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6735 .dac_nids = alc883_dac_nids,
6736 .dig_out_nid = ALC883_DIGOUT_NID,
6737 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6738 .adc_nids = alc883_adc_nids,
6739 .dig_in_nid = ALC883_DIGIN_NID,
6740 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6741 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006742 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006743 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006744 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006745 [ALC883_3ST_6ch] = {
6746 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6747 .init_verbs = { alc883_init_verbs },
6748 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6749 .dac_nids = alc883_dac_nids,
6750 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6751 .adc_nids = alc883_adc_nids,
6752 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6753 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006754 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006755 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006756 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006757 [ALC883_6ST_DIG] = {
6758 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6759 .init_verbs = { alc883_init_verbs },
6760 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6761 .dac_nids = alc883_dac_nids,
6762 .dig_out_nid = ALC883_DIGOUT_NID,
6763 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6764 .adc_nids = alc883_adc_nids,
6765 .dig_in_nid = ALC883_DIGIN_NID,
6766 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6767 .channel_mode = alc883_sixstack_modes,
6768 .input_mux = &alc883_capture_source,
6769 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006770 [ALC883_TARGA_DIG] = {
6771 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6772 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6773 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6774 .dac_nids = alc883_dac_nids,
6775 .dig_out_nid = ALC883_DIGOUT_NID,
6776 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6777 .adc_nids = alc883_adc_nids,
6778 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6779 .channel_mode = alc883_3ST_6ch_modes,
6780 .need_dac_fix = 1,
6781 .input_mux = &alc883_capture_source,
6782 .unsol_event = alc883_tagra_unsol_event,
6783 .init_hook = alc883_tagra_automute,
6784 },
6785 [ALC883_TARGA_2ch_DIG] = {
6786 .mixers = { alc883_tagra_2ch_mixer},
6787 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6788 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6789 .dac_nids = alc883_dac_nids,
6790 .dig_out_nid = ALC883_DIGOUT_NID,
6791 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6792 .adc_nids = alc883_adc_nids,
6793 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6794 .channel_mode = alc883_3ST_2ch_modes,
6795 .input_mux = &alc883_capture_source,
6796 .unsol_event = alc883_tagra_unsol_event,
6797 .init_hook = alc883_tagra_automute,
6798 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02006799 [ALC883_ACER] = {
6800 .mixers = { alc883_base_mixer,
6801 alc883_chmode_mixer },
6802 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6803 * and the headphone jack. Turn this on and rely on the
6804 * standard mute methods whenever the user wants to turn
6805 * these outputs off.
6806 */
6807 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6808 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6809 .dac_nids = alc883_dac_nids,
6810 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6811 .adc_nids = alc883_adc_nids,
6812 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6813 .channel_mode = alc883_3ST_2ch_modes,
6814 .input_mux = &alc883_capture_source,
6815 },
Tobin Davis2880a862007-08-07 11:50:26 +02006816 [ALC883_ACER_ASPIRE] = {
6817 .mixers = { alc883_acer_aspire_mixer},
6818 .init_verbs = { alc883_init_verbs, alc883_acer_aspire_verbs},
6819 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6820 .dac_nids = alc883_dac_nids,
6821 .dig_out_nid = ALC883_DIGOUT_NID,
6822 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6823 .adc_nids = alc883_adc_nids,
6824 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6825 .channel_mode = alc883_3ST_2ch_modes,
6826 .input_mux = &alc883_capture_source,
6827 .unsol_event = alc883_medion_md2_unsol_event,
6828 .init_hook = alc883_medion_md2_automute,
6829 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006830 [ALC883_MEDION] = {
6831 .mixers = { alc883_fivestack_mixer,
6832 alc883_chmode_mixer },
6833 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006834 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006835 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6836 .dac_nids = alc883_dac_nids,
6837 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6838 .adc_nids = alc883_adc_nids,
6839 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6840 .channel_mode = alc883_sixstack_modes,
6841 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006842 },
Kailang Yang272a5272007-05-14 11:00:38 +02006843 [ALC883_MEDION_MD2] = {
6844 .mixers = { alc883_medion_md2_mixer},
6845 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6846 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6847 .dac_nids = alc883_dac_nids,
6848 .dig_out_nid = ALC883_DIGOUT_NID,
6849 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6850 .adc_nids = alc883_adc_nids,
6851 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6852 .channel_mode = alc883_3ST_2ch_modes,
6853 .input_mux = &alc883_capture_source,
6854 .unsol_event = alc883_medion_md2_unsol_event,
6855 .init_hook = alc883_medion_md2_automute,
6856 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006857 [ALC883_LAPTOP_EAPD] = {
6858 .mixers = { alc883_base_mixer,
6859 alc883_chmode_mixer },
6860 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6861 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6862 .dac_nids = alc883_dac_nids,
6863 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6864 .adc_nids = alc883_adc_nids,
6865 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6866 .channel_mode = alc883_3ST_2ch_modes,
6867 .input_mux = &alc883_capture_source,
6868 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006869 [ALC883_LENOVO_101E_2ch] = {
6870 .mixers = { alc883_lenovo_101e_2ch_mixer},
6871 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6872 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6873 .dac_nids = alc883_dac_nids,
6874 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6875 .adc_nids = alc883_adc_nids,
6876 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6877 .channel_mode = alc883_3ST_2ch_modes,
6878 .input_mux = &alc883_lenovo_101e_capture_source,
6879 .unsol_event = alc883_lenovo_101e_unsol_event,
6880 .init_hook = alc883_lenovo_101e_all_automute,
6881 },
Kailang Yang272a5272007-05-14 11:00:38 +02006882 [ALC883_LENOVO_NB0763] = {
6883 .mixers = { alc883_lenovo_nb0763_mixer },
6884 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6885 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6886 .dac_nids = alc883_dac_nids,
6887 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6888 .adc_nids = alc883_adc_nids,
6889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6890 .channel_mode = alc883_3ST_2ch_modes,
6891 .need_dac_fix = 1,
6892 .input_mux = &alc883_lenovo_nb0763_capture_source,
6893 .unsol_event = alc883_medion_md2_unsol_event,
6894 .init_hook = alc883_medion_md2_automute,
6895 },
6896 [ALC888_LENOVO_MS7195_DIG] = {
6897 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6898 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6899 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6900 .dac_nids = alc883_dac_nids,
6901 .dig_out_nid = ALC883_DIGOUT_NID,
6902 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6903 .adc_nids = alc883_adc_nids,
6904 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6905 .channel_mode = alc883_3ST_6ch_modes,
6906 .need_dac_fix = 1,
6907 .input_mux = &alc883_capture_source,
6908 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6909 .init_hook = alc888_lenovo_ms7195_front_automute,
6910 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006911 [ALC888_6ST_HP] = {
6912 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6913 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006914 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6915 .dac_nids = alc883_dac_nids,
6916 .dig_out_nid = ALC883_DIGOUT_NID,
6917 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6918 .adc_nids = alc883_adc_nids,
6919 .dig_in_nid = ALC883_DIGIN_NID,
6920 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6921 .channel_mode = alc883_sixstack_modes,
6922 .input_mux = &alc883_capture_source,
6923 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006924 [ALC888_3ST_HP] = {
6925 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6926 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006927 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6928 .dac_nids = alc883_dac_nids,
6929 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6930 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006931 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6932 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006933 .need_dac_fix = 1,
6934 .input_mux = &alc883_capture_source,
6935 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006936};
6937
6938
6939/*
6940 * BIOS auto configuration
6941 */
6942static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6943 hda_nid_t nid, int pin_type,
6944 int dac_idx)
6945{
6946 /* set as output */
6947 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006948 int idx;
6949
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006950 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6951 idx = 4;
6952 else
6953 idx = spec->multiout.dac_nids[dac_idx] - 2;
6954
6955 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6956 pin_type);
6957 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6958 AMP_OUT_UNMUTE);
6959 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6960
6961}
6962
6963static void alc883_auto_init_multi_out(struct hda_codec *codec)
6964{
6965 struct alc_spec *spec = codec->spec;
6966 int i;
6967
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006968 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006969 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006970 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006971 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006972 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006973 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006974 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006975 }
6976}
6977
6978static void alc883_auto_init_hp_out(struct hda_codec *codec)
6979{
6980 struct alc_spec *spec = codec->spec;
6981 hda_nid_t pin;
6982
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006983 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006984 if (pin) /* connect to front */
6985 /* use dac 0 */
6986 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6987}
6988
6989#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6990#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6991
6992static void alc883_auto_init_analog_input(struct hda_codec *codec)
6993{
6994 struct alc_spec *spec = codec->spec;
6995 int i;
6996
6997 for (i = 0; i < AUTO_PIN_LAST; i++) {
6998 hda_nid_t nid = spec->autocfg.input_pins[i];
6999 if (alc883_is_input_pin(nid)) {
7000 snd_hda_codec_write(codec, nid, 0,
7001 AC_VERB_SET_PIN_WIDGET_CONTROL,
7002 (i <= AUTO_PIN_FRONT_MIC ?
7003 PIN_VREF80 : PIN_IN));
7004 if (nid != ALC883_PIN_CD_NID)
7005 snd_hda_codec_write(codec, nid, 0,
7006 AC_VERB_SET_AMP_GAIN_MUTE,
7007 AMP_OUT_MUTE);
7008 }
7009 }
7010}
7011
7012/* almost identical with ALC880 parser... */
7013static int alc883_parse_auto_config(struct hda_codec *codec)
7014{
7015 struct alc_spec *spec = codec->spec;
7016 int err = alc880_parse_auto_config(codec);
7017
7018 if (err < 0)
7019 return err;
7020 else if (err > 0)
7021 /* hack - override the init verbs */
7022 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007023 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7024 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007025 return err;
7026}
7027
7028/* additional initialization for auto-configuration model */
7029static void alc883_auto_init(struct hda_codec *codec)
7030{
7031 alc883_auto_init_multi_out(codec);
7032 alc883_auto_init_hp_out(codec);
7033 alc883_auto_init_analog_input(codec);
7034}
7035
7036static int patch_alc883(struct hda_codec *codec)
7037{
7038 struct alc_spec *spec;
7039 int err, board_config;
7040
7041 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7042 if (spec == NULL)
7043 return -ENOMEM;
7044
7045 codec->spec = spec;
7046
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007047 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7048 alc883_models,
7049 alc883_cfg_tbl);
7050 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007051 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7052 "trying auto-probe from BIOS...\n");
7053 board_config = ALC883_AUTO;
7054 }
7055
7056 if (board_config == ALC883_AUTO) {
7057 /* automatic parse from the BIOS config */
7058 err = alc883_parse_auto_config(codec);
7059 if (err < 0) {
7060 alc_free(codec);
7061 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007062 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007063 printk(KERN_INFO
7064 "hda_codec: Cannot set up configuration "
7065 "from BIOS. Using base mode...\n");
7066 board_config = ALC883_3ST_2ch_DIG;
7067 }
7068 }
7069
7070 if (board_config != ALC883_AUTO)
7071 setup_preset(spec, &alc883_presets[board_config]);
7072
7073 spec->stream_name_analog = "ALC883 Analog";
7074 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7075 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7076
7077 spec->stream_name_digital = "ALC883 Digital";
7078 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7079 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7080
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007081 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007082 spec->adc_nids = alc883_adc_nids;
7083 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7084 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007085
7086 codec->patch_ops = alc_patch_ops;
7087 if (board_config == ALC883_AUTO)
7088 spec->init_hook = alc883_auto_init;
7089
7090 return 0;
7091}
7092
7093/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007094 * ALC262 support
7095 */
7096
7097#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7098#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7099
7100#define alc262_dac_nids alc260_dac_nids
7101#define alc262_adc_nids alc882_adc_nids
7102#define alc262_adc_nids_alt alc882_adc_nids_alt
7103
7104#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007105#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007106
7107static struct snd_kcontrol_new alc262_base_mixer[] = {
7108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7109 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7110 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7111 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7113 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007116 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007117 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7118 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007119 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007120 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7121 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7122 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7123 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7124 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7125 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007126 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007127};
7128
Kailang Yangccc656c2006-10-17 12:32:26 +02007129static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7131 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007138 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007139 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7140 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007141 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007142 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7143 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7144 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7146 { } /* end */
7147};
7148
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007149static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7150 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7151 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7153 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7154 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7155
7156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007159 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7160 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007161 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007162 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7163 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7164 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7165 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7166 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7167 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7168 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7169 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7170 { } /* end */
7171};
7172
Kailang Yangcd7509a2007-01-26 18:33:17 +01007173static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7175 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7176 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7178 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7179 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7180 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007182 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007183 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7184 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7185 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7186 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7187 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7188 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7189 { } /* end */
7190};
7191
7192static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7193 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7194 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007195 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007196 { } /* end */
7197};
7198
Takashi Iwai532d5382007-07-27 19:02:40 +02007199static struct hda_bind_ctls alc262_sony_bind_sw = {
7200 .ops = &snd_hda_bind_sw,
7201 .values = {
7202 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7203 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7204 0,
7205 },
7206};
Takashi Iwai5b319542007-07-26 11:49:22 +02007207
Kailang Yang272a5272007-05-14 11:00:38 +02007208static struct snd_kcontrol_new alc262_sony_mixer[] = {
7209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai532d5382007-07-27 19:02:40 +02007210 HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
Kailang Yang272a5272007-05-14 11:00:38 +02007211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7213 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7214 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7215 { } /* end */
7216};
7217
Kailang Yang83c34212007-07-05 11:43:05 +02007218static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7220 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7224 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7225 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7226 { } /* end */
7227};
Kailang Yang272a5272007-05-14 11:00:38 +02007228
Kailang Yangdf694da2005-12-05 19:42:22 +01007229#define alc262_capture_mixer alc882_capture_mixer
7230#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7231
7232/*
7233 * generic initialization of ADC, input mixers and output mixers
7234 */
7235static struct hda_verb alc262_init_verbs[] = {
7236 /*
7237 * Unmute ADC0-2 and set the default input to mic-in
7238 */
7239 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7241 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7243 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7245
7246 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7247 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007248 * Note: PASD motherboards uses the Line In 2 as the input for
7249 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007250 */
7251 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7256 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7257
7258 /*
7259 * Set up output mixers (0x0c - 0x0e)
7260 */
7261 /* set vol=0 to output mixers */
7262 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7263 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7265 /* set up input amps for analog loopback */
7266 /* Amp Indices: DAC = 0, mixer = 1 */
7267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7271 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7272 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7273
7274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7276 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7279 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7280
7281 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7283 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7284 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7285 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7286
7287 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7288 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7289
7290 /* FIXME: use matrix-type input source selection */
7291 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7292 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7297 /* Input mixer2 */
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7301 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7302 /* Input mixer3 */
7303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007307
7308 { }
7309};
7310
Kailang Yangccc656c2006-10-17 12:32:26 +02007311static struct hda_verb alc262_hippo_unsol_verbs[] = {
7312 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7314 {}
7315};
7316
7317static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7318 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7319 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7320 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7321
7322 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7324 {}
7325};
7326
Kailang Yang272a5272007-05-14 11:00:38 +02007327static struct hda_verb alc262_sony_unsol_verbs[] = {
7328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7329 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7330 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7331
7332 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7333 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7334};
7335
Kailang Yangccc656c2006-10-17 12:32:26 +02007336/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02007337static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007338{
7339 struct alc_spec *spec = codec->spec;
7340 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007341 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007342
Takashi Iwai5b319542007-07-26 11:49:22 +02007343 /* need to execute and sync at first */
7344 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7345 present = snd_hda_codec_read(codec, 0x15, 0,
7346 AC_VERB_GET_PIN_SENSE, 0);
7347 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02007348 if (spec->jack_present) {
7349 /* mute internal speaker */
7350 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7351 0x80, 0x80);
7352 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7353 0x80, 0x80);
7354 } else {
7355 /* unmute internal speaker if necessary */
7356 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7357 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7358 0x80, mute & 0x80);
7359 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7360 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7361 0x80, mute & 0x80);
7362 }
7363}
7364
7365/* unsolicited event for HP jack sensing */
7366static void alc262_hippo_unsol_event(struct hda_codec *codec,
7367 unsigned int res)
7368{
7369 if ((res >> 26) != ALC880_HP_EVENT)
7370 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007371 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007372}
7373
Takashi Iwai5b319542007-07-26 11:49:22 +02007374static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007375{
Kailang Yangccc656c2006-10-17 12:32:26 +02007376 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007377 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007378
Takashi Iwai5b319542007-07-26 11:49:22 +02007379 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7380 present = snd_hda_codec_read(codec, 0x1b, 0,
7381 AC_VERB_GET_PIN_SENSE, 0);
7382 present = (present & 0x80000000) != 0;
7383 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007384 /* mute internal speaker */
7385 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7386 0x80, 0x80);
7387 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7388 0x80, 0x80);
7389 } else {
7390 /* unmute internal speaker if necessary */
7391 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7392 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7393 0x80, mute & 0x80);
7394 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7395 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7396 0x80, mute & 0x80);
7397 }
7398}
7399
7400/* unsolicited event for HP jack sensing */
7401static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7402 unsigned int res)
7403{
7404 if ((res >> 26) != ALC880_HP_EVENT)
7405 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007406 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007407}
7408
Takashi Iwai834be882006-03-01 14:16:17 +01007409/*
7410 * fujitsu model
7411 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7412 */
7413
7414#define ALC_HP_EVENT 0x37
7415
7416static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7417 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7419 {}
7420};
7421
7422static struct hda_input_mux alc262_fujitsu_capture_source = {
7423 .num_items = 2,
7424 .items = {
7425 { "Mic", 0x0 },
7426 { "CD", 0x4 },
7427 },
7428};
7429
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007430static struct hda_input_mux alc262_HP_capture_source = {
7431 .num_items = 5,
7432 .items = {
7433 { "Mic", 0x0 },
7434 { "Front Mic", 0x3 },
7435 { "Line", 0x2 },
7436 { "CD", 0x4 },
7437 { "AUX IN", 0x6 },
7438 },
7439};
7440
Takashi Iwai834be882006-03-01 14:16:17 +01007441/* mute/unmute internal speaker according to the hp jack and mute state */
7442static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7443{
7444 struct alc_spec *spec = codec->spec;
7445 unsigned int mute;
7446
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007447 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007448 unsigned int present;
7449 /* need to execute and sync at first */
7450 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7451 present = snd_hda_codec_read(codec, 0x14, 0,
7452 AC_VERB_GET_PIN_SENSE, 0);
7453 spec->jack_present = (present & 0x80000000) != 0;
7454 spec->sense_updated = 1;
7455 }
7456 if (spec->jack_present) {
7457 /* mute internal speaker */
7458 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7459 0x80, 0x80);
7460 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7461 0x80, 0x80);
7462 } else {
7463 /* unmute internal speaker if necessary */
7464 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7465 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7466 0x80, mute & 0x80);
7467 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7468 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7469 0x80, mute & 0x80);
7470 }
7471}
7472
7473/* unsolicited event for HP jack sensing */
7474static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7475 unsigned int res)
7476{
7477 if ((res >> 26) != ALC_HP_EVENT)
7478 return;
7479 alc262_fujitsu_automute(codec, 1);
7480}
7481
7482/* bind volumes of both NID 0x0c and 0x0d */
7483static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7484 struct snd_ctl_elem_value *ucontrol)
7485{
7486 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7487 long *valp = ucontrol->value.integer.value;
7488 int change;
7489
7490 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7491 0x7f, valp[0] & 0x7f);
7492 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7493 0x7f, valp[1] & 0x7f);
7494 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7495 0x7f, valp[0] & 0x7f);
7496 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7497 0x7f, valp[1] & 0x7f);
7498 return change;
7499}
7500
7501/* bind hp and internal speaker mute (with plug check) */
7502static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7503 struct snd_ctl_elem_value *ucontrol)
7504{
7505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7506 long *valp = ucontrol->value.integer.value;
7507 int change;
7508
7509 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7510 0x80, valp[0] ? 0 : 0x80);
7511 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7512 0x80, valp[1] ? 0 : 0x80);
7513 if (change || codec->in_resume)
7514 alc262_fujitsu_automute(codec, codec->in_resume);
7515 return change;
7516}
7517
7518static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7519 {
7520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7521 .name = "Master Playback Volume",
7522 .info = snd_hda_mixer_amp_volume_info,
7523 .get = snd_hda_mixer_amp_volume_get,
7524 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007525 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007526 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7527 },
7528 {
7529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7530 .name = "Master Playback Switch",
7531 .info = snd_hda_mixer_amp_switch_info,
7532 .get = snd_hda_mixer_amp_switch_get,
7533 .put = alc262_fujitsu_master_sw_put,
7534 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7535 },
7536 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7537 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7541 { } /* end */
7542};
7543
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007544/* additional init verbs for Benq laptops */
7545static struct hda_verb alc262_EAPD_verbs[] = {
7546 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7547 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7548 {}
7549};
7550
Kailang Yang83c34212007-07-05 11:43:05 +02007551static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7554
7555 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7556 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7557 {}
7558};
7559
Kailang Yangdf694da2005-12-05 19:42:22 +01007560/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007561static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7562 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007563{
7564 hda_nid_t nid;
7565 int err;
7566
7567 spec->multiout.num_dacs = 1; /* only use one dac */
7568 spec->multiout.dac_nids = spec->private_dac_nids;
7569 spec->multiout.dac_nids[0] = 2;
7570
7571 nid = cfg->line_out_pins[0];
7572 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007573 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7574 "Front Playback Volume",
7575 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7576 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007577 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007578 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7579 "Front Playback Switch",
7580 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7581 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007582 return err;
7583 }
7584
Takashi Iwai82bc9552006-03-21 11:24:42 +01007585 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007586 if (nid) {
7587 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007588 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7589 "Speaker Playback Volume",
7590 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7591 HDA_OUTPUT));
7592 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007593 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007594 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7595 "Speaker Playback Switch",
7596 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7597 HDA_OUTPUT));
7598 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007599 return err;
7600 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007601 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7602 "Speaker Playback Switch",
7603 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7604 HDA_OUTPUT));
7605 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007606 return err;
7607 }
7608 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007609 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007610 if (nid) {
7611 /* spec->multiout.hp_nid = 2; */
7612 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007613 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7614 "Headphone Playback Volume",
7615 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7616 HDA_OUTPUT));
7617 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007618 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007619 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7620 "Headphone Playback Switch",
7621 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7622 HDA_OUTPUT));
7623 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007624 return err;
7625 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007626 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7627 "Headphone Playback Switch",
7628 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7629 HDA_OUTPUT));
7630 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007631 return err;
7632 }
7633 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007634 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007635}
7636
7637/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007638#define alc262_auto_create_analog_input_ctls \
7639 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007640
7641/*
7642 * generic initialization of ADC, input mixers and output mixers
7643 */
7644static struct hda_verb alc262_volume_init_verbs[] = {
7645 /*
7646 * Unmute ADC0-2 and set the default input to mic-in
7647 */
7648 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7650 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7651 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7652 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7653 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7654
7655 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7656 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007657 * Note: PASD motherboards uses the Line In 2 as the input for
7658 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007659 */
7660 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7666
7667 /*
7668 * Set up output mixers (0x0c - 0x0f)
7669 */
7670 /* set vol=0 to output mixers */
7671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7672 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7673 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7674
7675 /* set up input amps for analog loopback */
7676 /* Amp Indices: DAC = 0, mixer = 1 */
7677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7683
7684 /* FIXME: use matrix-type input source selection */
7685 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7686 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7687 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7691 /* Input mixer2 */
7692 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7693 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7694 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7695 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7696 /* Input mixer3 */
7697 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7699 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7701
7702 { }
7703};
7704
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007705static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7706 /*
7707 * Unmute ADC0-2 and set the default input to mic-in
7708 */
7709 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7711 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7712 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7713 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7714 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715
7716 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7717 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007718 * Note: PASD motherboards uses the Line In 2 as the input for
7719 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007720 */
7721 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7729
7730 /*
7731 * Set up output mixers (0x0c - 0x0e)
7732 */
7733 /* set vol=0 to output mixers */
7734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7737
7738 /* set up input amps for analog loopback */
7739 /* Amp Indices: DAC = 0, mixer = 1 */
7740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7746
7747 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7750
7751 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7753
7754 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7756
7757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7761 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7762
7763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7766 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7767 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7768 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7769
7770
7771 /* FIXME: use matrix-type input source selection */
7772 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7773 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7778 /* Input mixer2 */
7779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7783 /* Input mixer3 */
7784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7788
7789 { }
7790};
7791
Kailang Yangcd7509a2007-01-26 18:33:17 +01007792static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7793 /*
7794 * Unmute ADC0-2 and set the default input to mic-in
7795 */
7796 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7798 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7800 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7802
7803 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7804 * mixer widget
7805 * Note: PASD motherboards uses the Line In 2 as the input for front
7806 * panel mic (mic 2)
7807 */
7808 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7811 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7817 /*
7818 * Set up output mixers (0x0c - 0x0e)
7819 */
7820 /* set vol=0 to output mixers */
7821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7824
7825 /* set up input amps for analog loopback */
7826 /* Amp Indices: DAC = 0, mixer = 1 */
7827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7830 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7831 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7832 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7833
7834
7835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7839 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7841 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7842
7843 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7845
7846 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7847 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7848
7849 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7853 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7854 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7855
7856 /* FIXME: use matrix-type input source selection */
7857 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7858 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7864 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7866 /* Input mixer2 */
7867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7872 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7874 /* Input mixer3 */
7875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7880 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7882
7883 { }
7884};
7885
Kailang Yangdf694da2005-12-05 19:42:22 +01007886/* pcm configuration: identiacal with ALC880 */
7887#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7888#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7889#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7890#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7891
7892/*
7893 * BIOS auto configuration
7894 */
7895static int alc262_parse_auto_config(struct hda_codec *codec)
7896{
7897 struct alc_spec *spec = codec->spec;
7898 int err;
7899 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7900
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007901 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7902 alc262_ignore);
7903 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007904 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007905 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007906 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007907 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7908 if (err < 0)
7909 return err;
7910 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7911 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007912 return err;
7913
7914 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7915
7916 if (spec->autocfg.dig_out_pin)
7917 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7918 if (spec->autocfg.dig_in_pin)
7919 spec->dig_in_nid = ALC262_DIGIN_NID;
7920
7921 if (spec->kctl_alloc)
7922 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7923
7924 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007925 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007926 spec->input_mux = &spec->private_imux;
7927
7928 return 1;
7929}
7930
7931#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7932#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7933#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7934
7935
7936/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007937static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007938{
Kailang Yangdf694da2005-12-05 19:42:22 +01007939 alc262_auto_init_multi_out(codec);
7940 alc262_auto_init_hp_out(codec);
7941 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007942}
7943
7944/*
7945 * configuration and preset
7946 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007947static const char *alc262_models[ALC262_MODEL_LAST] = {
7948 [ALC262_BASIC] = "basic",
7949 [ALC262_HIPPO] = "hippo",
7950 [ALC262_HIPPO_1] = "hippo_1",
7951 [ALC262_FUJITSU] = "fujitsu",
7952 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007953 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007954 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02007955 [ALC262_BENQ_T31] = "benq-t31",
7956 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007957 [ALC262_AUTO] = "auto",
7958};
7959
7960static struct snd_pci_quirk alc262_cfg_tbl[] = {
7961 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7962 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7963 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007964 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7965 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007966 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007967 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007968 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007969 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007970 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7971 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7972 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7973 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7974 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7975 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7976 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7977 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007978 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7979 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7980 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7981 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02007982 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwai5b319542007-07-26 11:49:22 +02007983 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yang272a5272007-05-14 11:00:38 +02007984 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7985 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7986 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007987 {}
7988};
7989
7990static struct alc_config_preset alc262_presets[] = {
7991 [ALC262_BASIC] = {
7992 .mixers = { alc262_base_mixer },
7993 .init_verbs = { alc262_init_verbs },
7994 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7995 .dac_nids = alc262_dac_nids,
7996 .hp_nid = 0x03,
7997 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7998 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007999 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01008000 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008001 [ALC262_HIPPO] = {
8002 .mixers = { alc262_base_mixer },
8003 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8004 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8005 .dac_nids = alc262_dac_nids,
8006 .hp_nid = 0x03,
8007 .dig_out_nid = ALC262_DIGOUT_NID,
8008 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8009 .channel_mode = alc262_modes,
8010 .input_mux = &alc262_capture_source,
8011 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008012 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008013 },
8014 [ALC262_HIPPO_1] = {
8015 .mixers = { alc262_hippo1_mixer },
8016 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8017 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8018 .dac_nids = alc262_dac_nids,
8019 .hp_nid = 0x02,
8020 .dig_out_nid = ALC262_DIGOUT_NID,
8021 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8022 .channel_mode = alc262_modes,
8023 .input_mux = &alc262_capture_source,
8024 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008025 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008026 },
Takashi Iwai834be882006-03-01 14:16:17 +01008027 [ALC262_FUJITSU] = {
8028 .mixers = { alc262_fujitsu_mixer },
8029 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
8030 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8031 .dac_nids = alc262_dac_nids,
8032 .hp_nid = 0x03,
8033 .dig_out_nid = ALC262_DIGOUT_NID,
8034 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8035 .channel_mode = alc262_modes,
8036 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008037 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01008038 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008039 [ALC262_HP_BPC] = {
8040 .mixers = { alc262_HP_BPC_mixer },
8041 .init_verbs = { alc262_HP_BPC_init_verbs },
8042 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8043 .dac_nids = alc262_dac_nids,
8044 .hp_nid = 0x03,
8045 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8046 .channel_mode = alc262_modes,
8047 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008048 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008049 [ALC262_HP_BPC_D7000_WF] = {
8050 .mixers = { alc262_HP_BPC_WildWest_mixer },
8051 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8052 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8053 .dac_nids = alc262_dac_nids,
8054 .hp_nid = 0x03,
8055 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8056 .channel_mode = alc262_modes,
8057 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008058 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008059 [ALC262_HP_BPC_D7000_WL] = {
8060 .mixers = { alc262_HP_BPC_WildWest_mixer,
8061 alc262_HP_BPC_WildWest_option_mixer },
8062 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8063 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8064 .dac_nids = alc262_dac_nids,
8065 .hp_nid = 0x03,
8066 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8067 .channel_mode = alc262_modes,
8068 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008069 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008070 [ALC262_BENQ_ED8] = {
8071 .mixers = { alc262_base_mixer },
8072 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8073 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8074 .dac_nids = alc262_dac_nids,
8075 .hp_nid = 0x03,
8076 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8077 .channel_mode = alc262_modes,
8078 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008079 },
Kailang Yang272a5272007-05-14 11:00:38 +02008080 [ALC262_SONY_ASSAMD] = {
8081 .mixers = { alc262_sony_mixer },
8082 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8083 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8084 .dac_nids = alc262_dac_nids,
8085 .hp_nid = 0x02,
8086 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8087 .channel_mode = alc262_modes,
8088 .input_mux = &alc262_capture_source,
8089 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008090 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02008091 },
8092 [ALC262_BENQ_T31] = {
8093 .mixers = { alc262_benq_t31_mixer },
8094 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8095 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8096 .dac_nids = alc262_dac_nids,
8097 .hp_nid = 0x03,
8098 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8099 .channel_mode = alc262_modes,
8100 .input_mux = &alc262_capture_source,
8101 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008102 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02008103 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008104};
8105
8106static int patch_alc262(struct hda_codec *codec)
8107{
8108 struct alc_spec *spec;
8109 int board_config;
8110 int err;
8111
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008112 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008113 if (spec == NULL)
8114 return -ENOMEM;
8115
8116 codec->spec = spec;
8117#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008118 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8119 * under-run
8120 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008121 {
8122 int tmp;
8123 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8124 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8125 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8126 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8127 }
8128#endif
8129
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008130 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8131 alc262_models,
8132 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01008133
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008134 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008135 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8136 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008137 board_config = ALC262_AUTO;
8138 }
8139
8140 if (board_config == ALC262_AUTO) {
8141 /* automatic parse from the BIOS config */
8142 err = alc262_parse_auto_config(codec);
8143 if (err < 0) {
8144 alc_free(codec);
8145 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008146 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008147 printk(KERN_INFO
8148 "hda_codec: Cannot set up configuration "
8149 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008150 board_config = ALC262_BASIC;
8151 }
8152 }
8153
8154 if (board_config != ALC262_AUTO)
8155 setup_preset(spec, &alc262_presets[board_config]);
8156
8157 spec->stream_name_analog = "ALC262 Analog";
8158 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8159 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8160
8161 spec->stream_name_digital = "ALC262 Digital";
8162 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8163 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8164
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008165 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008166 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01008167 unsigned int wcap = get_wcaps(codec, 0x07);
8168
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008169 /* get type */
8170 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01008171 if (wcap != AC_WID_AUD_IN) {
8172 spec->adc_nids = alc262_adc_nids_alt;
8173 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008174 spec->mixers[spec->num_mixers] =
8175 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01008176 spec->num_mixers++;
8177 } else {
8178 spec->adc_nids = alc262_adc_nids;
8179 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8180 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8181 spec->num_mixers++;
8182 }
8183 }
8184
8185 codec->patch_ops = alc_patch_ops;
8186 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008187 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01008188
Kailang Yangdf694da2005-12-05 19:42:22 +01008189 return 0;
8190}
8191
Kailang Yangdf694da2005-12-05 19:42:22 +01008192/*
Kailang Yanga361d842007-06-05 12:30:55 +02008193 * ALC268 channel source setting (2 channel)
8194 */
8195#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8196#define alc268_modes alc260_modes
8197
8198static hda_nid_t alc268_dac_nids[2] = {
8199 /* front, hp */
8200 0x02, 0x03
8201};
8202
8203static hda_nid_t alc268_adc_nids[2] = {
8204 /* ADC0-1 */
8205 0x08, 0x07
8206};
8207
8208static hda_nid_t alc268_adc_nids_alt[1] = {
8209 /* ADC0 */
8210 0x08
8211};
8212
8213static struct snd_kcontrol_new alc268_base_mixer[] = {
8214 /* output mixer control */
8215 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8216 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8219 { }
8220};
8221
8222/*
8223 * generic initialization of ADC, input mixers and output mixers
8224 */
8225static struct hda_verb alc268_base_init_verbs[] = {
8226 /* Unmute DAC0-1 and set vol = 0 */
8227 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8228 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8229 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8230 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8231 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8232 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8233
8234 /*
8235 * Set up output mixers (0x0c - 0x0e)
8236 */
8237 /* set vol=0 to output mixers */
8238 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8239 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8240 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8241 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8242
8243 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8244 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8245
8246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8248 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8249 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8251 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8252 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8253 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8254
8255 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8257 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8259 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8260 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8261 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8262 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8263
8264 /* FIXME: use matrix-type input source selection */
8265 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8266 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8267 /* Input mixer2 */
8268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8272
8273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8277 { }
8278};
8279
8280/*
8281 * generic initialization of ADC, input mixers and output mixers
8282 */
8283static struct hda_verb alc268_volume_init_verbs[] = {
8284 /* set output DAC */
8285 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8286 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8287 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8288 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8289
8290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8291 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8292 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8293 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8294 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8295
8296 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8299 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8300 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8301
8302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8303 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8305 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8306
8307 /* set PCBEEP vol = 0 */
8308 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8309
8310 { }
8311};
8312
8313#define alc268_mux_enum_info alc_mux_enum_info
8314#define alc268_mux_enum_get alc_mux_enum_get
8315
8316static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8317 struct snd_ctl_elem_value *ucontrol)
8318{
8319 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8320 struct alc_spec *spec = codec->spec;
8321 const struct hda_input_mux *imux = spec->input_mux;
8322 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8323 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8324 hda_nid_t nid = capture_mixers[adc_idx];
8325 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8326 unsigned int i, idx;
8327
8328 idx = ucontrol->value.enumerated.item[0];
8329 if (idx >= imux->num_items)
8330 idx = imux->num_items - 1;
8331 if (*cur_val == idx && !codec->in_resume)
8332 return 0;
8333 for (i = 0; i < imux->num_items; i++) {
8334 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8335 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8336 v | (imux->items[i].index << 8));
8337 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8338 idx );
8339 }
8340 *cur_val = idx;
8341 return 1;
8342}
8343
8344static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8345 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8346 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8347 {
8348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8349 /* The multiple "Capture Source" controls confuse alsamixer
8350 * So call somewhat different..
8351 * FIXME: the controls appear in the "playback" view!
8352 */
8353 /* .name = "Capture Source", */
8354 .name = "Input Source",
8355 .count = 1,
8356 .info = alc268_mux_enum_info,
8357 .get = alc268_mux_enum_get,
8358 .put = alc268_mux_enum_put,
8359 },
8360 { } /* end */
8361};
8362
8363static struct snd_kcontrol_new alc268_capture_mixer[] = {
8364 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8365 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8366 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8367 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8368 {
8369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8370 /* The multiple "Capture Source" controls confuse alsamixer
8371 * So call somewhat different..
8372 * FIXME: the controls appear in the "playback" view!
8373 */
8374 /* .name = "Capture Source", */
8375 .name = "Input Source",
8376 .count = 2,
8377 .info = alc268_mux_enum_info,
8378 .get = alc268_mux_enum_get,
8379 .put = alc268_mux_enum_put,
8380 },
8381 { } /* end */
8382};
8383
8384static struct hda_input_mux alc268_capture_source = {
8385 .num_items = 4,
8386 .items = {
8387 { "Mic", 0x0 },
8388 { "Front Mic", 0x1 },
8389 { "Line", 0x2 },
8390 { "CD", 0x3 },
8391 },
8392};
8393
8394/* create input playback/capture controls for the given pin */
8395static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8396 const char *ctlname, int idx)
8397{
8398 char name[32];
8399 int err;
8400
8401 sprintf(name, "%s Playback Volume", ctlname);
8402 if (nid == 0x14) {
8403 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8404 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8405 HDA_OUTPUT));
8406 if (err < 0)
8407 return err;
8408 } else if (nid == 0x15) {
8409 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8410 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8411 HDA_OUTPUT));
8412 if (err < 0)
8413 return err;
8414 } else
8415 return -1;
8416 sprintf(name, "%s Playback Switch", ctlname);
8417 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8418 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8419 if (err < 0)
8420 return err;
8421 return 0;
8422}
8423
8424/* add playback controls from the parsed DAC table */
8425static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8426 const struct auto_pin_cfg *cfg)
8427{
8428 hda_nid_t nid;
8429 int err;
8430
8431 spec->multiout.num_dacs = 2; /* only use one dac */
8432 spec->multiout.dac_nids = spec->private_dac_nids;
8433 spec->multiout.dac_nids[0] = 2;
8434 spec->multiout.dac_nids[1] = 3;
8435
8436 nid = cfg->line_out_pins[0];
8437 if (nid)
8438 alc268_new_analog_output(spec, nid, "Front", 0);
8439
8440 nid = cfg->speaker_pins[0];
8441 if (nid == 0x1d) {
8442 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8443 "Speaker Playback Volume",
8444 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8445 if (err < 0)
8446 return err;
8447 }
8448 nid = cfg->hp_pins[0];
8449 if (nid)
8450 alc268_new_analog_output(spec, nid, "Headphone", 0);
8451
8452 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8453 if (nid == 0x16) {
8454 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8455 "Mono Playback Switch",
8456 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8457 if (err < 0)
8458 return err;
8459 }
8460 return 0;
8461}
8462
8463/* create playback/capture controls for input pins */
8464static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8465 const struct auto_pin_cfg *cfg)
8466{
8467 struct hda_input_mux *imux = &spec->private_imux;
8468 int i, idx1;
8469
8470 for (i = 0; i < AUTO_PIN_LAST; i++) {
8471 switch(cfg->input_pins[i]) {
8472 case 0x18:
8473 idx1 = 0; /* Mic 1 */
8474 break;
8475 case 0x19:
8476 idx1 = 1; /* Mic 2 */
8477 break;
8478 case 0x1a:
8479 idx1 = 2; /* Line In */
8480 break;
8481 case 0x1c:
8482 idx1 = 3; /* CD */
8483 break;
8484 default:
8485 continue;
8486 }
8487 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8488 imux->items[imux->num_items].index = idx1;
8489 imux->num_items++;
8490 }
8491 return 0;
8492}
8493
8494static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8495{
8496 struct alc_spec *spec = codec->spec;
8497 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8498 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8499 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8500 unsigned int dac_vol1, dac_vol2;
8501
8502 if (speaker_nid) {
8503 snd_hda_codec_write(codec, speaker_nid, 0,
8504 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8505 snd_hda_codec_write(codec, 0x0f, 0,
8506 AC_VERB_SET_AMP_GAIN_MUTE,
8507 AMP_IN_UNMUTE(1));
8508 snd_hda_codec_write(codec, 0x10, 0,
8509 AC_VERB_SET_AMP_GAIN_MUTE,
8510 AMP_IN_UNMUTE(1));
8511 } else {
8512 snd_hda_codec_write(codec, 0x0f, 0,
8513 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8514 snd_hda_codec_write(codec, 0x10, 0,
8515 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8516 }
8517
8518 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8519 if (line_nid == 0x14)
8520 dac_vol2 = AMP_OUT_ZERO;
8521 else if (line_nid == 0x15)
8522 dac_vol1 = AMP_OUT_ZERO;
8523 if (hp_nid == 0x14)
8524 dac_vol2 = AMP_OUT_ZERO;
8525 else if (hp_nid == 0x15)
8526 dac_vol1 = AMP_OUT_ZERO;
8527 if (line_nid != 0x16 || hp_nid != 0x16 ||
8528 spec->autocfg.line_out_pins[1] != 0x16 ||
8529 spec->autocfg.line_out_pins[2] != 0x16)
8530 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8531
8532 snd_hda_codec_write(codec, 0x02, 0,
8533 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8534 snd_hda_codec_write(codec, 0x03, 0,
8535 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8536}
8537
8538/* pcm configuration: identiacal with ALC880 */
8539#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8540#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8541#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8542
8543/*
8544 * BIOS auto configuration
8545 */
8546static int alc268_parse_auto_config(struct hda_codec *codec)
8547{
8548 struct alc_spec *spec = codec->spec;
8549 int err;
8550 static hda_nid_t alc268_ignore[] = { 0 };
8551
8552 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8553 alc268_ignore);
8554 if (err < 0)
8555 return err;
8556 if (!spec->autocfg.line_outs)
8557 return 0; /* can't find valid BIOS pin config */
8558
8559 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8560 if (err < 0)
8561 return err;
8562 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8563 if (err < 0)
8564 return err;
8565
8566 spec->multiout.max_channels = 2;
8567
8568 /* digital only support output */
8569 if (spec->autocfg.dig_out_pin)
8570 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8571
8572 if (spec->kctl_alloc)
8573 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8574
8575 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8576 spec->num_mux_defs = 1;
8577 spec->input_mux = &spec->private_imux;
8578
8579 return 1;
8580}
8581
8582#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8583#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8584#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8585
8586/* init callback for auto-configuration model -- overriding the default init */
8587static void alc268_auto_init(struct hda_codec *codec)
8588{
8589 alc268_auto_init_multi_out(codec);
8590 alc268_auto_init_hp_out(codec);
8591 alc268_auto_init_mono_speaker_out(codec);
8592 alc268_auto_init_analog_input(codec);
8593}
8594
8595/*
8596 * configuration and preset
8597 */
8598static const char *alc268_models[ALC268_MODEL_LAST] = {
8599 [ALC268_3ST] = "3stack",
8600 [ALC268_AUTO] = "auto",
8601};
8602
8603static struct snd_pci_quirk alc268_cfg_tbl[] = {
8604 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8605 {}
8606};
8607
8608static struct alc_config_preset alc268_presets[] = {
8609 [ALC268_3ST] = {
8610 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8611 .init_verbs = { alc268_base_init_verbs },
8612 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8613 .dac_nids = alc268_dac_nids,
8614 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8615 .adc_nids = alc268_adc_nids_alt,
8616 .hp_nid = 0x03,
8617 .dig_out_nid = ALC268_DIGOUT_NID,
8618 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8619 .channel_mode = alc268_modes,
8620 .input_mux = &alc268_capture_source,
8621 },
8622};
8623
8624static int patch_alc268(struct hda_codec *codec)
8625{
8626 struct alc_spec *spec;
8627 int board_config;
8628 int err;
8629
8630 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8631 if (spec == NULL)
8632 return -ENOMEM;
8633
8634 codec->spec = spec;
8635
8636 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8637 alc268_models,
8638 alc268_cfg_tbl);
8639
8640 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8641 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8642 "trying auto-probe from BIOS...\n");
8643 board_config = ALC268_AUTO;
8644 }
8645
8646 if (board_config == ALC268_AUTO) {
8647 /* automatic parse from the BIOS config */
8648 err = alc268_parse_auto_config(codec);
8649 if (err < 0) {
8650 alc_free(codec);
8651 return err;
8652 } else if (!err) {
8653 printk(KERN_INFO
8654 "hda_codec: Cannot set up configuration "
8655 "from BIOS. Using base mode...\n");
8656 board_config = ALC268_3ST;
8657 }
8658 }
8659
8660 if (board_config != ALC268_AUTO)
8661 setup_preset(spec, &alc268_presets[board_config]);
8662
8663 spec->stream_name_analog = "ALC268 Analog";
8664 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8665 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8666
8667 spec->stream_name_digital = "ALC268 Digital";
8668 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8669
8670 if (board_config == ALC268_AUTO) {
8671 if (!spec->adc_nids && spec->input_mux) {
8672 /* check whether NID 0x07 is valid */
8673 unsigned int wcap = get_wcaps(codec, 0x07);
8674
8675 /* get type */
8676 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8677 if (wcap != AC_WID_AUD_IN) {
8678 spec->adc_nids = alc268_adc_nids_alt;
8679 spec->num_adc_nids =
8680 ARRAY_SIZE(alc268_adc_nids_alt);
8681 spec->mixers[spec->num_mixers] =
8682 alc268_capture_alt_mixer;
8683 spec->num_mixers++;
8684 } else {
8685 spec->adc_nids = alc268_adc_nids;
8686 spec->num_adc_nids =
8687 ARRAY_SIZE(alc268_adc_nids);
8688 spec->mixers[spec->num_mixers] =
8689 alc268_capture_mixer;
8690 spec->num_mixers++;
8691 }
8692 }
8693 }
8694 codec->patch_ops = alc_patch_ops;
8695 if (board_config == ALC268_AUTO)
8696 spec->init_hook = alc268_auto_init;
8697
8698 return 0;
8699}
8700
8701/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008702 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8703 */
8704
8705/*
8706 * set the path ways for 2 channel output
8707 * need to set the codec line out and mic 1 pin widgets to inputs
8708 */
8709static struct hda_verb alc861_threestack_ch2_init[] = {
8710 /* set pin widget 1Ah (line in) for input */
8711 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008712 /* set pin widget 18h (mic1/2) for input, for mic also enable
8713 * the vref
8714 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008715 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8716
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008717 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8718#if 0
8719 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8720 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8721#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008722 { } /* end */
8723};
8724/*
8725 * 6ch mode
8726 * need to set the codec line out and mic 1 pin widgets to outputs
8727 */
8728static struct hda_verb alc861_threestack_ch6_init[] = {
8729 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8730 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8731 /* set pin widget 18h (mic1) for output (CLFE)*/
8732 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8733
8734 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008735 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008736
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008737 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8738#if 0
8739 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8740 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8741#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008742 { } /* end */
8743};
8744
8745static struct hda_channel_mode alc861_threestack_modes[2] = {
8746 { 2, alc861_threestack_ch2_init },
8747 { 6, alc861_threestack_ch6_init },
8748};
Takashi Iwai22309c32006-08-09 16:57:28 +02008749/* Set mic1 as input and unmute the mixer */
8750static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8751 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8752 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8753 { } /* end */
8754};
8755/* Set mic1 as output and mute mixer */
8756static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8757 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8758 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8759 { } /* end */
8760};
8761
8762static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8763 { 2, alc861_uniwill_m31_ch2_init },
8764 { 4, alc861_uniwill_m31_ch4_init },
8765};
Kailang Yangdf694da2005-12-05 19:42:22 +01008766
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008767/* Set mic1 and line-in as input and unmute the mixer */
8768static struct hda_verb alc861_asus_ch2_init[] = {
8769 /* set pin widget 1Ah (line in) for input */
8770 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008771 /* set pin widget 18h (mic1/2) for input, for mic also enable
8772 * the vref
8773 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008774 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8775
8776 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8777#if 0
8778 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8779 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8780#endif
8781 { } /* end */
8782};
8783/* Set mic1 nad line-in as output and mute mixer */
8784static struct hda_verb alc861_asus_ch6_init[] = {
8785 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8786 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8787 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8788 /* set pin widget 18h (mic1) for output (CLFE)*/
8789 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8790 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8791 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8792 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8793
8794 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8795#if 0
8796 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8797 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8798#endif
8799 { } /* end */
8800};
8801
8802static struct hda_channel_mode alc861_asus_modes[2] = {
8803 { 2, alc861_asus_ch2_init },
8804 { 6, alc861_asus_ch6_init },
8805};
8806
Kailang Yangdf694da2005-12-05 19:42:22 +01008807/* patch-ALC861 */
8808
8809static struct snd_kcontrol_new alc861_base_mixer[] = {
8810 /* output mixer control */
8811 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8812 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8813 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8814 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8815 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8816
8817 /*Input mixer control */
8818 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8819 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8820 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8821 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8822 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8823 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8825 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8826 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008828
Kailang Yangdf694da2005-12-05 19:42:22 +01008829 /* Capture mixer control */
8830 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8831 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8832 {
8833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8834 .name = "Capture Source",
8835 .count = 1,
8836 .info = alc_mux_enum_info,
8837 .get = alc_mux_enum_get,
8838 .put = alc_mux_enum_put,
8839 },
8840 { } /* end */
8841};
8842
8843static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8844 /* output mixer control */
8845 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8846 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8847 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8848 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8849 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8850
8851 /* Input mixer control */
8852 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8853 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8854 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8855 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8856 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8857 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8859 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008862
Kailang Yangdf694da2005-12-05 19:42:22 +01008863 /* Capture mixer control */
8864 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8865 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8866 {
8867 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8868 .name = "Capture Source",
8869 .count = 1,
8870 .info = alc_mux_enum_info,
8871 .get = alc_mux_enum_get,
8872 .put = alc_mux_enum_put,
8873 },
8874 {
8875 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8876 .name = "Channel Mode",
8877 .info = alc_ch_mode_info,
8878 .get = alc_ch_mode_get,
8879 .put = alc_ch_mode_put,
8880 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8881 },
8882 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008883};
8884
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008885static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008886 /* output mixer control */
8887 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8889 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8890
8891 /*Capture mixer control */
8892 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8893 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8894 {
8895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8896 .name = "Capture Source",
8897 .count = 1,
8898 .info = alc_mux_enum_info,
8899 .get = alc_mux_enum_get,
8900 .put = alc_mux_enum_put,
8901 },
8902
8903 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008904};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008905
Takashi Iwai22309c32006-08-09 16:57:28 +02008906static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8907 /* output mixer control */
8908 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8909 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8910 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8911 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8912 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8913
8914 /* Input mixer control */
8915 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8916 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8917 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8918 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8919 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8920 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8922 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8923 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8924 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008925
Takashi Iwai22309c32006-08-09 16:57:28 +02008926 /* Capture mixer control */
8927 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8928 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8929 {
8930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8931 .name = "Capture Source",
8932 .count = 1,
8933 .info = alc_mux_enum_info,
8934 .get = alc_mux_enum_get,
8935 .put = alc_mux_enum_put,
8936 },
8937 {
8938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8939 .name = "Channel Mode",
8940 .info = alc_ch_mode_info,
8941 .get = alc_ch_mode_get,
8942 .put = alc_ch_mode_put,
8943 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8944 },
8945 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008946};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008947
8948static struct snd_kcontrol_new alc861_asus_mixer[] = {
8949 /* output mixer control */
8950 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8951 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8952 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8953 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8954 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8955
8956 /* Input mixer control */
8957 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8958 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8959 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8960 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8961 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8962 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8964 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8965 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8967
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008968 /* Capture mixer control */
8969 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8970 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8971 {
8972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8973 .name = "Capture Source",
8974 .count = 1,
8975 .info = alc_mux_enum_info,
8976 .get = alc_mux_enum_get,
8977 .put = alc_mux_enum_put,
8978 },
8979 {
8980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8981 .name = "Channel Mode",
8982 .info = alc_ch_mode_info,
8983 .get = alc_ch_mode_get,
8984 .put = alc_ch_mode_put,
8985 .private_value = ARRAY_SIZE(alc861_asus_modes),
8986 },
8987 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008988};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008989
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008990/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008991static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008992 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8993 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8994 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8995 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8996 { }
8997};
8998
Kailang Yangdf694da2005-12-05 19:42:22 +01008999/*
9000 * generic initialization of ADC, input mixers and output mixers
9001 */
9002static struct hda_verb alc861_base_init_verbs[] = {
9003 /*
9004 * Unmute ADC0 and set the default input to mic-in
9005 */
9006 /* port-A for surround (rear panel) */
9007 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9008 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9009 /* port-B for mic-in (rear panel) with vref */
9010 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9011 /* port-C for line-in (rear panel) */
9012 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9013 /* port-D for Front */
9014 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9015 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9016 /* port-E for HP out (front panel) */
9017 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9018 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009019 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009020 /* port-F for mic-in (front panel) with vref */
9021 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9022 /* port-G for CLFE (rear panel) */
9023 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9024 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9025 /* port-H for side (rear panel) */
9026 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9027 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9028 /* CD-in */
9029 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9030 /* route front mic to ADC1*/
9031 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9032 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9033
9034 /* Unmute DAC0~3 & spdif out*/
9035 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9036 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9037 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9038 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9039 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9040
9041 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9042 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9043 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9044 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9045 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9046
9047 /* Unmute Stereo Mixer 15 */
9048 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9049 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009052
9053 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9054 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9056 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9057 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9058 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9060 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009061 /* hp used DAC 3 (Front) */
9062 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009063 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9064
9065 { }
9066};
9067
9068static struct hda_verb alc861_threestack_init_verbs[] = {
9069 /*
9070 * Unmute ADC0 and set the default input to mic-in
9071 */
9072 /* port-A for surround (rear panel) */
9073 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9074 /* port-B for mic-in (rear panel) with vref */
9075 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9076 /* port-C for line-in (rear panel) */
9077 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9078 /* port-D for Front */
9079 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9080 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9081 /* port-E for HP out (front panel) */
9082 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9083 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009084 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009085 /* port-F for mic-in (front panel) with vref */
9086 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9087 /* port-G for CLFE (rear panel) */
9088 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9089 /* port-H for side (rear panel) */
9090 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9091 /* CD-in */
9092 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9093 /* route front mic to ADC1*/
9094 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9096 /* Unmute DAC0~3 & spdif out*/
9097 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9098 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9099 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9100 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9102
9103 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9104 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9105 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9106 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9107 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9108
9109 /* Unmute Stereo Mixer 15 */
9110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009114
9115 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9116 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9117 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9118 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9121 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009123 /* hp used DAC 3 (Front) */
9124 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9126 { }
9127};
Takashi Iwai22309c32006-08-09 16:57:28 +02009128
9129static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9130 /*
9131 * Unmute ADC0 and set the default input to mic-in
9132 */
9133 /* port-A for surround (rear panel) */
9134 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9135 /* port-B for mic-in (rear panel) with vref */
9136 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9137 /* port-C for line-in (rear panel) */
9138 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9139 /* port-D for Front */
9140 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9141 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9142 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009143 /* this has to be set to VREF80 */
9144 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009145 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009146 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009147 /* port-F for mic-in (front panel) with vref */
9148 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9149 /* port-G for CLFE (rear panel) */
9150 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9151 /* port-H for side (rear panel) */
9152 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9153 /* CD-in */
9154 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9155 /* route front mic to ADC1*/
9156 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9158 /* Unmute DAC0~3 & spdif out*/
9159 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9160 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9161 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9162 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9164
9165 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9166 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9167 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9168 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9169 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9170
9171 /* Unmute Stereo Mixer 15 */
9172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02009176
9177 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9179 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9180 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9182 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9184 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009185 /* hp used DAC 3 (Front) */
9186 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009187 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9188 { }
9189};
9190
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009191static struct hda_verb alc861_asus_init_verbs[] = {
9192 /*
9193 * Unmute ADC0 and set the default input to mic-in
9194 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009195 /* port-A for surround (rear panel)
9196 * according to codec#0 this is the HP jack
9197 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009198 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9199 /* route front PCM to HP */
9200 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9201 /* port-B for mic-in (rear panel) with vref */
9202 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9203 /* port-C for line-in (rear panel) */
9204 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9205 /* port-D for Front */
9206 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9207 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9208 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009209 /* this has to be set to VREF80 */
9210 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009211 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009212 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009213 /* port-F for mic-in (front panel) with vref */
9214 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9215 /* port-G for CLFE (rear panel) */
9216 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9217 /* port-H for side (rear panel) */
9218 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9219 /* CD-in */
9220 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9221 /* route front mic to ADC1*/
9222 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9224 /* Unmute DAC0~3 & spdif out*/
9225 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9226 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9227 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9228 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9230 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9231 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9232 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9233 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9234 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9235
9236 /* Unmute Stereo Mixer 15 */
9237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009241
9242 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9243 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9244 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9246 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9247 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9248 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9249 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009250 /* hp used DAC 3 (Front) */
9251 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9253 { }
9254};
9255
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009256/* additional init verbs for ASUS laptops */
9257static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9258 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9259 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9260 { }
9261};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009262
Kailang Yangdf694da2005-12-05 19:42:22 +01009263/*
9264 * generic initialization of ADC, input mixers and output mixers
9265 */
9266static struct hda_verb alc861_auto_init_verbs[] = {
9267 /*
9268 * Unmute ADC0 and set the default input to mic-in
9269 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009270 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9272
9273 /* Unmute DAC0~3 & spdif out*/
9274 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9275 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9276 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9277 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9279
9280 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9281 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9282 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9283 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9284 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9285
9286 /* Unmute Stereo Mixer 15 */
9287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9291
9292 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9294 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9295 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9299 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9300
9301 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9302 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009303 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009305 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9306 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009307 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009309
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009310 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009311
9312 { }
9313};
9314
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009315static struct hda_verb alc861_toshiba_init_verbs[] = {
9316 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009317
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009318 { }
9319};
9320
9321/* toggle speaker-output according to the hp-jack state */
9322static void alc861_toshiba_automute(struct hda_codec *codec)
9323{
9324 unsigned int present;
9325
9326 present = snd_hda_codec_read(codec, 0x0f, 0,
9327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9328 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
9329 0x80, present ? 0x80 : 0);
9330 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
9331 0x80, present ? 0x80 : 0);
9332 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
9333 0x80, present ? 0 : 0x80);
9334 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
9335 0x80, present ? 0 : 0x80);
9336}
9337
9338static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9339 unsigned int res)
9340{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009341 if ((res >> 26) == ALC880_HP_EVENT)
9342 alc861_toshiba_automute(codec);
9343}
9344
Kailang Yangdf694da2005-12-05 19:42:22 +01009345/* pcm configuration: identiacal with ALC880 */
9346#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9347#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9348#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9349#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9350
9351
9352#define ALC861_DIGOUT_NID 0x07
9353
9354static struct hda_channel_mode alc861_8ch_modes[1] = {
9355 { 8, NULL }
9356};
9357
9358static hda_nid_t alc861_dac_nids[4] = {
9359 /* front, surround, clfe, side */
9360 0x03, 0x06, 0x05, 0x04
9361};
9362
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009363static hda_nid_t alc660_dac_nids[3] = {
9364 /* front, clfe, surround */
9365 0x03, 0x05, 0x06
9366};
9367
Kailang Yangdf694da2005-12-05 19:42:22 +01009368static hda_nid_t alc861_adc_nids[1] = {
9369 /* ADC0-2 */
9370 0x08,
9371};
9372
9373static struct hda_input_mux alc861_capture_source = {
9374 .num_items = 5,
9375 .items = {
9376 { "Mic", 0x0 },
9377 { "Front Mic", 0x3 },
9378 { "Line", 0x1 },
9379 { "CD", 0x4 },
9380 { "Mixer", 0x5 },
9381 },
9382};
9383
9384/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009385static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9386 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009387{
9388 int i;
9389 hda_nid_t nid;
9390
9391 spec->multiout.dac_nids = spec->private_dac_nids;
9392 for (i = 0; i < cfg->line_outs; i++) {
9393 nid = cfg->line_out_pins[i];
9394 if (nid) {
9395 if (i >= ARRAY_SIZE(alc861_dac_nids))
9396 continue;
9397 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9398 }
9399 }
9400 spec->multiout.num_dacs = cfg->line_outs;
9401 return 0;
9402}
9403
9404/* add playback controls from the parsed DAC table */
9405static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9406 const struct auto_pin_cfg *cfg)
9407{
9408 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009409 static const char *chname[4] = {
9410 "Front", "Surround", NULL /*CLFE*/, "Side"
9411 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009412 hda_nid_t nid;
9413 int i, idx, err;
9414
9415 for (i = 0; i < cfg->line_outs; i++) {
9416 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009417 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009418 continue;
9419 if (nid == 0x05) {
9420 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009421 err = add_control(spec, ALC_CTL_BIND_MUTE,
9422 "Center Playback Switch",
9423 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9424 HDA_OUTPUT));
9425 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009426 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009427 err = add_control(spec, ALC_CTL_BIND_MUTE,
9428 "LFE Playback Switch",
9429 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9430 HDA_OUTPUT));
9431 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009432 return err;
9433 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009434 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9435 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009436 if (nid == alc861_dac_nids[idx])
9437 break;
9438 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009439 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9440 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9441 HDA_OUTPUT));
9442 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009443 return err;
9444 }
9445 }
9446 return 0;
9447}
9448
9449static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9450{
9451 int err;
9452 hda_nid_t nid;
9453
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009454 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009455 return 0;
9456
9457 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9458 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009459 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9460 "Headphone Playback Switch",
9461 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9462 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009463 return err;
9464 spec->multiout.hp_nid = nid;
9465 }
9466 return 0;
9467}
9468
9469/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009470static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9471 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009472{
Kailang Yangdf694da2005-12-05 19:42:22 +01009473 struct hda_input_mux *imux = &spec->private_imux;
9474 int i, err, idx, idx1;
9475
9476 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009477 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009478 case 0x0c:
9479 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009480 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009481 break;
9482 case 0x0f:
9483 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009484 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009485 break;
9486 case 0x0d:
9487 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009488 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009489 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009490 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009491 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009492 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009493 break;
9494 case 0x11:
9495 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009496 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009497 break;
9498 default:
9499 continue;
9500 }
9501
Takashi Iwai4a471b72005-12-07 13:56:29 +01009502 err = new_analog_input(spec, cfg->input_pins[i],
9503 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009504 if (err < 0)
9505 return err;
9506
Takashi Iwai4a471b72005-12-07 13:56:29 +01009507 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009508 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009509 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009510 }
9511 return 0;
9512}
9513
9514static struct snd_kcontrol_new alc861_capture_mixer[] = {
9515 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9516 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9517
9518 {
9519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9520 /* The multiple "Capture Source" controls confuse alsamixer
9521 * So call somewhat different..
9522 *FIXME: the controls appear in the "playback" view!
9523 */
9524 /* .name = "Capture Source", */
9525 .name = "Input Source",
9526 .count = 1,
9527 .info = alc_mux_enum_info,
9528 .get = alc_mux_enum_get,
9529 .put = alc_mux_enum_put,
9530 },
9531 { } /* end */
9532};
9533
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009534static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9535 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009536 int pin_type, int dac_idx)
9537{
9538 /* set as output */
9539
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009540 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9541 pin_type);
9542 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9543 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009544
9545}
9546
9547static void alc861_auto_init_multi_out(struct hda_codec *codec)
9548{
9549 struct alc_spec *spec = codec->spec;
9550 int i;
9551
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009552 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009553 for (i = 0; i < spec->autocfg.line_outs; i++) {
9554 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009555 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009556 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009557 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009558 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009559 }
9560}
9561
9562static void alc861_auto_init_hp_out(struct hda_codec *codec)
9563{
9564 struct alc_spec *spec = codec->spec;
9565 hda_nid_t pin;
9566
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009567 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009568 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009569 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9570 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009571}
9572
9573static void alc861_auto_init_analog_input(struct hda_codec *codec)
9574{
9575 struct alc_spec *spec = codec->spec;
9576 int i;
9577
9578 for (i = 0; i < AUTO_PIN_LAST; i++) {
9579 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009580 if (nid >= 0x0c && nid <= 0x11) {
9581 snd_hda_codec_write(codec, nid, 0,
9582 AC_VERB_SET_PIN_WIDGET_CONTROL,
9583 i <= AUTO_PIN_FRONT_MIC ?
9584 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009585 }
9586 }
9587}
9588
9589/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009590/* return 1 if successful, 0 if the proper config is not found,
9591 * or a negative error code
9592 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009593static int alc861_parse_auto_config(struct hda_codec *codec)
9594{
9595 struct alc_spec *spec = codec->spec;
9596 int err;
9597 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9598
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009599 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9600 alc861_ignore);
9601 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009602 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009603 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009604 return 0; /* can't find valid BIOS pin config */
9605
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009606 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9607 if (err < 0)
9608 return err;
9609 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9610 if (err < 0)
9611 return err;
9612 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9613 if (err < 0)
9614 return err;
9615 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9616 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009617 return err;
9618
9619 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9620
9621 if (spec->autocfg.dig_out_pin)
9622 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9623
9624 if (spec->kctl_alloc)
9625 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9626
9627 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9628
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009629 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009630 spec->input_mux = &spec->private_imux;
9631
9632 spec->adc_nids = alc861_adc_nids;
9633 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9634 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9635 spec->num_mixers++;
9636
9637 return 1;
9638}
9639
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009640/* additional initialization for auto-configuration model */
9641static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009642{
Kailang Yangdf694da2005-12-05 19:42:22 +01009643 alc861_auto_init_multi_out(codec);
9644 alc861_auto_init_hp_out(codec);
9645 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009646}
9647
9648
9649/*
9650 * configuration and preset
9651 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009652static const char *alc861_models[ALC861_MODEL_LAST] = {
9653 [ALC861_3ST] = "3stack",
9654 [ALC660_3ST] = "3stack-660",
9655 [ALC861_3ST_DIG] = "3stack-dig",
9656 [ALC861_6ST_DIG] = "6stack-dig",
9657 [ALC861_UNIWILL_M31] = "uniwill-m31",
9658 [ALC861_TOSHIBA] = "toshiba",
9659 [ALC861_ASUS] = "asus",
9660 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9661 [ALC861_AUTO] = "auto",
9662};
9663
9664static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009665 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009666 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9667 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009668 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +02009669 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009670 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +02009671 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +01009672 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +02009673 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9674 * Any other models that need this preset?
9675 */
9676 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009677 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009678 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009679 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009680 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009681 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Claudio Matsuokaef64adb2007-07-14 00:26:16 +02009682 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9683 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009684 {}
9685};
9686
9687static struct alc_config_preset alc861_presets[] = {
9688 [ALC861_3ST] = {
9689 .mixers = { alc861_3ST_mixer },
9690 .init_verbs = { alc861_threestack_init_verbs },
9691 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9692 .dac_nids = alc861_dac_nids,
9693 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9694 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009695 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009696 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9697 .adc_nids = alc861_adc_nids,
9698 .input_mux = &alc861_capture_source,
9699 },
9700 [ALC861_3ST_DIG] = {
9701 .mixers = { alc861_base_mixer },
9702 .init_verbs = { alc861_threestack_init_verbs },
9703 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9704 .dac_nids = alc861_dac_nids,
9705 .dig_out_nid = ALC861_DIGOUT_NID,
9706 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9707 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009708 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009709 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9710 .adc_nids = alc861_adc_nids,
9711 .input_mux = &alc861_capture_source,
9712 },
9713 [ALC861_6ST_DIG] = {
9714 .mixers = { alc861_base_mixer },
9715 .init_verbs = { alc861_base_init_verbs },
9716 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9717 .dac_nids = alc861_dac_nids,
9718 .dig_out_nid = ALC861_DIGOUT_NID,
9719 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9720 .channel_mode = alc861_8ch_modes,
9721 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9722 .adc_nids = alc861_adc_nids,
9723 .input_mux = &alc861_capture_source,
9724 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009725 [ALC660_3ST] = {
9726 .mixers = { alc861_3ST_mixer },
9727 .init_verbs = { alc861_threestack_init_verbs },
9728 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9729 .dac_nids = alc660_dac_nids,
9730 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9731 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009732 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009733 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9734 .adc_nids = alc861_adc_nids,
9735 .input_mux = &alc861_capture_source,
9736 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009737 [ALC861_UNIWILL_M31] = {
9738 .mixers = { alc861_uniwill_m31_mixer },
9739 .init_verbs = { alc861_uniwill_m31_init_verbs },
9740 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9741 .dac_nids = alc861_dac_nids,
9742 .dig_out_nid = ALC861_DIGOUT_NID,
9743 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9744 .channel_mode = alc861_uniwill_m31_modes,
9745 .need_dac_fix = 1,
9746 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9747 .adc_nids = alc861_adc_nids,
9748 .input_mux = &alc861_capture_source,
9749 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009750 [ALC861_TOSHIBA] = {
9751 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009752 .init_verbs = { alc861_base_init_verbs,
9753 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009754 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9755 .dac_nids = alc861_dac_nids,
9756 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9757 .channel_mode = alc883_3ST_2ch_modes,
9758 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9759 .adc_nids = alc861_adc_nids,
9760 .input_mux = &alc861_capture_source,
9761 .unsol_event = alc861_toshiba_unsol_event,
9762 .init_hook = alc861_toshiba_automute,
9763 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009764 [ALC861_ASUS] = {
9765 .mixers = { alc861_asus_mixer },
9766 .init_verbs = { alc861_asus_init_verbs },
9767 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9768 .dac_nids = alc861_dac_nids,
9769 .dig_out_nid = ALC861_DIGOUT_NID,
9770 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9771 .channel_mode = alc861_asus_modes,
9772 .need_dac_fix = 1,
9773 .hp_nid = 0x06,
9774 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9775 .adc_nids = alc861_adc_nids,
9776 .input_mux = &alc861_capture_source,
9777 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009778 [ALC861_ASUS_LAPTOP] = {
9779 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9780 .init_verbs = { alc861_asus_init_verbs,
9781 alc861_asus_laptop_init_verbs },
9782 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9783 .dac_nids = alc861_dac_nids,
9784 .dig_out_nid = ALC861_DIGOUT_NID,
9785 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9786 .channel_mode = alc883_3ST_2ch_modes,
9787 .need_dac_fix = 1,
9788 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9789 .adc_nids = alc861_adc_nids,
9790 .input_mux = &alc861_capture_source,
9791 },
9792};
Kailang Yangdf694da2005-12-05 19:42:22 +01009793
9794
9795static int patch_alc861(struct hda_codec *codec)
9796{
9797 struct alc_spec *spec;
9798 int board_config;
9799 int err;
9800
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009801 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009802 if (spec == NULL)
9803 return -ENOMEM;
9804
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009805 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009806
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009807 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9808 alc861_models,
9809 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009810
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009811 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009812 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9813 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009814 board_config = ALC861_AUTO;
9815 }
9816
9817 if (board_config == ALC861_AUTO) {
9818 /* automatic parse from the BIOS config */
9819 err = alc861_parse_auto_config(codec);
9820 if (err < 0) {
9821 alc_free(codec);
9822 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009823 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009824 printk(KERN_INFO
9825 "hda_codec: Cannot set up configuration "
9826 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009827 board_config = ALC861_3ST_DIG;
9828 }
9829 }
9830
9831 if (board_config != ALC861_AUTO)
9832 setup_preset(spec, &alc861_presets[board_config]);
9833
9834 spec->stream_name_analog = "ALC861 Analog";
9835 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9836 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9837
9838 spec->stream_name_digital = "ALC861 Digital";
9839 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9840 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9841
9842 codec->patch_ops = alc_patch_ops;
9843 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009844 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009845
9846 return 0;
9847}
9848
9849/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009850 * ALC861-VD support
9851 *
9852 * Based on ALC882
9853 *
9854 * In addition, an independent DAC
9855 */
9856#define ALC861VD_DIGOUT_NID 0x06
9857
9858static hda_nid_t alc861vd_dac_nids[4] = {
9859 /* front, surr, clfe, side surr */
9860 0x02, 0x03, 0x04, 0x05
9861};
9862
9863/* dac_nids for ALC660vd are in a different order - according to
9864 * Realtek's driver.
9865 * This should probably tesult in a different mixer for 6stack models
9866 * of ALC660vd codecs, but for now there is only 3stack mixer
9867 * - and it is the same as in 861vd.
9868 * adc_nids in ALC660vd are (is) the same as in 861vd
9869 */
9870static hda_nid_t alc660vd_dac_nids[3] = {
9871 /* front, rear, clfe, rear_surr */
9872 0x02, 0x04, 0x03
9873};
9874
9875static hda_nid_t alc861vd_adc_nids[1] = {
9876 /* ADC0 */
9877 0x09,
9878};
9879
9880/* input MUX */
9881/* FIXME: should be a matrix-type input source selection */
9882static struct hda_input_mux alc861vd_capture_source = {
9883 .num_items = 4,
9884 .items = {
9885 { "Mic", 0x0 },
9886 { "Front Mic", 0x1 },
9887 { "Line", 0x2 },
9888 { "CD", 0x4 },
9889 },
9890};
9891
Kailang Yang272a5272007-05-14 11:00:38 +02009892static struct hda_input_mux alc861vd_dallas_capture_source = {
9893 .num_items = 3,
9894 .items = {
9895 { "Front Mic", 0x0 },
9896 { "ATAPI Mic", 0x1 },
9897 { "Line In", 0x5 },
9898 },
9899};
9900
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009901#define alc861vd_mux_enum_info alc_mux_enum_info
9902#define alc861vd_mux_enum_get alc_mux_enum_get
9903
9904static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9905 struct snd_ctl_elem_value *ucontrol)
9906{
9907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9908 struct alc_spec *spec = codec->spec;
9909 const struct hda_input_mux *imux = spec->input_mux;
9910 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9911 static hda_nid_t capture_mixers[1] = { 0x22 };
9912 hda_nid_t nid = capture_mixers[adc_idx];
9913 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9914 unsigned int i, idx;
9915
9916 idx = ucontrol->value.enumerated.item[0];
9917 if (idx >= imux->num_items)
9918 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009919 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009920 return 0;
9921 for (i = 0; i < imux->num_items; i++) {
9922 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9923 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9924 v | (imux->items[i].index << 8));
9925 }
9926 *cur_val = idx;
9927 return 1;
9928}
9929
9930/*
9931 * 2ch mode
9932 */
9933static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9934 { 2, NULL }
9935};
9936
9937/*
9938 * 6ch mode
9939 */
9940static struct hda_verb alc861vd_6stack_ch6_init[] = {
9941 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9942 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9943 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9944 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9945 { } /* end */
9946};
9947
9948/*
9949 * 8ch mode
9950 */
9951static struct hda_verb alc861vd_6stack_ch8_init[] = {
9952 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9953 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9954 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9955 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9956 { } /* end */
9957};
9958
9959static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9960 { 6, alc861vd_6stack_ch6_init },
9961 { 8, alc861vd_6stack_ch8_init },
9962};
9963
9964static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9965 {
9966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9967 .name = "Channel Mode",
9968 .info = alc_ch_mode_info,
9969 .get = alc_ch_mode_get,
9970 .put = alc_ch_mode_put,
9971 },
9972 { } /* end */
9973};
9974
9975static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9976 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9977 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9978
9979 {
9980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9981 /* The multiple "Capture Source" controls confuse alsamixer
9982 * So call somewhat different..
9983 *FIXME: the controls appear in the "playback" view!
9984 */
9985 /* .name = "Capture Source", */
9986 .name = "Input Source",
9987 .count = 1,
9988 .info = alc861vd_mux_enum_info,
9989 .get = alc861vd_mux_enum_get,
9990 .put = alc861vd_mux_enum_put,
9991 },
9992 { } /* end */
9993};
9994
9995/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9996 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9997 */
9998static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9999 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10000 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10001
10002 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10003 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10004
10005 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10006 HDA_OUTPUT),
10007 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10008 HDA_OUTPUT),
10009 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10010 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10011
10012 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10013 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10014
10015 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10016
10017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10020
10021 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10022 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10023 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10024
10025 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10026 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10027
10028 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10029 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10030
10031 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10032 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10033
10034 { } /* end */
10035};
10036
10037static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10038 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10040
10041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10042
10043 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10046
10047 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10048 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10050
10051 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10052 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10053
10054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10056
10057 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10058 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10059
10060 { } /* end */
10061};
10062
Kailang Yangbdd148a2007-05-08 15:19:08 +020010063static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10064 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10065 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10066 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10067
10068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10069
10070 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10073
10074 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10075 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10076 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10077
10078 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10079 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10080
10081 { } /* end */
10082};
10083
Kailang Yang272a5272007-05-14 11:00:38 +020010084/* Pin assignment: Front=0x14, HP = 0x15,
10085 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10086 */
10087static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10088 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10089 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10090 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10091 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10092 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10093 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10094 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10095 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10096 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10097 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10098 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10099 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10100 {
10101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10102 /* .name = "Capture Source", */
10103 .name = "Input Source",
10104 .count = 1,
10105 .info = alc882_mux_enum_info,
10106 .get = alc882_mux_enum_get,
10107 .put = alc882_mux_enum_put,
10108 },
10109 { } /* end */
10110};
10111
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010112/*
10113 * generic initialization of ADC, input mixers and output mixers
10114 */
10115static struct hda_verb alc861vd_volume_init_verbs[] = {
10116 /*
10117 * Unmute ADC0 and set the default input to mic-in
10118 */
10119 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10121
10122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10123 * the analog-loopback mixer widget
10124 */
10125 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10131
10132 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020010133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010137
10138 /*
10139 * Set up output mixers (0x02 - 0x05)
10140 */
10141 /* set vol=0 to output mixers */
10142 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10143 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10144 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10145 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10146
10147 /* set up input amps for analog loopback */
10148 /* Amp Indices: DAC = 0, mixer = 1 */
10149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10151 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10152 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10153 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10154 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10155 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10156 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10157
10158 { }
10159};
10160
10161/*
10162 * 3-stack pin configuration:
10163 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10164 */
10165static struct hda_verb alc861vd_3stack_init_verbs[] = {
10166 /*
10167 * Set pin mode and muting
10168 */
10169 /* set front pin widgets 0x14 for output */
10170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10171 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10172 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10173
10174 /* Mic (rear) pin: input vref at 80% */
10175 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10177 /* Front Mic pin: input vref at 80% */
10178 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10180 /* Line In pin: input */
10181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10183 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10185 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10186 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10187 /* CD pin widget for input */
10188 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10189
10190 { }
10191};
10192
10193/*
10194 * 6-stack pin configuration:
10195 */
10196static struct hda_verb alc861vd_6stack_init_verbs[] = {
10197 /*
10198 * Set pin mode and muting
10199 */
10200 /* set front pin widgets 0x14 for output */
10201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10202 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10203 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10204
10205 /* Rear Pin: output 1 (0x0d) */
10206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10207 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10208 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10209 /* CLFE Pin: output 2 (0x0e) */
10210 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10211 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10212 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10213 /* Side Pin: output 3 (0x0f) */
10214 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10215 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10216 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10217
10218 /* Mic (rear) pin: input vref at 80% */
10219 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10220 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10221 /* Front Mic pin: input vref at 80% */
10222 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10224 /* Line In pin: input */
10225 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10227 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10228 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10229 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10230 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10231 /* CD pin widget for input */
10232 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10233
10234 { }
10235};
10236
Kailang Yangbdd148a2007-05-08 15:19:08 +020010237static struct hda_verb alc861vd_eapd_verbs[] = {
10238 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10239 { }
10240};
10241
10242static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10246 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10248 {}
10249};
10250
10251/* toggle speaker-output according to the hp-jack state */
10252static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10253{
10254 unsigned int present;
10255 unsigned char bits;
10256
10257 present = snd_hda_codec_read(codec, 0x1b, 0,
10258 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10259 bits = present ? 0x80 : 0;
10260 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10261 0x80, bits);
10262 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10263 0x80, bits);
10264}
10265
10266static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10267{
10268 unsigned int present;
10269 unsigned char bits;
10270
10271 present = snd_hda_codec_read(codec, 0x18, 0,
10272 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10273 bits = present ? 0x80 : 0;
10274 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10275 0x80, bits);
10276 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10277 0x80, bits);
10278}
10279
10280static void alc861vd_lenovo_automute(struct hda_codec *codec)
10281{
10282 alc861vd_lenovo_hp_automute(codec);
10283 alc861vd_lenovo_mic_automute(codec);
10284}
10285
10286static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10287 unsigned int res)
10288{
10289 switch (res >> 26) {
10290 case ALC880_HP_EVENT:
10291 alc861vd_lenovo_hp_automute(codec);
10292 break;
10293 case ALC880_MIC_EVENT:
10294 alc861vd_lenovo_mic_automute(codec);
10295 break;
10296 }
10297}
10298
Kailang Yang272a5272007-05-14 11:00:38 +020010299static struct hda_verb alc861vd_dallas_verbs[] = {
10300 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10301 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10302 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10303 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10304
10305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10313
10314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10316 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10318 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10319 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10320 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10321 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10322
10323 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10324 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10325 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10326 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10328 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10329 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10330 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10331
10332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10335 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10336
10337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10338 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10339 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10340
10341 { } /* end */
10342};
10343
10344/* toggle speaker-output according to the hp-jack state */
10345static void alc861vd_dallas_automute(struct hda_codec *codec)
10346{
10347 unsigned int present;
10348
10349 present = snd_hda_codec_read(codec, 0x15, 0,
10350 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10351 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10352 0x80, present ? 0x80 : 0);
10353 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10354 0x80, present ? 0x80 : 0);
10355}
10356
10357static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10358{
10359 if ((res >> 26) == ALC880_HP_EVENT)
10360 alc861vd_dallas_automute(codec);
10361}
10362
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010363/* pcm configuration: identiacal with ALC880 */
10364#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10365#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10366#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10367#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10368
10369/*
10370 * configuration and preset
10371 */
10372static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10373 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +020010374 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010375 [ALC861VD_3ST] = "3stack",
10376 [ALC861VD_3ST_DIG] = "3stack-digout",
10377 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010378 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010379 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010380 [ALC861VD_AUTO] = "auto",
10381};
10382
10383static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010384 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010385 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010386 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010387 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10388 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10389
Kailang Yang272a5272007-05-14 11:00:38 +020010390 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10391 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010392 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10393 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010394 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020010395 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010396 {}
10397};
10398
10399static struct alc_config_preset alc861vd_presets[] = {
10400 [ALC660VD_3ST] = {
10401 .mixers = { alc861vd_3st_mixer },
10402 .init_verbs = { alc861vd_volume_init_verbs,
10403 alc861vd_3stack_init_verbs },
10404 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10405 .dac_nids = alc660vd_dac_nids,
10406 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10407 .adc_nids = alc861vd_adc_nids,
10408 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10409 .channel_mode = alc861vd_3stack_2ch_modes,
10410 .input_mux = &alc861vd_capture_source,
10411 },
Mike Crash6963f842007-06-25 12:12:51 +020010412 [ALC660VD_3ST_DIG] = {
10413 .mixers = { alc861vd_3st_mixer },
10414 .init_verbs = { alc861vd_volume_init_verbs,
10415 alc861vd_3stack_init_verbs },
10416 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10417 .dac_nids = alc660vd_dac_nids,
10418 .dig_out_nid = ALC861VD_DIGOUT_NID,
10419 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10420 .adc_nids = alc861vd_adc_nids,
10421 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10422 .channel_mode = alc861vd_3stack_2ch_modes,
10423 .input_mux = &alc861vd_capture_source,
10424 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010425 [ALC861VD_3ST] = {
10426 .mixers = { alc861vd_3st_mixer },
10427 .init_verbs = { alc861vd_volume_init_verbs,
10428 alc861vd_3stack_init_verbs },
10429 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10430 .dac_nids = alc861vd_dac_nids,
10431 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10432 .channel_mode = alc861vd_3stack_2ch_modes,
10433 .input_mux = &alc861vd_capture_source,
10434 },
10435 [ALC861VD_3ST_DIG] = {
10436 .mixers = { alc861vd_3st_mixer },
10437 .init_verbs = { alc861vd_volume_init_verbs,
10438 alc861vd_3stack_init_verbs },
10439 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10440 .dac_nids = alc861vd_dac_nids,
10441 .dig_out_nid = ALC861VD_DIGOUT_NID,
10442 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10443 .channel_mode = alc861vd_3stack_2ch_modes,
10444 .input_mux = &alc861vd_capture_source,
10445 },
10446 [ALC861VD_6ST_DIG] = {
10447 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10448 .init_verbs = { alc861vd_volume_init_verbs,
10449 alc861vd_6stack_init_verbs },
10450 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10451 .dac_nids = alc861vd_dac_nids,
10452 .dig_out_nid = ALC861VD_DIGOUT_NID,
10453 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10454 .channel_mode = alc861vd_6stack_modes,
10455 .input_mux = &alc861vd_capture_source,
10456 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010457 [ALC861VD_LENOVO] = {
10458 .mixers = { alc861vd_lenovo_mixer },
10459 .init_verbs = { alc861vd_volume_init_verbs,
10460 alc861vd_3stack_init_verbs,
10461 alc861vd_eapd_verbs,
10462 alc861vd_lenovo_unsol_verbs },
10463 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10464 .dac_nids = alc660vd_dac_nids,
10465 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10466 .adc_nids = alc861vd_adc_nids,
10467 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10468 .channel_mode = alc861vd_3stack_2ch_modes,
10469 .input_mux = &alc861vd_capture_source,
10470 .unsol_event = alc861vd_lenovo_unsol_event,
10471 .init_hook = alc861vd_lenovo_automute,
10472 },
Kailang Yang272a5272007-05-14 11:00:38 +020010473 [ALC861VD_DALLAS] = {
10474 .mixers = { alc861vd_dallas_mixer },
10475 .init_verbs = { alc861vd_dallas_verbs },
10476 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10477 .dac_nids = alc861vd_dac_nids,
10478 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10479 .adc_nids = alc861vd_adc_nids,
10480 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10481 .channel_mode = alc861vd_3stack_2ch_modes,
10482 .input_mux = &alc861vd_dallas_capture_source,
10483 .unsol_event = alc861vd_dallas_unsol_event,
10484 .init_hook = alc861vd_dallas_automute,
10485 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010486};
10487
10488/*
10489 * BIOS auto configuration
10490 */
10491static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10492 hda_nid_t nid, int pin_type, int dac_idx)
10493{
10494 /* set as output */
10495 snd_hda_codec_write(codec, nid, 0,
10496 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10497 snd_hda_codec_write(codec, nid, 0,
10498 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10499}
10500
10501static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10502{
10503 struct alc_spec *spec = codec->spec;
10504 int i;
10505
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010506 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010507 for (i = 0; i <= HDA_SIDE; i++) {
10508 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010509 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010510 if (nid)
10511 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010512 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010513 }
10514}
10515
10516
10517static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10518{
10519 struct alc_spec *spec = codec->spec;
10520 hda_nid_t pin;
10521
10522 pin = spec->autocfg.hp_pins[0];
10523 if (pin) /* connect to front and use dac 0 */
10524 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10525}
10526
10527#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10528#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10529
10530static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10531{
10532 struct alc_spec *spec = codec->spec;
10533 int i;
10534
10535 for (i = 0; i < AUTO_PIN_LAST; i++) {
10536 hda_nid_t nid = spec->autocfg.input_pins[i];
10537 if (alc861vd_is_input_pin(nid)) {
10538 snd_hda_codec_write(codec, nid, 0,
10539 AC_VERB_SET_PIN_WIDGET_CONTROL,
10540 i <= AUTO_PIN_FRONT_MIC ?
10541 PIN_VREF80 : PIN_IN);
10542 if (nid != ALC861VD_PIN_CD_NID)
10543 snd_hda_codec_write(codec, nid, 0,
10544 AC_VERB_SET_AMP_GAIN_MUTE,
10545 AMP_OUT_MUTE);
10546 }
10547 }
10548}
10549
10550#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10551#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10552
10553/* add playback controls from the parsed DAC table */
10554/* Based on ALC880 version. But ALC861VD has separate,
10555 * different NIDs for mute/unmute switch and volume control */
10556static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10557 const struct auto_pin_cfg *cfg)
10558{
10559 char name[32];
10560 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10561 hda_nid_t nid_v, nid_s;
10562 int i, err;
10563
10564 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010565 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010566 continue;
10567 nid_v = alc861vd_idx_to_mixer_vol(
10568 alc880_dac_to_idx(
10569 spec->multiout.dac_nids[i]));
10570 nid_s = alc861vd_idx_to_mixer_switch(
10571 alc880_dac_to_idx(
10572 spec->multiout.dac_nids[i]));
10573
10574 if (i == 2) {
10575 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010576 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10577 "Center Playback Volume",
10578 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10579 HDA_OUTPUT));
10580 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010581 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010582 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10583 "LFE Playback Volume",
10584 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10585 HDA_OUTPUT));
10586 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010587 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010588 err = add_control(spec, ALC_CTL_BIND_MUTE,
10589 "Center Playback Switch",
10590 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10591 HDA_INPUT));
10592 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010593 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010594 err = add_control(spec, ALC_CTL_BIND_MUTE,
10595 "LFE Playback Switch",
10596 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10597 HDA_INPUT));
10598 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010599 return err;
10600 } else {
10601 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010602 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10603 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10604 HDA_OUTPUT));
10605 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010606 return err;
10607 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010608 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010609 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010610 HDA_INPUT));
10611 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010612 return err;
10613 }
10614 }
10615 return 0;
10616}
10617
10618/* add playback controls for speaker and HP outputs */
10619/* Based on ALC880 version. But ALC861VD has separate,
10620 * different NIDs for mute/unmute switch and volume control */
10621static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10622 hda_nid_t pin, const char *pfx)
10623{
10624 hda_nid_t nid_v, nid_s;
10625 int err;
10626 char name[32];
10627
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010628 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010629 return 0;
10630
10631 if (alc880_is_fixed_pin(pin)) {
10632 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10633 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010634 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010635 spec->multiout.hp_nid = nid_v;
10636 else
10637 spec->multiout.extra_out_nid[0] = nid_v;
10638 /* control HP volume/switch on the output mixer amp */
10639 nid_v = alc861vd_idx_to_mixer_vol(
10640 alc880_fixed_pin_idx(pin));
10641 nid_s = alc861vd_idx_to_mixer_switch(
10642 alc880_fixed_pin_idx(pin));
10643
10644 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010645 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10646 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10647 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010648 return err;
10649 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010650 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10651 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10652 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010653 return err;
10654 } else if (alc880_is_multi_pin(pin)) {
10655 /* set manual connection */
10656 /* we have only a switch on HP-out PIN */
10657 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010658 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10659 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10660 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010661 return err;
10662 }
10663 return 0;
10664}
10665
10666/* parse the BIOS configuration and set up the alc_spec
10667 * return 1 if successful, 0 if the proper config is not found,
10668 * or a negative error code
10669 * Based on ALC880 version - had to change it to override
10670 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10671static int alc861vd_parse_auto_config(struct hda_codec *codec)
10672{
10673 struct alc_spec *spec = codec->spec;
10674 int err;
10675 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10676
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010677 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10678 alc861vd_ignore);
10679 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010680 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010681 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010682 return 0; /* can't find valid BIOS pin config */
10683
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010684 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10685 if (err < 0)
10686 return err;
10687 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10688 if (err < 0)
10689 return err;
10690 err = alc861vd_auto_create_extra_out(spec,
10691 spec->autocfg.speaker_pins[0],
10692 "Speaker");
10693 if (err < 0)
10694 return err;
10695 err = alc861vd_auto_create_extra_out(spec,
10696 spec->autocfg.hp_pins[0],
10697 "Headphone");
10698 if (err < 0)
10699 return err;
10700 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10701 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010702 return err;
10703
10704 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10705
10706 if (spec->autocfg.dig_out_pin)
10707 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10708
10709 if (spec->kctl_alloc)
10710 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10711
10712 spec->init_verbs[spec->num_init_verbs++]
10713 = alc861vd_volume_init_verbs;
10714
10715 spec->num_mux_defs = 1;
10716 spec->input_mux = &spec->private_imux;
10717
10718 return 1;
10719}
10720
10721/* additional initialization for auto-configuration model */
10722static void alc861vd_auto_init(struct hda_codec *codec)
10723{
10724 alc861vd_auto_init_multi_out(codec);
10725 alc861vd_auto_init_hp_out(codec);
10726 alc861vd_auto_init_analog_input(codec);
10727}
10728
10729static int patch_alc861vd(struct hda_codec *codec)
10730{
10731 struct alc_spec *spec;
10732 int err, board_config;
10733
10734 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10735 if (spec == NULL)
10736 return -ENOMEM;
10737
10738 codec->spec = spec;
10739
10740 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10741 alc861vd_models,
10742 alc861vd_cfg_tbl);
10743
10744 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10745 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10746 "ALC861VD, trying auto-probe from BIOS...\n");
10747 board_config = ALC861VD_AUTO;
10748 }
10749
10750 if (board_config == ALC861VD_AUTO) {
10751 /* automatic parse from the BIOS config */
10752 err = alc861vd_parse_auto_config(codec);
10753 if (err < 0) {
10754 alc_free(codec);
10755 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010756 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010757 printk(KERN_INFO
10758 "hda_codec: Cannot set up configuration "
10759 "from BIOS. Using base mode...\n");
10760 board_config = ALC861VD_3ST;
10761 }
10762 }
10763
10764 if (board_config != ALC861VD_AUTO)
10765 setup_preset(spec, &alc861vd_presets[board_config]);
10766
10767 spec->stream_name_analog = "ALC861VD Analog";
10768 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10769 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10770
10771 spec->stream_name_digital = "ALC861VD Digital";
10772 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10773 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10774
10775 spec->adc_nids = alc861vd_adc_nids;
10776 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10777
10778 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10779 spec->num_mixers++;
10780
10781 codec->patch_ops = alc_patch_ops;
10782
10783 if (board_config == ALC861VD_AUTO)
10784 spec->init_hook = alc861vd_auto_init;
10785
10786 return 0;
10787}
10788
10789/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010790 * ALC662 support
10791 *
10792 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10793 * configuration. Each pin widget can choose any input DACs and a mixer.
10794 * Each ADC is connected from a mixer of all inputs. This makes possible
10795 * 6-channel independent captures.
10796 *
10797 * In addition, an independent DAC for the multi-playback (not used in this
10798 * driver yet).
10799 */
10800#define ALC662_DIGOUT_NID 0x06
10801#define ALC662_DIGIN_NID 0x0a
10802
10803static hda_nid_t alc662_dac_nids[4] = {
10804 /* front, rear, clfe, rear_surr */
10805 0x02, 0x03, 0x04
10806};
10807
10808static hda_nid_t alc662_adc_nids[1] = {
10809 /* ADC1-2 */
10810 0x09,
10811};
10812/* input MUX */
10813/* FIXME: should be a matrix-type input source selection */
10814
10815static struct hda_input_mux alc662_capture_source = {
10816 .num_items = 4,
10817 .items = {
10818 { "Mic", 0x0 },
10819 { "Front Mic", 0x1 },
10820 { "Line", 0x2 },
10821 { "CD", 0x4 },
10822 },
10823};
10824
10825static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10826 .num_items = 2,
10827 .items = {
10828 { "Mic", 0x1 },
10829 { "Line", 0x2 },
10830 },
10831};
10832#define alc662_mux_enum_info alc_mux_enum_info
10833#define alc662_mux_enum_get alc_mux_enum_get
10834
10835static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10836 struct snd_ctl_elem_value *ucontrol)
10837{
10838 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10839 struct alc_spec *spec = codec->spec;
10840 const struct hda_input_mux *imux = spec->input_mux;
10841 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10842 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10843 hda_nid_t nid = capture_mixers[adc_idx];
10844 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10845 unsigned int i, idx;
10846
10847 idx = ucontrol->value.enumerated.item[0];
10848 if (idx >= imux->num_items)
10849 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010850 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010851 return 0;
10852 for (i = 0; i < imux->num_items; i++) {
10853 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10854 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10855 v | (imux->items[i].index << 8));
10856 }
10857 *cur_val = idx;
10858 return 1;
10859}
10860/*
10861 * 2ch mode
10862 */
10863static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10864 { 2, NULL }
10865};
10866
10867/*
10868 * 2ch mode
10869 */
10870static struct hda_verb alc662_3ST_ch2_init[] = {
10871 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10872 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10873 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10874 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10875 { } /* end */
10876};
10877
10878/*
10879 * 6ch mode
10880 */
10881static struct hda_verb alc662_3ST_ch6_init[] = {
10882 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10883 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10884 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10887 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10888 { } /* end */
10889};
10890
10891static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10892 { 2, alc662_3ST_ch2_init },
10893 { 6, alc662_3ST_ch6_init },
10894};
10895
10896/*
10897 * 2ch mode
10898 */
10899static struct hda_verb alc662_sixstack_ch6_init[] = {
10900 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10901 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10902 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10903 { } /* end */
10904};
10905
10906/*
10907 * 6ch mode
10908 */
10909static struct hda_verb alc662_sixstack_ch8_init[] = {
10910 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10911 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10912 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10913 { } /* end */
10914};
10915
10916static struct hda_channel_mode alc662_5stack_modes[2] = {
10917 { 2, alc662_sixstack_ch6_init },
10918 { 6, alc662_sixstack_ch8_init },
10919};
10920
10921/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10922 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10923 */
10924
10925static struct snd_kcontrol_new alc662_base_mixer[] = {
10926 /* output mixer control */
10927 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10928 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10929 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10930 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10931 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10932 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10933 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10934 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10935 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10936
10937 /*Input mixer control */
10938 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10939 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10940 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10941 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10942 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10943 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10944 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10945 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10946
10947 /* Capture mixer control */
10948 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10949 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10950 {
10951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10952 .name = "Capture Source",
10953 .count = 1,
10954 .info = alc_mux_enum_info,
10955 .get = alc_mux_enum_get,
10956 .put = alc_mux_enum_put,
10957 },
10958 { } /* end */
10959};
10960
10961static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10962 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10963 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10973 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10974 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10975 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10976 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10977 {
10978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10979 /* .name = "Capture Source", */
10980 .name = "Input Source",
10981 .count = 1,
10982 .info = alc662_mux_enum_info,
10983 .get = alc662_mux_enum_get,
10984 .put = alc662_mux_enum_put,
10985 },
10986 { } /* end */
10987};
10988
10989static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10990 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10991 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10992 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10993 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10994 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10995 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10996 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10997 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10999 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11000 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11001 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11002 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11006 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11007 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11008 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11009 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11010 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11011 {
11012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11013 /* .name = "Capture Source", */
11014 .name = "Input Source",
11015 .count = 1,
11016 .info = alc662_mux_enum_info,
11017 .get = alc662_mux_enum_get,
11018 .put = alc662_mux_enum_put,
11019 },
11020 { } /* end */
11021};
11022
11023static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11024 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11025 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11026 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11027 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11028 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11029 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11030 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11032 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11033 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11034 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11035 {
11036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11037 /* .name = "Capture Source", */
11038 .name = "Input Source",
11039 .count = 1,
11040 .info = alc662_mux_enum_info,
11041 .get = alc662_mux_enum_get,
11042 .put = alc662_mux_enum_put,
11043 },
11044 { } /* end */
11045};
11046
11047static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11048 {
11049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11050 .name = "Channel Mode",
11051 .info = alc_ch_mode_info,
11052 .get = alc_ch_mode_get,
11053 .put = alc_ch_mode_put,
11054 },
11055 { } /* end */
11056};
11057
11058static struct hda_verb alc662_init_verbs[] = {
11059 /* ADC: mute amp left and right */
11060 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11061 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11062 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11063
11064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11069
11070 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11071 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11072 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11073 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11074 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11075 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11076
11077 /* Front Pin: output 0 (0x0c) */
11078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11079 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11080
11081 /* Rear Pin: output 1 (0x0d) */
11082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11084
11085 /* CLFE Pin: output 2 (0x0e) */
11086 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11087 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11088
11089 /* Mic (rear) pin: input vref at 80% */
11090 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11092 /* Front Mic pin: input vref at 80% */
11093 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11094 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11095 /* Line In pin: input */
11096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11097 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11098 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11100 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11101 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11102 /* CD pin widget for input */
11103 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11104
11105 /* FIXME: use matrix-type input source selection */
11106 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11107 /* Input mixer */
11108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11112 { }
11113};
11114
11115static struct hda_verb alc662_sue_init_verbs[] = {
11116 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11117 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11118 {}
11119};
11120
11121/*
11122 * generic initialization of ADC, input mixers and output mixers
11123 */
11124static struct hda_verb alc662_auto_init_verbs[] = {
11125 /*
11126 * Unmute ADC and set the default input to mic-in
11127 */
11128 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11129 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11130
11131 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11132 * mixer widget
11133 * Note: PASD motherboards uses the Line In 2 as the input for front
11134 * panel mic (mic 2)
11135 */
11136 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11142
11143 /*
11144 * Set up output mixers (0x0c - 0x0f)
11145 */
11146 /* set vol=0 to output mixers */
11147 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11148 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11149 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11150
11151 /* set up input amps for analog loopback */
11152 /* Amp Indices: DAC = 0, mixer = 1 */
11153 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11154 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11155 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11156 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11157 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11158 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11159
11160
11161 /* FIXME: use matrix-type input source selection */
11162 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11163 /* Input mixer */
11164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11167 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
11168 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11169
11170 { }
11171};
11172
11173/* capture mixer elements */
11174static struct snd_kcontrol_new alc662_capture_mixer[] = {
11175 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11176 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11177 {
11178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11179 /* The multiple "Capture Source" controls confuse alsamixer
11180 * So call somewhat different..
11181 * FIXME: the controls appear in the "playback" view!
11182 */
11183 /* .name = "Capture Source", */
11184 .name = "Input Source",
11185 .count = 1,
11186 .info = alc882_mux_enum_info,
11187 .get = alc882_mux_enum_get,
11188 .put = alc882_mux_enum_put,
11189 },
11190 { } /* end */
11191};
11192
11193static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11194{
11195 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011196 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011197
11198 present = snd_hda_codec_read(codec, 0x14, 0,
11199 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011200 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011201 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011202 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011203 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011204 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011205}
11206
11207static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11208{
11209 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011210 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011211
11212 present = snd_hda_codec_read(codec, 0x1b, 0,
11213 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011214 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011215 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011216 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011217 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011218 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011219 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011220 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011221 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011222 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011223}
11224
11225static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11226 unsigned int res)
11227{
11228 if ((res >> 26) == ALC880_HP_EVENT)
11229 alc662_lenovo_101e_all_automute(codec);
11230 if ((res >> 26) == ALC880_FRONT_EVENT)
11231 alc662_lenovo_101e_ispeaker_automute(codec);
11232}
11233
11234
11235/* pcm configuration: identiacal with ALC880 */
11236#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11237#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11238#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11239#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11240
11241/*
11242 * configuration and preset
11243 */
11244static const char *alc662_models[ALC662_MODEL_LAST] = {
11245 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11246 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11247 [ALC662_3ST_6ch] = "3stack-6ch",
11248 [ALC662_5ST_DIG] = "6stack-dig",
11249 [ALC662_LENOVO_101E] = "lenovo-101e",
11250 [ALC662_AUTO] = "auto",
11251};
11252
11253static struct snd_pci_quirk alc662_cfg_tbl[] = {
11254 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11255 {}
11256};
11257
11258static struct alc_config_preset alc662_presets[] = {
11259 [ALC662_3ST_2ch_DIG] = {
11260 .mixers = { alc662_3ST_2ch_mixer },
11261 .init_verbs = { alc662_init_verbs },
11262 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11263 .dac_nids = alc662_dac_nids,
11264 .dig_out_nid = ALC662_DIGOUT_NID,
11265 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11266 .adc_nids = alc662_adc_nids,
11267 .dig_in_nid = ALC662_DIGIN_NID,
11268 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11269 .channel_mode = alc662_3ST_2ch_modes,
11270 .input_mux = &alc662_capture_source,
11271 },
11272 [ALC662_3ST_6ch_DIG] = {
11273 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11274 .init_verbs = { alc662_init_verbs },
11275 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11276 .dac_nids = alc662_dac_nids,
11277 .dig_out_nid = ALC662_DIGOUT_NID,
11278 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11279 .adc_nids = alc662_adc_nids,
11280 .dig_in_nid = ALC662_DIGIN_NID,
11281 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11282 .channel_mode = alc662_3ST_6ch_modes,
11283 .need_dac_fix = 1,
11284 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011285 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011286 [ALC662_3ST_6ch] = {
11287 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11288 .init_verbs = { alc662_init_verbs },
11289 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11290 .dac_nids = alc662_dac_nids,
11291 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11292 .adc_nids = alc662_adc_nids,
11293 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11294 .channel_mode = alc662_3ST_6ch_modes,
11295 .need_dac_fix = 1,
11296 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011297 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011298 [ALC662_5ST_DIG] = {
11299 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11300 .init_verbs = { alc662_init_verbs },
11301 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11302 .dac_nids = alc662_dac_nids,
11303 .dig_out_nid = ALC662_DIGOUT_NID,
11304 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11305 .adc_nids = alc662_adc_nids,
11306 .dig_in_nid = ALC662_DIGIN_NID,
11307 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11308 .channel_mode = alc662_5stack_modes,
11309 .input_mux = &alc662_capture_source,
11310 },
11311 [ALC662_LENOVO_101E] = {
11312 .mixers = { alc662_lenovo_101e_mixer },
11313 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11314 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11315 .dac_nids = alc662_dac_nids,
11316 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11317 .adc_nids = alc662_adc_nids,
11318 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11319 .channel_mode = alc662_3ST_2ch_modes,
11320 .input_mux = &alc662_lenovo_101e_capture_source,
11321 .unsol_event = alc662_lenovo_101e_unsol_event,
11322 .init_hook = alc662_lenovo_101e_all_automute,
11323 },
11324
11325};
11326
11327
11328/*
11329 * BIOS auto configuration
11330 */
11331
11332/* add playback controls from the parsed DAC table */
11333static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11334 const struct auto_pin_cfg *cfg)
11335{
11336 char name[32];
11337 static const char *chname[4] = {
11338 "Front", "Surround", NULL /*CLFE*/, "Side"
11339 };
11340 hda_nid_t nid;
11341 int i, err;
11342
11343 for (i = 0; i < cfg->line_outs; i++) {
11344 if (!spec->multiout.dac_nids[i])
11345 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011346 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011347 if (i == 2) {
11348 /* Center/LFE */
11349 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11350 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011351 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11352 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011353 if (err < 0)
11354 return err;
11355 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11356 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011357 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11358 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011359 if (err < 0)
11360 return err;
11361 err = add_control(spec, ALC_CTL_BIND_MUTE,
11362 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011363 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11364 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011365 if (err < 0)
11366 return err;
11367 err = add_control(spec, ALC_CTL_BIND_MUTE,
11368 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011369 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11370 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011371 if (err < 0)
11372 return err;
11373 } else {
11374 sprintf(name, "%s Playback Volume", chname[i]);
11375 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011376 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11377 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011378 if (err < 0)
11379 return err;
11380 sprintf(name, "%s Playback Switch", chname[i]);
11381 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011382 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11383 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011384 if (err < 0)
11385 return err;
11386 }
11387 }
11388 return 0;
11389}
11390
11391/* add playback controls for speaker and HP outputs */
11392static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11393 const char *pfx)
11394{
11395 hda_nid_t nid;
11396 int err;
11397 char name[32];
11398
11399 if (!pin)
11400 return 0;
11401
11402 if (alc880_is_fixed_pin(pin)) {
11403 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11404 /* printk("DAC nid=%x\n",nid); */
11405 /* specify the DAC as the extra output */
11406 if (!spec->multiout.hp_nid)
11407 spec->multiout.hp_nid = nid;
11408 else
11409 spec->multiout.extra_out_nid[0] = nid;
11410 /* control HP volume/switch on the output mixer amp */
11411 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11412 sprintf(name, "%s Playback Volume", pfx);
11413 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11414 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11415 if (err < 0)
11416 return err;
11417 sprintf(name, "%s Playback Switch", pfx);
11418 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11419 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11420 if (err < 0)
11421 return err;
11422 } else if (alc880_is_multi_pin(pin)) {
11423 /* set manual connection */
11424 /* we have only a switch on HP-out PIN */
11425 sprintf(name, "%s Playback Switch", pfx);
11426 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11427 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11428 if (err < 0)
11429 return err;
11430 }
11431 return 0;
11432}
11433
11434/* create playback/capture controls for input pins */
11435static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11436 const struct auto_pin_cfg *cfg)
11437{
11438 struct hda_input_mux *imux = &spec->private_imux;
11439 int i, err, idx;
11440
11441 for (i = 0; i < AUTO_PIN_LAST; i++) {
11442 if (alc880_is_input_pin(cfg->input_pins[i])) {
11443 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11444 err = new_analog_input(spec, cfg->input_pins[i],
11445 auto_pin_cfg_labels[i],
11446 idx, 0x0b);
11447 if (err < 0)
11448 return err;
11449 imux->items[imux->num_items].label =
11450 auto_pin_cfg_labels[i];
11451 imux->items[imux->num_items].index =
11452 alc880_input_pin_idx(cfg->input_pins[i]);
11453 imux->num_items++;
11454 }
11455 }
11456 return 0;
11457}
11458
11459static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11460 hda_nid_t nid, int pin_type,
11461 int dac_idx)
11462{
11463 /* set as output */
11464 snd_hda_codec_write(codec, nid, 0,
11465 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11466 snd_hda_codec_write(codec, nid, 0,
11467 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11468 /* need the manual connection? */
11469 if (alc880_is_multi_pin(nid)) {
11470 struct alc_spec *spec = codec->spec;
11471 int idx = alc880_multi_pin_idx(nid);
11472 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11473 AC_VERB_SET_CONNECT_SEL,
11474 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11475 }
11476}
11477
11478static void alc662_auto_init_multi_out(struct hda_codec *codec)
11479{
11480 struct alc_spec *spec = codec->spec;
11481 int i;
11482
11483 for (i = 0; i <= HDA_SIDE; i++) {
11484 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011485 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011486 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011487 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011488 i);
11489 }
11490}
11491
11492static void alc662_auto_init_hp_out(struct hda_codec *codec)
11493{
11494 struct alc_spec *spec = codec->spec;
11495 hda_nid_t pin;
11496
11497 pin = spec->autocfg.hp_pins[0];
11498 if (pin) /* connect to front */
11499 /* use dac 0 */
11500 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11501}
11502
11503#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11504#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11505
11506static void alc662_auto_init_analog_input(struct hda_codec *codec)
11507{
11508 struct alc_spec *spec = codec->spec;
11509 int i;
11510
11511 for (i = 0; i < AUTO_PIN_LAST; i++) {
11512 hda_nid_t nid = spec->autocfg.input_pins[i];
11513 if (alc662_is_input_pin(nid)) {
11514 snd_hda_codec_write(codec, nid, 0,
11515 AC_VERB_SET_PIN_WIDGET_CONTROL,
11516 (i <= AUTO_PIN_FRONT_MIC ?
11517 PIN_VREF80 : PIN_IN));
11518 if (nid != ALC662_PIN_CD_NID)
11519 snd_hda_codec_write(codec, nid, 0,
11520 AC_VERB_SET_AMP_GAIN_MUTE,
11521 AMP_OUT_MUTE);
11522 }
11523 }
11524}
11525
11526static int alc662_parse_auto_config(struct hda_codec *codec)
11527{
11528 struct alc_spec *spec = codec->spec;
11529 int err;
11530 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11531
11532 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11533 alc662_ignore);
11534 if (err < 0)
11535 return err;
11536 if (!spec->autocfg.line_outs)
11537 return 0; /* can't find valid BIOS pin config */
11538
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011539 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11540 if (err < 0)
11541 return err;
11542 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11543 if (err < 0)
11544 return err;
11545 err = alc662_auto_create_extra_out(spec,
11546 spec->autocfg.speaker_pins[0],
11547 "Speaker");
11548 if (err < 0)
11549 return err;
11550 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11551 "Headphone");
11552 if (err < 0)
11553 return err;
11554 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11555 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011556 return err;
11557
11558 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11559
11560 if (spec->autocfg.dig_out_pin)
11561 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11562
11563 if (spec->kctl_alloc)
11564 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11565
11566 spec->num_mux_defs = 1;
11567 spec->input_mux = &spec->private_imux;
11568
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011569 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011570 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11571 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011572 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011573}
11574
11575/* additional initialization for auto-configuration model */
11576static void alc662_auto_init(struct hda_codec *codec)
11577{
11578 alc662_auto_init_multi_out(codec);
11579 alc662_auto_init_hp_out(codec);
11580 alc662_auto_init_analog_input(codec);
11581}
11582
11583static int patch_alc662(struct hda_codec *codec)
11584{
11585 struct alc_spec *spec;
11586 int err, board_config;
11587
11588 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11589 if (!spec)
11590 return -ENOMEM;
11591
11592 codec->spec = spec;
11593
11594 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11595 alc662_models,
11596 alc662_cfg_tbl);
11597 if (board_config < 0) {
11598 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11599 "trying auto-probe from BIOS...\n");
11600 board_config = ALC662_AUTO;
11601 }
11602
11603 if (board_config == ALC662_AUTO) {
11604 /* automatic parse from the BIOS config */
11605 err = alc662_parse_auto_config(codec);
11606 if (err < 0) {
11607 alc_free(codec);
11608 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011609 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011610 printk(KERN_INFO
11611 "hda_codec: Cannot set up configuration "
11612 "from BIOS. Using base mode...\n");
11613 board_config = ALC662_3ST_2ch_DIG;
11614 }
11615 }
11616
11617 if (board_config != ALC662_AUTO)
11618 setup_preset(spec, &alc662_presets[board_config]);
11619
11620 spec->stream_name_analog = "ALC662 Analog";
11621 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11622 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11623
11624 spec->stream_name_digital = "ALC662 Digital";
11625 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11626 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11627
11628 if (!spec->adc_nids && spec->input_mux) {
11629 spec->adc_nids = alc662_adc_nids;
11630 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11631 }
11632
11633 codec->patch_ops = alc_patch_ops;
11634 if (board_config == ALC662_AUTO)
11635 spec->init_hook = alc662_auto_init;
11636
11637 return 0;
11638}
11639
11640/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011641 * patch entries
11642 */
11643struct hda_codec_preset snd_hda_preset_realtek[] = {
11644 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011645 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011646 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011647 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011648 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011649 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11650 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11651 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011652 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11653 .patch = patch_alc883 },
11654 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11655 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011656 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011657 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011658 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011659 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011660 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011661 {} /* terminator */
11662};