blob: b145667de17c8054a935f94eb7480cf1d48238c6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010074 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010076 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020077 ALC260_WILL,
78 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010079#ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020083 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Kailang Yangdf694da2005-12-05 19:42:22 +010086/* ALC262 models */
87enum {
88 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020089 ALC262_HIPPO,
90 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010091 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020092 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010093 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020095 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020096 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020097 ALC262_BENQ_T31,
Kailang Yangdf694da2005-12-05 19:42:22 +010098 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */
100};
101
Kailang Yanga361d842007-06-05 12:30:55 +0200102/* ALC268 models */
103enum {
104 ALC268_3ST,
105 ALC268_AUTO,
106 ALC268_MODEL_LAST /* last tag */
107};
108
Kailang Yangdf694da2005-12-05 19:42:22 +0100109/* ALC861 models */
110enum {
111 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200112 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100113 ALC861_3ST_DIG,
114 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200115 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200116 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200117 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100118 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100119 ALC861_AUTO,
120 ALC861_MODEL_LAST,
121};
122
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100123/* ALC861-VD models */
124enum {
125 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200126 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100127 ALC861VD_3ST,
128 ALC861VD_3ST_DIG,
129 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200130 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200131 ALC861VD_DALLAS,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100132 ALC861VD_AUTO,
133 ALC861VD_MODEL_LAST,
134};
135
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200136/* ALC662 models */
137enum {
138 ALC662_3ST_2ch_DIG,
139 ALC662_3ST_6ch_DIG,
140 ALC662_3ST_6ch,
141 ALC662_5ST_DIG,
142 ALC662_LENOVO_101E,
143 ALC662_AUTO,
144 ALC662_MODEL_LAST,
145};
146
Kailang Yangdf694da2005-12-05 19:42:22 +0100147/* ALC882 models */
148enum {
149 ALC882_3ST_DIG,
150 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200151 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200152 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200153 ALC882_TARGA,
154 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100155 ALC885_MACPRO,
Kailang Yang272a5272007-05-14 11:00:38 +0200156 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100157 ALC882_MODEL_LAST,
158};
159
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200160/* ALC883 models */
161enum {
162 ALC883_3ST_2ch_DIG,
163 ALC883_3ST_6ch_DIG,
164 ALC883_3ST_6ch,
165 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200166 ALC883_TARGA_DIG,
167 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200168 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200169 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200170 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100171 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200172 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200173 ALC883_LENOVO_NB0763,
174 ALC888_LENOVO_MS7195_DIG,
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +0200175 ALC888_HP_NETTLE,
Claudio Matsuoka8341de62007-07-06 12:10:45 +0200176 ALC888_HP_LUCKNOW,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200177 ALC883_AUTO,
178 ALC883_MODEL_LAST,
179};
180
Kailang Yangdf694da2005-12-05 19:42:22 +0100181/* for GPIO Poll */
182#define GPIO_MASK 0x03
183
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184struct alc_spec {
185 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100186 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 unsigned int num_mixers;
188
Kailang Yangdf694da2005-12-05 19:42:22 +0100189 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200190 * don't forget NULL
191 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200192 */
193 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
Takashi Iwai16ded522005-06-10 19:58:24 +0200195 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 struct hda_pcm_stream *stream_analog_playback;
197 struct hda_pcm_stream *stream_analog_capture;
198
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200199 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 struct hda_pcm_stream *stream_digital_playback;
201 struct hda_pcm_stream *stream_digital_capture;
202
203 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200204 struct hda_multi_out multiout; /* playback set-up
205 * max_channels, dacs must be set
206 * dig_out_nid and hp_nid are optional
207 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
209 /* capture */
210 unsigned int num_adc_nids;
211 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200212 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
214 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200215 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 const struct hda_input_mux *input_mux;
217 unsigned int cur_mux[3];
218
219 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100220 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200222 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100225 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200226
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200227 /* dynamic controls, init_verbs and input_mux */
228 struct auto_pin_cfg autocfg;
229 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100230 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200231 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100232 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100233
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100234 /* hooks */
235 void (*init_hook)(struct hda_codec *codec);
236 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
237
Takashi Iwai834be882006-03-01 14:16:17 +0100238 /* for pin sensing */
239 unsigned int sense_updated: 1;
240 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100241};
242
243/*
244 * configuration template - to be copied to the spec instance
245 */
246struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247 struct snd_kcontrol_new *mixers[5]; /* should be identical size
248 * with spec
249 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100250 const struct hda_verb *init_verbs[5];
251 unsigned int num_dacs;
252 hda_nid_t *dac_nids;
253 hda_nid_t dig_out_nid; /* optional */
254 hda_nid_t hp_nid; /* optional */
255 unsigned int num_adc_nids;
256 hda_nid_t *adc_nids;
257 hda_nid_t dig_in_nid;
258 unsigned int num_channel_mode;
259 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200260 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200261 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100262 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100263 void (*unsol_event)(struct hda_codec *, unsigned int);
264 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265};
266
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
268/*
269 * input MUX handling
270 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200271static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
272 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273{
274 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
275 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200276 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
277 if (mux_idx >= spec->num_mux_defs)
278 mux_idx = 0;
279 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280}
281
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200282static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
283 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284{
285 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
286 struct alc_spec *spec = codec->spec;
287 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
288
289 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
290 return 0;
291}
292
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200293static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
294 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295{
296 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
297 struct alc_spec *spec = codec->spec;
298 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200299 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
300 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200301 spec->adc_nids[adc_idx],
302 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303}
304
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306/*
307 * channel mode setting
308 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200309static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
310 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311{
312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100314 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
315 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316}
317
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200318static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
319 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320{
321 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
322 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100323 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200324 spec->num_channel_mode,
325 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326}
327
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200328static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
329 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330{
331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
332 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200333 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
334 spec->num_channel_mode,
335 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200336 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200337 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
338 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339}
340
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100342 * Control the mode of pin widget settings via the mixer. "pc" is used
343 * instead of "%" to avoid consequences of accidently treating the % as
344 * being part of a format specifier. Maximum allowed length of a value is
345 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100346 *
347 * Note: some retasking pin complexes seem to ignore requests for input
348 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
349 * are requested. Therefore order this list so that this behaviour will not
350 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200351 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
352 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200353 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100354static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100355 "Mic 50pc bias", "Mic 80pc bias",
356 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100357};
358static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100359 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100360};
361/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200362 * in the pin being assumed to be exclusively an input or an output pin. In
363 * addition, "input" pins may or may not process the mic bias option
364 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
365 * accept requests for bias as of chip versions up to March 2006) and/or
366 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100367 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200368#define ALC_PIN_DIR_IN 0x00
369#define ALC_PIN_DIR_OUT 0x01
370#define ALC_PIN_DIR_INOUT 0x02
371#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
372#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100373
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200374/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100375 * For each direction the minimum and maximum values are given.
376 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200377static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100378 { 0, 2 }, /* ALC_PIN_DIR_IN */
379 { 3, 4 }, /* ALC_PIN_DIR_OUT */
380 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200381 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
382 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100383};
384#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
385#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
386#define alc_pin_mode_n_items(_dir) \
387 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
388
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200389static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
390 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200391{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100392 unsigned int item_num = uinfo->value.enumerated.item;
393 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
394
395 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200396 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100397 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
398
399 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
400 item_num = alc_pin_mode_min(dir);
401 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200402 return 0;
403}
404
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200405static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200407{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100408 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100411 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200412 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
414 AC_VERB_GET_PIN_WIDGET_CONTROL,
415 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200416
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100417 /* Find enumerated value for current pinctl setting */
418 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200419 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100420 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200421 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100422 return 0;
423}
424
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200425static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
426 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100427{
428 signed int change;
429 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
430 hda_nid_t nid = kcontrol->private_value & 0xffff;
431 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
432 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
434 AC_VERB_GET_PIN_WIDGET_CONTROL,
435 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100436
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200437 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100438 val = alc_pin_mode_min(dir);
439
440 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100441 if (change) {
442 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200443 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200444 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100445
446 /* Also enable the retasking pin's input/output as required
447 * for the requested pin mode. Enum values of 2 or less are
448 * input modes.
449 *
450 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200451 * reduces noise slightly (particularly on input) so we'll
452 * do it. However, having both input and output buffers
453 * enabled simultaneously doesn't seem to be problematic if
454 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100455 */
456 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457 snd_hda_codec_write(codec, nid, 0,
458 AC_VERB_SET_AMP_GAIN_MUTE,
459 AMP_OUT_MUTE);
460 snd_hda_codec_write(codec, nid, 0,
461 AC_VERB_SET_AMP_GAIN_MUTE,
462 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100463 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464 snd_hda_codec_write(codec, nid, 0,
465 AC_VERB_SET_AMP_GAIN_MUTE,
466 AMP_IN_MUTE(0));
467 snd_hda_codec_write(codec, nid, 0,
468 AC_VERB_SET_AMP_GAIN_MUTE,
469 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100470 }
471 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200472 return change;
473}
474
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100475#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200476 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100477 .info = alc_pin_mode_info, \
478 .get = alc_pin_mode_get, \
479 .put = alc_pin_mode_put, \
480 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100481
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100482/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
483 * together using a mask with more than one bit set. This control is
484 * currently used only by the ALC260 test model. At this stage they are not
485 * needed for any "production" models.
486 */
487#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200488static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
489 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100490{
491 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
492 uinfo->count = 1;
493 uinfo->value.integer.min = 0;
494 uinfo->value.integer.max = 1;
495 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200496}
497
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200498static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100500{
501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
502 hda_nid_t nid = kcontrol->private_value & 0xffff;
503 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
504 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200505 unsigned int val = snd_hda_codec_read(codec, nid, 0,
506 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100507
508 *valp = (val & mask) != 0;
509 return 0;
510}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200511static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
512 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100513{
514 signed int change;
515 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
516 hda_nid_t nid = kcontrol->private_value & 0xffff;
517 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
518 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200519 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
520 AC_VERB_GET_GPIO_DATA,
521 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100522
523 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
525 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100526 gpio_data &= ~mask;
527 else
528 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100530
531 return change;
532}
533#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
534 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
535 .info = alc_gpio_data_info, \
536 .get = alc_gpio_data_get, \
537 .put = alc_gpio_data_put, \
538 .private_value = nid | (mask<<16) }
539#endif /* CONFIG_SND_DEBUG */
540
Jonathan Woithe92621f12006-02-28 11:47:47 +0100541/* A switch control to allow the enabling of the digital IO pins on the
542 * ALC260. This is incredibly simplistic; the intention of this control is
543 * to provide something in the test model allowing digital outputs to be
544 * identified if present. If models are found which can utilise these
545 * outputs a more complete mixer control can be devised for those models if
546 * necessary.
547 */
548#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200549static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
550 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100551{
552 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
553 uinfo->count = 1;
554 uinfo->value.integer.min = 0;
555 uinfo->value.integer.max = 1;
556 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200557}
558
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100561{
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 *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200566 unsigned int val = snd_hda_codec_read(codec, nid, 0,
567 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100568
569 *valp = (val & mask) != 0;
570 return 0;
571}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200572static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
573 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100574{
575 signed int change;
576 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
577 hda_nid_t nid = kcontrol->private_value & 0xffff;
578 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
579 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200580 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
581 AC_VERB_GET_DIGI_CONVERT,
582 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100583
584 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200585 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100586 if (val==0)
587 ctrl_data &= ~mask;
588 else
589 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200590 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
591 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100592
593 return change;
594}
595#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
596 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
597 .info = alc_spdif_ctrl_info, \
598 .get = alc_spdif_ctrl_get, \
599 .put = alc_spdif_ctrl_put, \
600 .private_value = nid | (mask<<16) }
601#endif /* CONFIG_SND_DEBUG */
602
Kailang Yangdf694da2005-12-05 19:42:22 +0100603/*
604 * set up from the preset table
605 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200606static void setup_preset(struct alc_spec *spec,
607 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100608{
609 int i;
610
611 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
612 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200613 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
614 i++)
615 spec->init_verbs[spec->num_init_verbs++] =
616 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100617
618 spec->channel_mode = preset->channel_mode;
619 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200620 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100621
622 spec->multiout.max_channels = spec->channel_mode[0].channels;
623
624 spec->multiout.num_dacs = preset->num_dacs;
625 spec->multiout.dac_nids = preset->dac_nids;
626 spec->multiout.dig_out_nid = preset->dig_out_nid;
627 spec->multiout.hp_nid = preset->hp_nid;
628
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200629 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200630 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200631 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100632 spec->input_mux = preset->input_mux;
633
634 spec->num_adc_nids = preset->num_adc_nids;
635 spec->adc_nids = preset->adc_nids;
636 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100637
638 spec->unsol_event = preset->unsol_event;
639 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100640}
641
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200642/* Enable GPIO mask and set output */
643static struct hda_verb alc_gpio1_init_verbs[] = {
644 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
645 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
646 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
647 { }
648};
649
650static struct hda_verb alc_gpio2_init_verbs[] = {
651 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
652 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
653 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
654 { }
655};
656
Kailang Yangbdd148a2007-05-08 15:19:08 +0200657static struct hda_verb alc_gpio3_init_verbs[] = {
658 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
659 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
660 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
661 { }
662};
663
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200664/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
665 * 31 ~ 16 : Manufacture ID
666 * 15 ~ 8 : SKU ID
667 * 7 ~ 0 : Assembly ID
668 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
669 */
670static void alc_subsystem_id(struct hda_codec *codec,
671 unsigned int porta, unsigned int porte,
672 unsigned int portd)
673{
674 unsigned int ass, tmp;
675
676 ass = codec->subsystem_id;
677 if (!(ass & 1))
678 return;
679
680 /* Override */
681 tmp = (ass & 0x38) >> 3; /* external Amp control */
682 switch (tmp) {
683 case 1:
684 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
685 break;
686 case 3:
687 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
688 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200689 case 7:
690 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
691 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200692 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200693 switch (codec->vendor_id) {
694 case 0x10ec0862:
695 case 0x10ec0660:
696 case 0x10ec0662:
697 case 0x10ec0267:
698 case 0x10ec0268:
699 snd_hda_codec_write(codec, 0x14, 0,
700 AC_VERB_SET_EAPD_BTLENABLE, 2);
701 snd_hda_codec_write(codec, 0x15, 0,
702 AC_VERB_SET_EAPD_BTLENABLE, 2);
703 return;
704 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200705 case 6:
706 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
707 hda_nid_t port = 0;
708 tmp = (ass & 0x1800) >> 11;
709 switch (tmp) {
710 case 0: port = porta; break;
711 case 1: port = porte; break;
712 case 2: port = portd; break;
713 }
714 if (port)
715 snd_hda_codec_write(codec, port, 0,
716 AC_VERB_SET_EAPD_BTLENABLE,
717 2);
718 }
719 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
720 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
721 (tmp == 5 ? 0x3040 : 0x3050));
722 break;
723 }
724}
725
Takashi Iwai41e41f12005-06-08 14:48:49 +0200726/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200727 * Fix-up pin default configurations
728 */
729
730struct alc_pincfg {
731 hda_nid_t nid;
732 u32 val;
733};
734
735static void alc_fix_pincfg(struct hda_codec *codec,
736 const struct snd_pci_quirk *quirk,
737 const struct alc_pincfg **pinfix)
738{
739 const struct alc_pincfg *cfg;
740
741 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
742 if (!quirk)
743 return;
744
745 cfg = pinfix[quirk->value];
746 for (; cfg->nid; cfg++) {
747 int i;
748 u32 val = cfg->val;
749 for (i = 0; i < 4; i++) {
750 snd_hda_codec_write(codec, cfg->nid, 0,
751 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
752 val & 0xff);
753 val >>= 8;
754 }
755 }
756}
757
758/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200759 * ALC880 3-stack model
760 *
761 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200762 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
763 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 */
765
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200766static hda_nid_t alc880_dac_nids[4] = {
767 /* front, rear, clfe, rear_surr */
768 0x02, 0x05, 0x04, 0x03
769};
770
771static hda_nid_t alc880_adc_nids[3] = {
772 /* ADC0-2 */
773 0x07, 0x08, 0x09,
774};
775
776/* The datasheet says the node 0x07 is connected from inputs,
777 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100778 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200780static hda_nid_t alc880_adc_nids_alt[2] = {
781 /* ADC1-2 */
782 0x08, 0x09,
783};
784
785#define ALC880_DIGOUT_NID 0x06
786#define ALC880_DIGIN_NID 0x0a
787
788static struct hda_input_mux alc880_capture_source = {
789 .num_items = 4,
790 .items = {
791 { "Mic", 0x0 },
792 { "Front Mic", 0x3 },
793 { "Line", 0x2 },
794 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200796};
797
798/* channel source setting (2/6 channel selection for 3-stack) */
799/* 2ch mode */
800static struct hda_verb alc880_threestack_ch2_init[] = {
801 /* set line-in to input, mute it */
802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
804 /* set mic-in to input vref 80%, mute it */
805 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
806 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 { } /* end */
808};
809
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200810/* 6ch mode */
811static struct hda_verb alc880_threestack_ch6_init[] = {
812 /* set line-in to output, unmute it */
813 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
814 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
815 /* set mic-in to output, unmute it */
816 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
817 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
818 { } /* end */
819};
820
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100821static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200822 { 2, alc880_threestack_ch2_init },
823 { 6, alc880_threestack_ch6_init },
824};
825
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100826static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100828 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200829 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100830 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200831 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
832 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100833 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
834 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
843 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
844 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200846 {
847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
848 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100849 .info = alc_ch_mode_info,
850 .get = alc_ch_mode_get,
851 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200852 },
853 { } /* end */
854};
855
856/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100857static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200858 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
859 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
860 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
861 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
862 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
863 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
864 {
865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
866 /* The multiple "Capture Source" controls confuse alsamixer
867 * So call somewhat different..
868 * FIXME: the controls appear in the "playback" view!
869 */
870 /* .name = "Capture Source", */
871 .name = "Input Source",
872 .count = 3,
873 .info = alc_mux_enum_info,
874 .get = alc_mux_enum_get,
875 .put = alc_mux_enum_put,
876 },
877 { } /* end */
878};
879
880/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100881static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200882 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
883 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
884 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
885 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 {
887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
888 /* The multiple "Capture Source" controls confuse alsamixer
889 * So call somewhat different..
890 * FIXME: the controls appear in the "playback" view!
891 */
892 /* .name = "Capture Source", */
893 .name = "Input Source",
894 .count = 2,
895 .info = alc_mux_enum_info,
896 .get = alc_mux_enum_get,
897 .put = alc_mux_enum_put,
898 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 { } /* end */
900};
901
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200902
903
904/*
905 * ALC880 5-stack model
906 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200907 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
908 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200909 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
910 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
911 */
912
913/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100914static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200915 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100916 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 { } /* end */
918};
919
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200920/* channel source setting (6/8 channel selection for 5-stack) */
921/* 6ch mode */
922static struct hda_verb alc880_fivestack_ch6_init[] = {
923 /* set line-in to input, mute it */
924 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
925 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200926 { } /* end */
927};
928
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200929/* 8ch mode */
930static struct hda_verb alc880_fivestack_ch8_init[] = {
931 /* set line-in to output, unmute it */
932 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
933 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
934 { } /* end */
935};
936
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100937static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200938 { 6, alc880_fivestack_ch6_init },
939 { 8, alc880_fivestack_ch8_init },
940};
941
942
943/*
944 * ALC880 6-stack model
945 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200946 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
947 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200948 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
949 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
950 */
951
952static hda_nid_t alc880_6st_dac_nids[4] = {
953 /* front, rear, clfe, rear_surr */
954 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200955};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200956
957static struct hda_input_mux alc880_6stack_capture_source = {
958 .num_items = 4,
959 .items = {
960 { "Mic", 0x0 },
961 { "Front Mic", 0x1 },
962 { "Line", 0x2 },
963 { "CD", 0x4 },
964 },
965};
966
967/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100968static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200969 { 8, NULL },
970};
971
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100972static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100974 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200975 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100976 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200977 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
978 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100979 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
980 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200981 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100982 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
986 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
991 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
992 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200993 {
994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
995 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100996 .info = alc_ch_mode_info,
997 .get = alc_ch_mode_get,
998 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200999 },
1000 { } /* end */
1001};
1002
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001003
1004/*
1005 * ALC880 W810 model
1006 *
1007 * W810 has rear IO for:
1008 * Front (DAC 02)
1009 * Surround (DAC 03)
1010 * Center/LFE (DAC 04)
1011 * Digital out (06)
1012 *
1013 * The system also has a pair of internal speakers, and a headphone jack.
1014 * These are both connected to Line2 on the codec, hence to DAC 02.
1015 *
1016 * There is a variable resistor to control the speaker or headphone
1017 * volume. This is a hardware-only device without a software API.
1018 *
1019 * Plugging headphones in will disable the internal speakers. This is
1020 * implemented in hardware, not via the driver using jack sense. In
1021 * a similar fashion, plugging into the rear socket marked "front" will
1022 * disable both the speakers and headphones.
1023 *
1024 * For input, there's a microphone jack, and an "audio in" jack.
1025 * These may not do anything useful with this driver yet, because I
1026 * haven't setup any initialization verbs for these yet...
1027 */
1028
1029static hda_nid_t alc880_w810_dac_nids[3] = {
1030 /* front, rear/surround, clfe */
1031 0x02, 0x03, 0x04
1032};
1033
1034/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001035static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001036 { 6, NULL }
1037};
1038
1039/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001040static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001043 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001044 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001045 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001047 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1048 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1050 { } /* end */
1051};
1052
1053
1054/*
1055 * Z710V model
1056 *
1057 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001058 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1059 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001060 */
1061
1062static hda_nid_t alc880_z71v_dac_nids[1] = {
1063 0x02
1064};
1065#define ALC880_Z71V_HP_DAC 0x03
1066
1067/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001068static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001069 { 2, NULL }
1070};
1071
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001072static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001076 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1081 { } /* end */
1082};
1083
1084
1085/* FIXME! */
1086/*
1087 * ALC880 F1734 model
1088 *
1089 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1090 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1091 */
1092
1093static hda_nid_t alc880_f1734_dac_nids[1] = {
1094 0x03
1095};
1096#define ALC880_F1734_HP_DAC 0x02
1097
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001098static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001099 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001100 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001101 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001102 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001103 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1104 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1106 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001107 { } /* end */
1108};
1109
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001110
1111/* FIXME! */
1112/*
1113 * ALC880 ASUS model
1114 *
1115 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1116 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1117 * Mic = 0x18, Line = 0x1a
1118 */
1119
1120#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1121#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1122
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001123static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001126 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001127 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001128 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1129 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001130 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1131 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001138 {
1139 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1140 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001141 .info = alc_ch_mode_info,
1142 .get = alc_ch_mode_get,
1143 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001144 },
1145 { } /* end */
1146};
1147
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148/* FIXME! */
1149/*
1150 * ALC880 ASUS W1V model
1151 *
1152 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1153 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1154 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1155 */
1156
1157/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001158static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001159 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1160 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001161 { } /* end */
1162};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001163
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001164/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001165static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001166 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1167 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1168 { } /* end */
1169};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001170
Kailang Yangdf694da2005-12-05 19:42:22 +01001171/* TCL S700 */
1172static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1174 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1177 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1180 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1181 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1182 {
1183 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1184 /* The multiple "Capture Source" controls confuse alsamixer
1185 * So call somewhat different..
1186 * FIXME: the controls appear in the "playback" view!
1187 */
1188 /* .name = "Capture Source", */
1189 .name = "Input Source",
1190 .count = 1,
1191 .info = alc_mux_enum_info,
1192 .get = alc_mux_enum_get,
1193 .put = alc_mux_enum_put,
1194 },
1195 { } /* end */
1196};
1197
Kailang Yangccc656c2006-10-17 12:32:26 +02001198/* Uniwill */
1199static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1200 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1201 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1202 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1203 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1206 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1207 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1208 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1209 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1210 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1211 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1216 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1217 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1218 {
1219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1220 .name = "Channel Mode",
1221 .info = alc_ch_mode_info,
1222 .get = alc_ch_mode_get,
1223 .put = alc_ch_mode_put,
1224 },
1225 { } /* end */
1226};
1227
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001228static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1229 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1230 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1231 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1232 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1235 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1236 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1237 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1238 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1239 { } /* end */
1240};
1241
Kailang Yangccc656c2006-10-17 12:32:26 +02001242static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1243 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1244 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1245 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1246 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1249 { } /* end */
1250};
1251
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001253 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 */
1255static int alc_build_controls(struct hda_codec *codec)
1256{
1257 struct alc_spec *spec = codec->spec;
1258 int err;
1259 int i;
1260
1261 for (i = 0; i < spec->num_mixers; i++) {
1262 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1263 if (err < 0)
1264 return err;
1265 }
1266
1267 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001268 err = snd_hda_create_spdif_out_ctls(codec,
1269 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 if (err < 0)
1271 return err;
1272 }
1273 if (spec->dig_in_nid) {
1274 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1275 if (err < 0)
1276 return err;
1277 }
1278 return 0;
1279}
1280
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001281
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282/*
1283 * initialize the codec volumes, etc
1284 */
1285
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286/*
1287 * generic initialization of ADC, input mixers and output mixers
1288 */
1289static struct hda_verb alc880_volume_init_verbs[] = {
1290 /*
1291 * Unmute ADC0-2 and set the default input to mic-in
1292 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001293 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001295 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001297 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001300 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1301 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001302 * Note: PASD motherboards uses the Line In 2 as the input for front
1303 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001305 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001312 /*
1313 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001315 /* set vol=0 to output mixers */
1316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1320 /* set up input amps for analog loopback */
1321 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330
1331 { }
1332};
1333
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001334/*
1335 * 3-stack pin configuration:
1336 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1337 */
1338static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1339 /*
1340 * preset connection lists of input pins
1341 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1342 */
1343 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1344 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1345 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1346
1347 /*
1348 * Set pin mode and muting
1349 */
1350 /* set front pin widgets 0x14 for output */
1351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1356 /* Mic2 (as headphone out) for HP output */
1357 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1358 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1359 /* Line In pin widget for input */
1360 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1361 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1362 /* Line2 (as front mic) pin widget for input and vref at 80% */
1363 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1364 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1365 /* CD pin widget for input */
1366 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1367
1368 { }
1369};
1370
1371/*
1372 * 5-stack pin configuration:
1373 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1374 * line-in/side = 0x1a, f-mic = 0x1b
1375 */
1376static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1377 /*
1378 * preset connection lists of input pins
1379 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1380 */
1381 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1382 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1383
1384 /*
1385 * Set pin mode and muting
1386 */
1387 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001392 /* unmute pins for output (no gain on this amp) */
1393 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001399 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1401 /* Mic2 (as headphone out) for HP output */
1402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001404 /* Line In pin widget for input */
1405 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1407 /* Line2 (as front mic) pin widget for input and vref at 80% */
1408 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1409 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1410 /* CD pin widget for input */
1411 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001412
1413 { }
1414};
1415
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001416/*
1417 * W810 pin configuration:
1418 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1419 */
1420static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001421 /* hphone/speaker input selector: front DAC */
1422 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1423
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1425 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1426 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1427 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1428 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1429 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1430
1431 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001432 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 { }
1435};
1436
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001437/*
1438 * Z71V pin configuration:
1439 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1440 */
1441static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001444 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001445 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001446
Takashi Iwai16ded522005-06-10 19:58:24 +02001447 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001448 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001449 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001450 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001451
1452 { }
1453};
1454
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001455/*
1456 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001457 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1458 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001459 */
1460static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1461 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1462
Takashi Iwai16ded522005-06-10 19:58:24 +02001463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001467 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001468 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001469 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001470 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1471
Takashi Iwai16ded522005-06-10 19:58:24 +02001472 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001474 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001476 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001477 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001479 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001480 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1481
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001482 { }
1483};
Takashi Iwai16ded522005-06-10 19:58:24 +02001484
Kailang Yangccc656c2006-10-17 12:32:26 +02001485/*
1486 * Uniwill pin configuration:
1487 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1488 * line = 0x1a
1489 */
1490static struct hda_verb alc880_uniwill_init_verbs[] = {
1491 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1492
1493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1495 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1498 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1500 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1507
1508 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1510 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1512 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1514 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1515 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1516 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1517
1518 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1519 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1520
1521 { }
1522};
1523
1524/*
1525* Uniwill P53
1526* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1527 */
1528static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1529 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1530
1531 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1532 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1535 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1536 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1543
1544 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1545 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1546 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1547 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1548 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1549 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1550
1551 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1552 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1553
1554 { }
1555};
1556
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001557static struct hda_verb alc880_beep_init_verbs[] = {
1558 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1559 { }
1560};
1561
Kailang Yangccc656c2006-10-17 12:32:26 +02001562/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001563static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001564{
1565 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001566 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001567
1568 present = snd_hda_codec_read(codec, 0x14, 0,
1569 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001570 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001571 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001572 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001573 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001574 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001575 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001576 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001577 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001578 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001579}
1580
1581/* auto-toggle front mic */
1582static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1583{
1584 unsigned int present;
1585 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001586
1587 present = snd_hda_codec_read(codec, 0x18, 0,
1588 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001589 bits = present ? 0x80 : 0;
1590 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1591 0x80, bits);
1592 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1593 0x80, bits);
1594}
1595
1596static void alc880_uniwill_automute(struct hda_codec *codec)
1597{
1598 alc880_uniwill_hp_automute(codec);
1599 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001600}
1601
1602static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1603 unsigned int res)
1604{
1605 /* Looks like the unsol event is incompatible with the standard
1606 * definition. 4bit tag is placed at 28 bit!
1607 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001608 switch (res >> 28) {
1609 case ALC880_HP_EVENT:
1610 alc880_uniwill_hp_automute(codec);
1611 break;
1612 case ALC880_MIC_EVENT:
1613 alc880_uniwill_mic_automute(codec);
1614 break;
1615 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001616}
1617
1618static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1619{
1620 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001621 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001622
1623 present = snd_hda_codec_read(codec, 0x14, 0,
1624 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001625 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001626 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001627 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001628 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001629 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001630}
1631
1632static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1633{
1634 unsigned int present;
1635
1636 present = snd_hda_codec_read(codec, 0x21, 0,
1637 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1638
1639 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1640 0x7f, present);
1641 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1642 0x7f, present);
1643
1644 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1645 0x7f, present);
1646 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1647 0x7f, present);
1648
1649}
1650static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1651 unsigned int res)
1652{
1653 /* Looks like the unsol event is incompatible with the standard
1654 * definition. 4bit tag is placed at 28 bit!
1655 */
1656 if ((res >> 28) == ALC880_HP_EVENT)
1657 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001658 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001659 alc880_uniwill_p53_dcvol_automute(codec);
1660}
1661
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001662/* FIXME! */
1663/*
1664 * F1734 pin configuration:
1665 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1666 */
1667static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1668 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1669 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1670 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1671 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1672
1673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1677
1678 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1679 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1680 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1681 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1682 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1684 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1685 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1686 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001687
1688 { }
1689};
1690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001691/* FIXME! */
1692/*
1693 * ASUS pin configuration:
1694 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1695 */
1696static struct hda_verb alc880_pin_asus_init_verbs[] = {
1697 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1698 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1699 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1700 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1701
1702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1705 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1706 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1707 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1708 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1710
1711 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1713 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1714 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1715 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1717 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1720
1721 { }
1722};
1723
1724/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001725#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1726#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001727
Kailang Yangdf694da2005-12-05 19:42:22 +01001728/* Clevo m520g init */
1729static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1730 /* headphone output */
1731 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1732 /* line-out */
1733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1735 /* Line-in */
1736 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1737 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1738 /* CD */
1739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1740 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1741 /* Mic1 (rear panel) */
1742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1744 /* Mic2 (front panel) */
1745 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1746 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1747 /* headphone */
1748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1750 /* change to EAPD mode */
1751 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1752 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1753
1754 { }
1755};
1756
1757static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001758 /* change to EAPD mode */
1759 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1760 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1761
Kailang Yangdf694da2005-12-05 19:42:22 +01001762 /* Headphone output */
1763 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1764 /* Front output*/
1765 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1766 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1767
1768 /* Line In pin widget for input */
1769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1770 /* CD pin widget for input */
1771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1772 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1773 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1774
1775 /* change to EAPD mode */
1776 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1777 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1778
1779 { }
1780};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001781
1782/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001783 * LG m1 express dual
1784 *
1785 * Pin assignment:
1786 * Rear Line-In/Out (blue): 0x14
1787 * Build-in Mic-In: 0x15
1788 * Speaker-out: 0x17
1789 * HP-Out (green): 0x1b
1790 * Mic-In/Out (red): 0x19
1791 * SPDIF-Out: 0x1e
1792 */
1793
1794/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1795static hda_nid_t alc880_lg_dac_nids[3] = {
1796 0x05, 0x02, 0x03
1797};
1798
1799/* seems analog CD is not working */
1800static struct hda_input_mux alc880_lg_capture_source = {
1801 .num_items = 3,
1802 .items = {
1803 { "Mic", 0x1 },
1804 { "Line", 0x5 },
1805 { "Internal Mic", 0x6 },
1806 },
1807};
1808
1809/* 2,4,6 channel modes */
1810static struct hda_verb alc880_lg_ch2_init[] = {
1811 /* set line-in and mic-in to input */
1812 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1813 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1814 { }
1815};
1816
1817static struct hda_verb alc880_lg_ch4_init[] = {
1818 /* set line-in to out and mic-in to input */
1819 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1820 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1821 { }
1822};
1823
1824static struct hda_verb alc880_lg_ch6_init[] = {
1825 /* set line-in and mic-in to output */
1826 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1827 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1828 { }
1829};
1830
1831static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1832 { 2, alc880_lg_ch2_init },
1833 { 4, alc880_lg_ch4_init },
1834 { 6, alc880_lg_ch6_init },
1835};
1836
1837static struct snd_kcontrol_new alc880_lg_mixer[] = {
1838 /* FIXME: it's not really "master" but front channels */
1839 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1840 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1841 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1842 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1843 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1844 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1845 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1846 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1849 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1850 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1851 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1852 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1853 {
1854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1855 .name = "Channel Mode",
1856 .info = alc_ch_mode_info,
1857 .get = alc_ch_mode_get,
1858 .put = alc_ch_mode_put,
1859 },
1860 { } /* end */
1861};
1862
1863static struct hda_verb alc880_lg_init_verbs[] = {
1864 /* set capture source to mic-in */
1865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1867 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1868 /* mute all amp mixer inputs */
1869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1872 /* line-in to input */
1873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1874 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1875 /* built-in mic */
1876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1878 /* speaker-out */
1879 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1880 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1881 /* mic-in to input */
1882 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1883 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1884 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1885 /* HP-out */
1886 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1888 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1889 /* jack sense */
1890 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1891 { }
1892};
1893
1894/* toggle speaker-output according to the hp-jack state */
1895static void alc880_lg_automute(struct hda_codec *codec)
1896{
1897 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001898 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001899
1900 present = snd_hda_codec_read(codec, 0x1b, 0,
1901 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001902 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001903 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001904 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001905 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001906 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001907}
1908
1909static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1910{
1911 /* Looks like the unsol event is incompatible with the standard
1912 * definition. 4bit tag is placed at 28 bit!
1913 */
1914 if ((res >> 28) == 0x01)
1915 alc880_lg_automute(codec);
1916}
1917
1918/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001919 * LG LW20
1920 *
1921 * Pin assignment:
1922 * Speaker-out: 0x14
1923 * Mic-In: 0x18
1924 * Built-in Mic-In: 0x19 (?)
1925 * HP-Out: 0x1b
1926 * SPDIF-Out: 0x1e
1927 */
1928
1929/* seems analog CD is not working */
1930static struct hda_input_mux alc880_lg_lw_capture_source = {
1931 .num_items = 2,
1932 .items = {
1933 { "Mic", 0x0 },
1934 { "Internal Mic", 0x1 },
1935 },
1936};
1937
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001938#define alc880_lg_lw_modes alc880_threestack_modes
1939
Takashi Iwaid6815182006-03-23 16:06:23 +01001940static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001941 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1942 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1943 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1944 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1946 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1947 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1948 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1953 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1954 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001955 {
1956 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1957 .name = "Channel Mode",
1958 .info = alc_ch_mode_info,
1959 .get = alc_ch_mode_get,
1960 .put = alc_ch_mode_put,
1961 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001962 { } /* end */
1963};
1964
1965static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001966 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1967 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1968 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1969
Takashi Iwaid6815182006-03-23 16:06:23 +01001970 /* set capture source to mic-in */
1971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1973 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1975 /* speaker-out */
1976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1978 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001979 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1980 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1981 /* mic-in to input */
1982 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1983 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 /* built-in mic */
1985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1986 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 /* jack sense */
1988 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1989 { }
1990};
1991
1992/* toggle speaker-output according to the hp-jack state */
1993static void alc880_lg_lw_automute(struct hda_codec *codec)
1994{
1995 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001996 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001997
1998 present = snd_hda_codec_read(codec, 0x1b, 0,
1999 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002000 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01002001 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002002 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002003 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002004 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002005}
2006
2007static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2008{
2009 /* Looks like the unsol event is incompatible with the standard
2010 * definition. 4bit tag is placed at 28 bit!
2011 */
2012 if ((res >> 28) == 0x01)
2013 alc880_lg_lw_automute(codec);
2014}
2015
2016/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002017 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002018 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002019
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020static int alc_init(struct hda_codec *codec)
2021{
2022 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002023 unsigned int i;
2024
2025 for (i = 0; i < spec->num_init_verbs; i++)
2026 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002027
2028 if (spec->init_hook)
2029 spec->init_hook(codec);
2030
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031 return 0;
2032}
2033
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002034static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2035{
2036 struct alc_spec *spec = codec->spec;
2037
2038 if (spec->unsol_event)
2039 spec->unsol_event(codec, res);
2040}
2041
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042#ifdef CONFIG_PM
2043/*
2044 * resume
2045 */
2046static int alc_resume(struct hda_codec *codec)
2047{
2048 struct alc_spec *spec = codec->spec;
2049 int i;
2050
2051 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002052 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002054 if (spec->multiout.dig_out_nid)
2055 snd_hda_resume_spdif_out(codec);
2056 if (spec->dig_in_nid)
2057 snd_hda_resume_spdif_in(codec);
2058
2059 return 0;
2060}
2061#endif
2062
2063/*
2064 * Analog playback callbacks
2065 */
2066static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2067 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002068 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002069{
2070 struct alc_spec *spec = codec->spec;
2071 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2072}
2073
2074static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2075 struct hda_codec *codec,
2076 unsigned int stream_tag,
2077 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002078 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079{
2080 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002081 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2082 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083}
2084
2085static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2086 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002087 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088{
2089 struct alc_spec *spec = codec->spec;
2090 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2091}
2092
2093/*
2094 * Digital out
2095 */
2096static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2097 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002098 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002099{
2100 struct alc_spec *spec = codec->spec;
2101 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2102}
2103
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002104static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2105 struct hda_codec *codec,
2106 unsigned int stream_tag,
2107 unsigned int format,
2108 struct snd_pcm_substream *substream)
2109{
2110 struct alc_spec *spec = codec->spec;
2111 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2112 stream_tag, format, substream);
2113}
2114
Linus Torvalds1da177e2005-04-16 15:20:36 -07002115static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2116 struct hda_codec *codec,
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 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2121}
2122
2123/*
2124 * Analog capture
2125 */
2126static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2127 struct hda_codec *codec,
2128 unsigned int stream_tag,
2129 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002130 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002131{
2132 struct alc_spec *spec = codec->spec;
2133
2134 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2135 stream_tag, 0, format);
2136 return 0;
2137}
2138
2139static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2140 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002141 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142{
2143 struct alc_spec *spec = codec->spec;
2144
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002145 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2146 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002147 return 0;
2148}
2149
2150
2151/*
2152 */
2153static struct hda_pcm_stream alc880_pcm_analog_playback = {
2154 .substreams = 1,
2155 .channels_min = 2,
2156 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002157 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002158 .ops = {
2159 .open = alc880_playback_pcm_open,
2160 .prepare = alc880_playback_pcm_prepare,
2161 .cleanup = alc880_playback_pcm_cleanup
2162 },
2163};
2164
2165static struct hda_pcm_stream alc880_pcm_analog_capture = {
2166 .substreams = 2,
2167 .channels_min = 2,
2168 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170 .ops = {
2171 .prepare = alc880_capture_pcm_prepare,
2172 .cleanup = alc880_capture_pcm_cleanup
2173 },
2174};
2175
2176static struct hda_pcm_stream alc880_pcm_digital_playback = {
2177 .substreams = 1,
2178 .channels_min = 2,
2179 .channels_max = 2,
2180 /* NID is set in alc_build_pcms */
2181 .ops = {
2182 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002183 .close = alc880_dig_playback_pcm_close,
2184 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185 },
2186};
2187
2188static struct hda_pcm_stream alc880_pcm_digital_capture = {
2189 .substreams = 1,
2190 .channels_min = 2,
2191 .channels_max = 2,
2192 /* NID is set in alc_build_pcms */
2193};
2194
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002195/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2196static struct hda_pcm_stream alc_pcm_null_playback = {
2197 .substreams = 0,
2198 .channels_min = 0,
2199 .channels_max = 0,
2200};
2201
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202static int alc_build_pcms(struct hda_codec *codec)
2203{
2204 struct alc_spec *spec = codec->spec;
2205 struct hda_pcm *info = spec->pcm_rec;
2206 int i;
2207
2208 codec->num_pcms = 1;
2209 codec->pcm_info = info;
2210
2211 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002212 if (spec->stream_analog_playback) {
2213 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2214 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2215 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2216 }
2217 if (spec->stream_analog_capture) {
2218 snd_assert(spec->adc_nids, return -EINVAL);
2219 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2220 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2221 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222
Takashi Iwai4a471b72005-12-07 13:56:29 +01002223 if (spec->channel_mode) {
2224 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2225 for (i = 0; i < spec->num_channel_mode; i++) {
2226 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2227 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2228 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002229 }
2230 }
2231
Takashi Iwaie08a0072006-09-07 17:52:14 +02002232 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002234 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002235 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002237 if (spec->multiout.dig_out_nid &&
2238 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2240 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2241 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002242 if (spec->dig_in_nid &&
2243 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2245 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2246 }
2247 }
2248
Takashi Iwaie08a0072006-09-07 17:52:14 +02002249 /* If the use of more than one ADC is requested for the current
2250 * model, configure a second analog capture-only PCM.
2251 */
2252 /* Additional Analaog capture for index #2 */
2253 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2254 spec->adc_nids) {
2255 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002256 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002257 info->name = spec->stream_name_analog;
2258 /* No playback stream for second PCM */
2259 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2260 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2261 if (spec->stream_analog_capture) {
2262 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2263 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2264 }
2265 }
2266
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267 return 0;
2268}
2269
2270static void alc_free(struct hda_codec *codec)
2271{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002272 struct alc_spec *spec = codec->spec;
2273 unsigned int i;
2274
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002275 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002276 return;
2277
2278 if (spec->kctl_alloc) {
2279 for (i = 0; i < spec->num_kctl_used; i++)
2280 kfree(spec->kctl_alloc[i].name);
2281 kfree(spec->kctl_alloc);
2282 }
2283 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284}
2285
2286/*
2287 */
2288static struct hda_codec_ops alc_patch_ops = {
2289 .build_controls = alc_build_controls,
2290 .build_pcms = alc_build_pcms,
2291 .init = alc_init,
2292 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002293 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294#ifdef CONFIG_PM
2295 .resume = alc_resume,
2296#endif
2297};
2298
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002299
2300/*
2301 * Test configuration for debugging
2302 *
2303 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2304 * enum controls.
2305 */
2306#ifdef CONFIG_SND_DEBUG
2307static hda_nid_t alc880_test_dac_nids[4] = {
2308 0x02, 0x03, 0x04, 0x05
2309};
2310
2311static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002312 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002313 .items = {
2314 { "In-1", 0x0 },
2315 { "In-2", 0x1 },
2316 { "In-3", 0x2 },
2317 { "In-4", 0x3 },
2318 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002319 { "Front", 0x5 },
2320 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002321 },
2322};
2323
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002324static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002325 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002326 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002327 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002328 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002329};
2330
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002331static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2332 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002333{
2334 static char *texts[] = {
2335 "N/A", "Line Out", "HP Out",
2336 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2337 };
2338 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2339 uinfo->count = 1;
2340 uinfo->value.enumerated.items = 8;
2341 if (uinfo->value.enumerated.item >= 8)
2342 uinfo->value.enumerated.item = 7;
2343 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2344 return 0;
2345}
2346
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002347static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2348 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002349{
2350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2351 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2352 unsigned int pin_ctl, item = 0;
2353
2354 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2355 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2356 if (pin_ctl & AC_PINCTL_OUT_EN) {
2357 if (pin_ctl & AC_PINCTL_HP_EN)
2358 item = 2;
2359 else
2360 item = 1;
2361 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2362 switch (pin_ctl & AC_PINCTL_VREFEN) {
2363 case AC_PINCTL_VREF_HIZ: item = 3; break;
2364 case AC_PINCTL_VREF_50: item = 4; break;
2365 case AC_PINCTL_VREF_GRD: item = 5; break;
2366 case AC_PINCTL_VREF_80: item = 6; break;
2367 case AC_PINCTL_VREF_100: item = 7; break;
2368 }
2369 }
2370 ucontrol->value.enumerated.item[0] = item;
2371 return 0;
2372}
2373
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002374static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2375 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002376{
2377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2378 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2379 static unsigned int ctls[] = {
2380 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2381 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2382 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2383 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2384 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2385 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2386 };
2387 unsigned int old_ctl, new_ctl;
2388
2389 old_ctl = snd_hda_codec_read(codec, nid, 0,
2390 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2391 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2392 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002393 snd_hda_codec_write(codec, nid, 0,
2394 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002395 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002396 (ucontrol->value.enumerated.item[0] >= 3 ?
2397 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002398 return 1;
2399 }
2400 return 0;
2401}
2402
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002403static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2404 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002405{
2406 static char *texts[] = {
2407 "Front", "Surround", "CLFE", "Side"
2408 };
2409 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2410 uinfo->count = 1;
2411 uinfo->value.enumerated.items = 4;
2412 if (uinfo->value.enumerated.item >= 4)
2413 uinfo->value.enumerated.item = 3;
2414 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2415 return 0;
2416}
2417
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002418static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2419 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002420{
2421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2422 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2423 unsigned int sel;
2424
2425 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2426 ucontrol->value.enumerated.item[0] = sel & 3;
2427 return 0;
2428}
2429
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002430static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2431 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002432{
2433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2434 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2435 unsigned int sel;
2436
2437 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2438 if (ucontrol->value.enumerated.item[0] != sel) {
2439 sel = ucontrol->value.enumerated.item[0] & 3;
2440 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2441 return 1;
2442 }
2443 return 0;
2444}
2445
2446#define PIN_CTL_TEST(xname,nid) { \
2447 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2448 .name = xname, \
2449 .info = alc_test_pin_ctl_info, \
2450 .get = alc_test_pin_ctl_get, \
2451 .put = alc_test_pin_ctl_put, \
2452 .private_value = nid \
2453 }
2454
2455#define PIN_SRC_TEST(xname,nid) { \
2456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2457 .name = xname, \
2458 .info = alc_test_pin_src_info, \
2459 .get = alc_test_pin_src_get, \
2460 .put = alc_test_pin_src_put, \
2461 .private_value = nid \
2462 }
2463
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002464static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2466 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2467 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2468 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002469 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2470 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2471 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2472 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002473 PIN_CTL_TEST("Front Pin Mode", 0x14),
2474 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2475 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2476 PIN_CTL_TEST("Side Pin Mode", 0x17),
2477 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2478 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2479 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2480 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2481 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2482 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2483 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2484 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2485 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2486 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2487 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2488 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2489 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2490 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2491 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2492 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2493 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2494 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002495 {
2496 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2497 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002498 .info = alc_ch_mode_info,
2499 .get = alc_ch_mode_get,
2500 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002501 },
2502 { } /* end */
2503};
2504
2505static struct hda_verb alc880_test_init_verbs[] = {
2506 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002507 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2508 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2509 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2510 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2512 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2513 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002515 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002520 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2524 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002525 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2528 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2529 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002530 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002531 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002533 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2535 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002536 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2539 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2540 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002541 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002543 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002544 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002545 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002547 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002548 /* Analog input/passthru */
2549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002554 { }
2555};
2556#endif
2557
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558/*
2559 */
2560
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002561static const char *alc880_models[ALC880_MODEL_LAST] = {
2562 [ALC880_3ST] = "3stack",
2563 [ALC880_TCL_S700] = "tcl",
2564 [ALC880_3ST_DIG] = "3stack-digout",
2565 [ALC880_CLEVO] = "clevo",
2566 [ALC880_5ST] = "5stack",
2567 [ALC880_5ST_DIG] = "5stack-digout",
2568 [ALC880_W810] = "w810",
2569 [ALC880_Z71V] = "z71v",
2570 [ALC880_6ST] = "6stack",
2571 [ALC880_6ST_DIG] = "6stack-digout",
2572 [ALC880_ASUS] = "asus",
2573 [ALC880_ASUS_W1V] = "asus-w1v",
2574 [ALC880_ASUS_DIG] = "asus-dig",
2575 [ALC880_ASUS_DIG2] = "asus-dig2",
2576 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002577 [ALC880_UNIWILL_P53] = "uniwill-p53",
2578 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002579 [ALC880_F1734] = "F1734",
2580 [ALC880_LG] = "lg",
2581 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002582#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002583 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002584#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002585 [ALC880_AUTO] = "auto",
2586};
2587
2588static struct snd_pci_quirk alc880_cfg_tbl[] = {
2589 /* Broken BIOS configuration */
2590 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2591 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2592
2593 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2594 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002595 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002596 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2597 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2598 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2599 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2600 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2601 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2602
2603 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2604 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2605
2606 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2607 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2608 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2609 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2610 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2611 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2612 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2613 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2614 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2615 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002616 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002617 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2618 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2619 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2620 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2621
2622 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2623 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2624 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2625 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2626 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2627 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2628 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2629 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2630 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2631 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2632 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2633 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2634 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2635 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2636 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2637 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2638 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2639 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2640
2641 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2642 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2643 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2644 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2645
2646 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2647 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2648 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002649 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002650
2651 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2652 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2653 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2654 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2655
2656 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2657 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2658 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2659 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2660 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2661 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2662 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2663 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2664 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2665 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2666 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002667
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668 {}
2669};
2670
Takashi Iwai16ded522005-06-10 19:58:24 +02002671/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002672 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002674static struct alc_config_preset alc880_presets[] = {
2675 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002677 .init_verbs = { alc880_volume_init_verbs,
2678 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002679 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002680 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002681 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2682 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002683 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 .input_mux = &alc880_capture_source,
2685 },
2686 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002688 .init_verbs = { alc880_volume_init_verbs,
2689 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002691 .dac_nids = alc880_dac_nids,
2692 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002693 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2694 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002695 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002696 .input_mux = &alc880_capture_source,
2697 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002698 [ALC880_TCL_S700] = {
2699 .mixers = { alc880_tcl_s700_mixer },
2700 .init_verbs = { alc880_volume_init_verbs,
2701 alc880_pin_tcl_S700_init_verbs,
2702 alc880_gpio2_init_verbs },
2703 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2704 .dac_nids = alc880_dac_nids,
2705 .hp_nid = 0x03,
2706 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2707 .channel_mode = alc880_2_jack_modes,
2708 .input_mux = &alc880_capture_source,
2709 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002710 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002711 .mixers = { alc880_three_stack_mixer,
2712 alc880_five_stack_mixer},
2713 .init_verbs = { alc880_volume_init_verbs,
2714 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002715 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2716 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002717 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2718 .channel_mode = alc880_fivestack_modes,
2719 .input_mux = &alc880_capture_source,
2720 },
2721 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002722 .mixers = { alc880_three_stack_mixer,
2723 alc880_five_stack_mixer },
2724 .init_verbs = { alc880_volume_init_verbs,
2725 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002726 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2727 .dac_nids = alc880_dac_nids,
2728 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2730 .channel_mode = alc880_fivestack_modes,
2731 .input_mux = &alc880_capture_source,
2732 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002733 [ALC880_6ST] = {
2734 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002735 .init_verbs = { alc880_volume_init_verbs,
2736 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002737 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2738 .dac_nids = alc880_6st_dac_nids,
2739 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2740 .channel_mode = alc880_sixstack_modes,
2741 .input_mux = &alc880_6stack_capture_source,
2742 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002743 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002745 .init_verbs = { alc880_volume_init_verbs,
2746 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002747 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2748 .dac_nids = alc880_6st_dac_nids,
2749 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002750 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2751 .channel_mode = alc880_sixstack_modes,
2752 .input_mux = &alc880_6stack_capture_source,
2753 },
2754 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002755 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002756 .init_verbs = { alc880_volume_init_verbs,
2757 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002758 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002759 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2760 .dac_nids = alc880_w810_dac_nids,
2761 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002762 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2763 .channel_mode = alc880_w810_modes,
2764 .input_mux = &alc880_capture_source,
2765 },
2766 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002767 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002768 .init_verbs = { alc880_volume_init_verbs,
2769 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002770 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2771 .dac_nids = alc880_z71v_dac_nids,
2772 .dig_out_nid = ALC880_DIGOUT_NID,
2773 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002774 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2775 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002776 .input_mux = &alc880_capture_source,
2777 },
2778 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002779 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002780 .init_verbs = { alc880_volume_init_verbs,
2781 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002782 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2783 .dac_nids = alc880_f1734_dac_nids,
2784 .hp_nid = 0x02,
2785 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2786 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002787 .input_mux = &alc880_capture_source,
2788 },
2789 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002790 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002791 .init_verbs = { alc880_volume_init_verbs,
2792 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002793 alc880_gpio1_init_verbs },
2794 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2795 .dac_nids = alc880_asus_dac_nids,
2796 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2797 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002798 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002799 .input_mux = &alc880_capture_source,
2800 },
2801 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002803 .init_verbs = { alc880_volume_init_verbs,
2804 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002805 alc880_gpio1_init_verbs },
2806 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2807 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002808 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002809 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2810 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002811 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002812 .input_mux = &alc880_capture_source,
2813 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002814 [ALC880_ASUS_DIG2] = {
2815 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002816 .init_verbs = { alc880_volume_init_verbs,
2817 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002818 alc880_gpio2_init_verbs }, /* use GPIO2 */
2819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2820 .dac_nids = alc880_asus_dac_nids,
2821 .dig_out_nid = ALC880_DIGOUT_NID,
2822 .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,
Kailang Yangdf694da2005-12-05 19:42:22 +01002825 .input_mux = &alc880_capture_source,
2826 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002827 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002828 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002829 .init_verbs = { alc880_volume_init_verbs,
2830 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002831 alc880_gpio1_init_verbs },
2832 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2833 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002834 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002835 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2836 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002837 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002838 .input_mux = &alc880_capture_source,
2839 },
2840 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002841 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002842 .init_verbs = { alc880_volume_init_verbs,
2843 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002844 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2845 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002846 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002847 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2848 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002849 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002850 .input_mux = &alc880_capture_source,
2851 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002852 [ALC880_UNIWILL] = {
2853 .mixers = { alc880_uniwill_mixer },
2854 .init_verbs = { alc880_volume_init_verbs,
2855 alc880_uniwill_init_verbs },
2856 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2857 .dac_nids = alc880_asus_dac_nids,
2858 .dig_out_nid = ALC880_DIGOUT_NID,
2859 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2860 .channel_mode = alc880_threestack_modes,
2861 .need_dac_fix = 1,
2862 .input_mux = &alc880_capture_source,
2863 .unsol_event = alc880_uniwill_unsol_event,
2864 .init_hook = alc880_uniwill_automute,
2865 },
2866 [ALC880_UNIWILL_P53] = {
2867 .mixers = { alc880_uniwill_p53_mixer },
2868 .init_verbs = { alc880_volume_init_verbs,
2869 alc880_uniwill_p53_init_verbs },
2870 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2871 .dac_nids = alc880_asus_dac_nids,
2872 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002873 .channel_mode = alc880_threestack_modes,
2874 .input_mux = &alc880_capture_source,
2875 .unsol_event = alc880_uniwill_p53_unsol_event,
2876 .init_hook = alc880_uniwill_p53_hp_automute,
2877 },
2878 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002879 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002880 alc880_pcbeep_mixer, },
2881 .init_verbs = { alc880_volume_init_verbs,
2882 alc880_uniwill_p53_init_verbs,
2883 alc880_beep_init_verbs },
2884 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2885 .dac_nids = alc880_dac_nids,
2886 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2887 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002888 .input_mux = &alc880_capture_source,
2889 .unsol_event = alc880_uniwill_p53_unsol_event,
2890 .init_hook = alc880_uniwill_p53_hp_automute,
2891 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002892 [ALC880_CLEVO] = {
2893 .mixers = { alc880_three_stack_mixer },
2894 .init_verbs = { alc880_volume_init_verbs,
2895 alc880_pin_clevo_init_verbs },
2896 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2897 .dac_nids = alc880_dac_nids,
2898 .hp_nid = 0x03,
2899 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2900 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002901 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002902 .input_mux = &alc880_capture_source,
2903 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002904 [ALC880_LG] = {
2905 .mixers = { alc880_lg_mixer },
2906 .init_verbs = { alc880_volume_init_verbs,
2907 alc880_lg_init_verbs },
2908 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2909 .dac_nids = alc880_lg_dac_nids,
2910 .dig_out_nid = ALC880_DIGOUT_NID,
2911 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2912 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002913 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002914 .input_mux = &alc880_lg_capture_source,
2915 .unsol_event = alc880_lg_unsol_event,
2916 .init_hook = alc880_lg_automute,
2917 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002918 [ALC880_LG_LW] = {
2919 .mixers = { alc880_lg_lw_mixer },
2920 .init_verbs = { alc880_volume_init_verbs,
2921 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002922 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002923 .dac_nids = alc880_dac_nids,
2924 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002925 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2926 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002927 .input_mux = &alc880_lg_lw_capture_source,
2928 .unsol_event = alc880_lg_lw_unsol_event,
2929 .init_hook = alc880_lg_lw_automute,
2930 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002931#ifdef CONFIG_SND_DEBUG
2932 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002933 .mixers = { alc880_test_mixer },
2934 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002935 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2936 .dac_nids = alc880_test_dac_nids,
2937 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002938 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2939 .channel_mode = alc880_test_modes,
2940 .input_mux = &alc880_test_capture_source,
2941 },
2942#endif
2943};
2944
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002945/*
2946 * Automatic parse of I/O pins from the BIOS configuration
2947 */
2948
2949#define NUM_CONTROL_ALLOC 32
2950#define NUM_VERB_ALLOC 32
2951
2952enum {
2953 ALC_CTL_WIDGET_VOL,
2954 ALC_CTL_WIDGET_MUTE,
2955 ALC_CTL_BIND_MUTE,
2956};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002957static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002958 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2959 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002960 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961};
2962
2963/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002964static int add_control(struct alc_spec *spec, int type, const char *name,
2965 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002967 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002968
2969 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2970 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2971
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002972 /* array + terminator */
2973 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2974 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975 return -ENOMEM;
2976 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002977 memcpy(knew, spec->kctl_alloc,
2978 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002979 kfree(spec->kctl_alloc);
2980 }
2981 spec->kctl_alloc = knew;
2982 spec->num_kctl_alloc = num;
2983 }
2984
2985 knew = &spec->kctl_alloc[spec->num_kctl_used];
2986 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002987 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002988 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002989 return -ENOMEM;
2990 knew->private_value = val;
2991 spec->num_kctl_used++;
2992 return 0;
2993}
2994
2995#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2996#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2997#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2998#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2999#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3000#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3001#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3002#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3003#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3004#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3005#define ALC880_PIN_CD_NID 0x1c
3006
3007/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003008static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3009 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003010{
3011 hda_nid_t nid;
3012 int assigned[4];
3013 int i, j;
3014
3015 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003016 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017
3018 /* check the pins hardwired to audio widget */
3019 for (i = 0; i < cfg->line_outs; i++) {
3020 nid = cfg->line_out_pins[i];
3021 if (alc880_is_fixed_pin(nid)) {
3022 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003023 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003024 assigned[idx] = 1;
3025 }
3026 }
3027 /* left pins can be connect to any audio widget */
3028 for (i = 0; i < cfg->line_outs; i++) {
3029 nid = cfg->line_out_pins[i];
3030 if (alc880_is_fixed_pin(nid))
3031 continue;
3032 /* search for an empty channel */
3033 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003034 if (!assigned[j]) {
3035 spec->multiout.dac_nids[i] =
3036 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003037 assigned[j] = 1;
3038 break;
3039 }
3040 }
3041 }
3042 spec->multiout.num_dacs = cfg->line_outs;
3043 return 0;
3044}
3045
3046/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003047static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3048 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003049{
3050 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003051 static const char *chname[4] = {
3052 "Front", "Surround", NULL /*CLFE*/, "Side"
3053 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003054 hda_nid_t nid;
3055 int i, err;
3056
3057 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003058 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003059 continue;
3060 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3061 if (i == 2) {
3062 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003063 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3064 "Center Playback Volume",
3065 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3066 HDA_OUTPUT));
3067 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003068 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003069 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3070 "LFE Playback Volume",
3071 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3072 HDA_OUTPUT));
3073 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003074 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003075 err = add_control(spec, ALC_CTL_BIND_MUTE,
3076 "Center Playback Switch",
3077 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3078 HDA_INPUT));
3079 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003080 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003081 err = add_control(spec, ALC_CTL_BIND_MUTE,
3082 "LFE Playback Switch",
3083 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3084 HDA_INPUT));
3085 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 return err;
3087 } else {
3088 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003089 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3090 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3091 HDA_OUTPUT));
3092 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003093 return err;
3094 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003095 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3096 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3097 HDA_INPUT));
3098 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003099 return err;
3100 }
3101 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003102 return 0;
3103}
3104
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003105/* add playback controls for speaker and HP outputs */
3106static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3107 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108{
3109 hda_nid_t nid;
3110 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003111 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003112
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003113 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003114 return 0;
3115
3116 if (alc880_is_fixed_pin(pin)) {
3117 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003118 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003119 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003121 else
3122 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003123 /* control HP volume/switch on the output mixer amp */
3124 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003125 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003126 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3127 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3128 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003129 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003130 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003131 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3132 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3133 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003134 return err;
3135 } else if (alc880_is_multi_pin(pin)) {
3136 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003138 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003139 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3140 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3141 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003142 return err;
3143 }
3144 return 0;
3145}
3146
3147/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003148static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3149 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003150 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003151{
3152 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003153 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003154
3155 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003156 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3157 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3158 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003159 return err;
3160 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003161 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3162 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3163 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003164 return err;
3165 return 0;
3166}
3167
3168/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003169static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3170 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003171{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003172 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003173 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174
3175 for (i = 0; i < AUTO_PIN_LAST; i++) {
3176 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003177 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003178 err = new_analog_input(spec, cfg->input_pins[i],
3179 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003180 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003181 if (err < 0)
3182 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003183 imux->items[imux->num_items].label =
3184 auto_pin_cfg_labels[i];
3185 imux->items[imux->num_items].index =
3186 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003187 imux->num_items++;
3188 }
3189 }
3190 return 0;
3191}
3192
Kailang Yangdf694da2005-12-05 19:42:22 +01003193static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3194 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003195 int dac_idx)
3196{
3197 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003198 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3199 pin_type);
3200 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3201 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003202 /* need the manual connection? */
3203 if (alc880_is_multi_pin(nid)) {
3204 struct alc_spec *spec = codec->spec;
3205 int idx = alc880_multi_pin_idx(nid);
3206 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3207 AC_VERB_SET_CONNECT_SEL,
3208 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3209 }
3210}
3211
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003212static int get_pin_type(int line_out_type)
3213{
3214 if (line_out_type == AUTO_PIN_HP_OUT)
3215 return PIN_HP;
3216 else
3217 return PIN_OUT;
3218}
3219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003220static void alc880_auto_init_multi_out(struct hda_codec *codec)
3221{
3222 struct alc_spec *spec = codec->spec;
3223 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003224
3225 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003226 for (i = 0; i < spec->autocfg.line_outs; i++) {
3227 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003228 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3229 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230 }
3231}
3232
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003233static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003234{
3235 struct alc_spec *spec = codec->spec;
3236 hda_nid_t pin;
3237
Takashi Iwai82bc9552006-03-21 11:24:42 +01003238 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003239 if (pin) /* connect to front */
3240 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003241 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242 if (pin) /* connect to front */
3243 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3244}
3245
3246static void alc880_auto_init_analog_input(struct hda_codec *codec)
3247{
3248 struct alc_spec *spec = codec->spec;
3249 int i;
3250
3251 for (i = 0; i < AUTO_PIN_LAST; i++) {
3252 hda_nid_t nid = spec->autocfg.input_pins[i];
3253 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003254 snd_hda_codec_write(codec, nid, 0,
3255 AC_VERB_SET_PIN_WIDGET_CONTROL,
3256 i <= AUTO_PIN_FRONT_MIC ?
3257 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003258 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003259 snd_hda_codec_write(codec, nid, 0,
3260 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 AMP_OUT_MUTE);
3262 }
3263 }
3264}
3265
3266/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003267/* return 1 if successful, 0 if the proper config is not found,
3268 * or a negative error code
3269 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270static int alc880_parse_auto_config(struct hda_codec *codec)
3271{
3272 struct alc_spec *spec = codec->spec;
3273 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003274 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003276 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3277 alc880_ignore);
3278 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003279 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003280 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003282
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003283 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3284 if (err < 0)
3285 return err;
3286 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3287 if (err < 0)
3288 return err;
3289 err = alc880_auto_create_extra_out(spec,
3290 spec->autocfg.speaker_pins[0],
3291 "Speaker");
3292 if (err < 0)
3293 return err;
3294 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3295 "Headphone");
3296 if (err < 0)
3297 return err;
3298 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3299 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003300 return err;
3301
3302 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3303
3304 if (spec->autocfg.dig_out_pin)
3305 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3306 if (spec->autocfg.dig_in_pin)
3307 spec->dig_in_nid = ALC880_DIGIN_NID;
3308
3309 if (spec->kctl_alloc)
3310 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3311
3312 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3313
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003314 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003315 spec->input_mux = &spec->private_imux;
3316
3317 return 1;
3318}
3319
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003320/* additional initialization for auto-configuration model */
3321static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003322{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003323 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003324 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003325 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003326}
3327
3328/*
3329 * OK, here we have finally the patch for ALC880
3330 */
3331
Linus Torvalds1da177e2005-04-16 15:20:36 -07003332static int patch_alc880(struct hda_codec *codec)
3333{
3334 struct alc_spec *spec;
3335 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003336 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003337
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003338 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003339 if (spec == NULL)
3340 return -ENOMEM;
3341
3342 codec->spec = spec;
3343
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003344 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3345 alc880_models,
3346 alc880_cfg_tbl);
3347 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003348 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3349 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003350 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003351 }
3352
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003353 if (board_config == ALC880_AUTO) {
3354 /* automatic parse from the BIOS config */
3355 err = alc880_parse_auto_config(codec);
3356 if (err < 0) {
3357 alc_free(codec);
3358 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003359 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003360 printk(KERN_INFO
3361 "hda_codec: Cannot set up configuration "
3362 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003363 board_config = ALC880_3ST;
3364 }
3365 }
3366
Kailang Yangdf694da2005-12-05 19:42:22 +01003367 if (board_config != ALC880_AUTO)
3368 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369
3370 spec->stream_name_analog = "ALC880 Analog";
3371 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3372 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3373
3374 spec->stream_name_digital = "ALC880 Digital";
3375 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3376 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3377
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003378 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003379 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003380 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003381 /* get type */
3382 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003383 if (wcap != AC_WID_AUD_IN) {
3384 spec->adc_nids = alc880_adc_nids_alt;
3385 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003386 spec->mixers[spec->num_mixers] =
3387 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003388 spec->num_mixers++;
3389 } else {
3390 spec->adc_nids = alc880_adc_nids;
3391 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3392 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3393 spec->num_mixers++;
3394 }
3395 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003396
3397 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003399 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003400
3401 return 0;
3402}
3403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404
Linus Torvalds1da177e2005-04-16 15:20:36 -07003405/*
3406 * ALC260 support
3407 */
3408
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409static hda_nid_t alc260_dac_nids[1] = {
3410 /* front */
3411 0x02,
3412};
3413
3414static hda_nid_t alc260_adc_nids[1] = {
3415 /* ADC0 */
3416 0x04,
3417};
3418
Kailang Yangdf694da2005-12-05 19:42:22 +01003419static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003420 /* ADC1 */
3421 0x05,
3422};
3423
Kailang Yangdf694da2005-12-05 19:42:22 +01003424static hda_nid_t alc260_hp_adc_nids[2] = {
3425 /* ADC1, 0 */
3426 0x05, 0x04
3427};
3428
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003429/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3430 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3431 */
3432static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003433 /* ADC0, ADC1 */
3434 0x04, 0x05
3435};
3436
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003437#define ALC260_DIGOUT_NID 0x03
3438#define ALC260_DIGIN_NID 0x06
3439
3440static struct hda_input_mux alc260_capture_source = {
3441 .num_items = 4,
3442 .items = {
3443 { "Mic", 0x0 },
3444 { "Front Mic", 0x1 },
3445 { "Line", 0x2 },
3446 { "CD", 0x4 },
3447 },
3448};
3449
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003450/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003451 * headphone jack and the internal CD lines since these are the only pins at
3452 * which audio can appear. For flexibility, also allow the option of
3453 * recording the mixer output on the second ADC (ADC0 doesn't have a
3454 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003455 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003456static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3457 {
3458 .num_items = 3,
3459 .items = {
3460 { "Mic/Line", 0x0 },
3461 { "CD", 0x4 },
3462 { "Headphone", 0x2 },
3463 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003464 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003465 {
3466 .num_items = 4,
3467 .items = {
3468 { "Mic/Line", 0x0 },
3469 { "CD", 0x4 },
3470 { "Headphone", 0x2 },
3471 { "Mixer", 0x5 },
3472 },
3473 },
3474
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003475};
3476
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003477/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3478 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003479 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003480static struct hda_input_mux alc260_acer_capture_sources[2] = {
3481 {
3482 .num_items = 4,
3483 .items = {
3484 { "Mic", 0x0 },
3485 { "Line", 0x2 },
3486 { "CD", 0x4 },
3487 { "Headphone", 0x5 },
3488 },
3489 },
3490 {
3491 .num_items = 5,
3492 .items = {
3493 { "Mic", 0x0 },
3494 { "Line", 0x2 },
3495 { "CD", 0x4 },
3496 { "Headphone", 0x6 },
3497 { "Mixer", 0x5 },
3498 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003499 },
3500};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501/*
3502 * This is just place-holder, so there's something for alc_build_pcms to look
3503 * at when it calculates the maximum number of channels. ALC260 has no mixer
3504 * element which allows changing the channel mode, so the verb list is
3505 * never used.
3506 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003507static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 { 2, NULL },
3509};
3510
Kailang Yangdf694da2005-12-05 19:42:22 +01003511
3512/* Mixer combinations
3513 *
3514 * basic: base_output + input + pc_beep + capture
3515 * HP: base_output + input + capture_alt
3516 * HP_3013: hp_3013 + input + capture
3517 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003518 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003519 */
3520
3521static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003522 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003523 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003524 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3525 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3526 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3527 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3528 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003529};
Kailang Yangdf694da2005-12-05 19:42:22 +01003530
3531static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003532 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3533 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3534 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3535 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3537 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3538 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3539 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003540 { } /* end */
3541};
3542
Kailang Yangdf694da2005-12-05 19:42:22 +01003543static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3544 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3545 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3546 { } /* end */
3547};
3548
3549static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3550 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3551 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3552 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3553 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3554 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3556 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3557 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003558 { } /* end */
3559};
3560
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003561/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3562 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3563 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003564static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003565 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003566 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003567 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003568 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3569 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3570 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3571 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003572 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003573 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3574 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3575 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003576 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003577 { } /* end */
3578};
3579
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003580/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3581 * versions of the ALC260 don't act on requests to enable mic bias from NID
3582 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3583 * datasheet doesn't mention this restriction. At this stage it's not clear
3584 * whether this behaviour is intentional or is a hardware bug in chip
3585 * revisions available in early 2006. Therefore for now allow the
3586 * "Headphone Jack Mode" control to span all choices, but if it turns out
3587 * that the lack of mic bias for this NID is intentional we could change the
3588 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3589 *
3590 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3591 * don't appear to make the mic bias available from the "line" jack, even
3592 * though the NID used for this jack (0x14) can supply it. The theory is
3593 * that perhaps Acer have included blocking capacitors between the ALC260
3594 * and the output jack. If this turns out to be the case for all such
3595 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3596 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003597 *
3598 * The C20x Tablet series have a mono internal speaker which is controlled
3599 * via the chip's Mono sum widget and pin complex, so include the necessary
3600 * controls for such models. On models without a "mono speaker" the control
3601 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003602 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003603static struct snd_kcontrol_new alc260_acer_mixer[] = {
3604 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3605 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003606 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003607 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3608 HDA_OUTPUT),
3609 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3610 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003611 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3612 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3613 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3614 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3615 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3616 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3617 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3618 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3619 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3620 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3621 { } /* end */
3622};
3623
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003624/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3625 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3626 */
3627static struct snd_kcontrol_new alc260_will_mixer[] = {
3628 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3629 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3631 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3632 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3633 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3634 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3635 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3636 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3637 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3638 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3639 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3640 { } /* end */
3641};
3642
3643/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3644 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3645 */
3646static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3647 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3648 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3650 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3651 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3652 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3653 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3654 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3655 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3656 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3657 { } /* end */
3658};
3659
Kailang Yangdf694da2005-12-05 19:42:22 +01003660/* capture mixer elements */
3661static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003662 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3663 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003664 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3665 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003666 {
3667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003668 /* The multiple "Capture Source" controls confuse alsamixer
3669 * So call somewhat different..
3670 * FIXME: the controls appear in the "playback" view!
3671 */
3672 /* .name = "Capture Source", */
3673 .name = "Input Source",
3674 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003675 .info = alc_mux_enum_info,
3676 .get = alc_mux_enum_get,
3677 .put = alc_mux_enum_put,
3678 },
3679 { } /* end */
3680};
3681
Kailang Yangdf694da2005-12-05 19:42:22 +01003682static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3683 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3684 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3685 {
3686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3687 /* The multiple "Capture Source" controls confuse alsamixer
3688 * So call somewhat different..
3689 * FIXME: the controls appear in the "playback" view!
3690 */
3691 /* .name = "Capture Source", */
3692 .name = "Input Source",
3693 .count = 1,
3694 .info = alc_mux_enum_info,
3695 .get = alc_mux_enum_get,
3696 .put = alc_mux_enum_put,
3697 },
3698 { } /* end */
3699};
3700
3701/*
3702 * initialization verbs
3703 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003704static struct hda_verb alc260_init_verbs[] = {
3705 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003707 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003709 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003710 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003711 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003712 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003713 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003715 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003716 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003718 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003719 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003720 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003721 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003722 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3723 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003724 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003725 /* set connection select to line in (default select for this ADC) */
3726 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003727 /* mute capture amp left and right */
3728 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3729 /* set connection select to line in (default select for this ADC) */
3730 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003731 /* set vol=0 Line-Out mixer amp left and right */
3732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3733 /* unmute pin widget amp left and right (no gain on this amp) */
3734 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3735 /* set vol=0 HP mixer amp left and right */
3736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3737 /* unmute pin widget amp left and right (no gain on this amp) */
3738 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3739 /* set vol=0 Mono mixer amp left and right */
3740 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3741 /* unmute pin widget amp left and right (no gain on this amp) */
3742 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3743 /* unmute LINE-2 out pin */
3744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003745 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3746 * Line In 2 = 0x03
3747 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003748 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003750 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003752 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003754 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003755 /* mute Front out path */
3756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3757 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3758 /* mute Headphone out path */
3759 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3761 /* mute Mono out path */
3762 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3763 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003764 { }
3765};
3766
Takashi Iwai474167d2006-05-17 17:17:43 +02003767#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003768static struct hda_verb alc260_hp_init_verbs[] = {
3769 /* Headphone and output */
3770 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3771 /* mono output */
3772 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3773 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3774 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3775 /* Mic2 (front panel) pin widget for input and vref at 80% */
3776 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3777 /* Line In pin widget for input */
3778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3779 /* Line-2 pin widget for output */
3780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3781 /* CD pin widget for input */
3782 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3783 /* unmute amp left and right */
3784 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3785 /* set connection select to line in (default select for this ADC) */
3786 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3787 /* unmute Line-Out mixer amp left and right (volume = 0) */
3788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3789 /* mute pin widget amp left and right (no gain on this amp) */
3790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3791 /* unmute HP mixer amp left and right (volume = 0) */
3792 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3793 /* mute pin widget amp left and right (no gain on this amp) */
3794 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003795 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3796 * Line In 2 = 0x03
3797 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003798 /* unmute CD */
3799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3800 /* unmute Line In */
3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3802 /* unmute Mic */
3803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3804 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3805 /* Unmute Front out path */
3806 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3808 /* Unmute Headphone out path */
3809 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3811 /* Unmute Mono out path */
3812 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3813 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3814 { }
3815};
Takashi Iwai474167d2006-05-17 17:17:43 +02003816#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003817
3818static struct hda_verb alc260_hp_3013_init_verbs[] = {
3819 /* Line out and output */
3820 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3821 /* mono output */
3822 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3823 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3824 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3825 /* Mic2 (front panel) pin widget for input and vref at 80% */
3826 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3827 /* Line In pin widget for input */
3828 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3829 /* Headphone pin widget for output */
3830 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3831 /* CD pin widget for input */
3832 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3833 /* unmute amp left and right */
3834 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3835 /* set connection select to line in (default select for this ADC) */
3836 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3837 /* unmute Line-Out mixer amp left and right (volume = 0) */
3838 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3839 /* mute pin widget amp left and right (no gain on this amp) */
3840 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3841 /* unmute HP mixer amp left and right (volume = 0) */
3842 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3843 /* mute pin widget amp left and right (no gain on this amp) */
3844 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003845 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3846 * Line In 2 = 0x03
3847 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003848 /* unmute CD */
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3850 /* unmute Line In */
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3852 /* unmute Mic */
3853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3854 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3855 /* Unmute Front out path */
3856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3858 /* Unmute Headphone out path */
3859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3861 /* Unmute Mono out path */
3862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3864 { }
3865};
3866
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003867/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003868 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3869 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003870 */
3871static struct hda_verb alc260_fujitsu_init_verbs[] = {
3872 /* Disable all GPIOs */
3873 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3874 /* Internal speaker is connected to headphone pin */
3875 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3876 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003878 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3879 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3880 /* Ensure all other unused pins are disabled and muted. */
3881 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3882 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003883 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003884 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003885 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003886 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003889
Jonathan Woithef7ace402006-02-28 11:46:14 +01003890 /* Disable digital (SPDIF) pins */
3891 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3892 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003893
Jonathan Woithef7ace402006-02-28 11:46:14 +01003894 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3895 * when acting as an output.
3896 */
3897 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3898
3899 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3903 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3906 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3907 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003909
Jonathan Woithef7ace402006-02-28 11:46:14 +01003910 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3911 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3912 /* Unmute Line1 pin widget output buffer since it starts as an output.
3913 * If the pin mode is changed by the user the pin mode control will
3914 * take care of enabling the pin's input/output buffers as needed.
3915 * Therefore there's no need to enable the input buffer at this
3916 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003917 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003919 /* Unmute input buffer of pin widget used for Line-in (no equiv
3920 * mixer ctrl)
3921 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003922 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003923
Jonathan Woithef7ace402006-02-28 11:46:14 +01003924 /* Mute capture amp left and right */
3925 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3926 /* Set ADC connection select to match default mixer setting - line
3927 * in (on mic1 pin)
3928 */
3929 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003930
Jonathan Woithef7ace402006-02-28 11:46:14 +01003931 /* Do the same for the second ADC: mute capture input amp and
3932 * set ADC connection to line in (on mic1 pin)
3933 */
3934 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3935 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003936
Jonathan Woithef7ace402006-02-28 11:46:14 +01003937 /* Mute all inputs to mixer widget (even unconnected ones) */
3938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003946
3947 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003948};
3949
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003950/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3951 * similar laptops (adapted from Fujitsu init verbs).
3952 */
3953static struct hda_verb alc260_acer_init_verbs[] = {
3954 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3955 * the headphone jack. Turn this on and rely on the standard mute
3956 * methods whenever the user wants to turn these outputs off.
3957 */
3958 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3959 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3960 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3961 /* Internal speaker/Headphone jack is connected to Line-out pin */
3962 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3963 /* Internal microphone/Mic jack is connected to Mic1 pin */
3964 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3965 /* Line In jack is connected to Line1 pin */
3966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003967 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3968 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003969 /* Ensure all other unused pins are disabled and muted. */
3970 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3971 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003972 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3973 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3976 /* Disable digital (SPDIF) pins */
3977 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3978 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3979
3980 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3981 * bus when acting as outputs.
3982 */
3983 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3984 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3985
3986 /* Start with output sum widgets muted and their output gains at min */
3987 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3990 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3992 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3993 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3994 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3995 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3996
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003997 /* Unmute Line-out pin widget amp left and right
3998 * (no equiv mixer ctrl)
3999 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004001 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4002 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004003 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4004 * inputs. If the pin mode is changed by the user the pin mode control
4005 * will take care of enabling the pin's input/output buffers as needed.
4006 * Therefore there's no need to enable the input buffer at this
4007 * stage.
4008 */
4009 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4011
4012 /* Mute capture amp left and right */
4013 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4014 /* Set ADC connection select to match default mixer setting - mic
4015 * (on mic1 pin)
4016 */
4017 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4018
4019 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004020 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004021 */
4022 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004023 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004024
4025 /* Mute all inputs to mixer widget (even unconnected ones) */
4026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4034
4035 { }
4036};
4037
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004038static struct hda_verb alc260_will_verbs[] = {
4039 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4040 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4041 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4042 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4043 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4044 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4045 {}
4046};
4047
4048static struct hda_verb alc260_replacer_672v_verbs[] = {
4049 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4050 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4051 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4052
4053 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4054 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4055 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4056
4057 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4058 {}
4059};
4060
4061/* toggle speaker-output according to the hp-jack state */
4062static void alc260_replacer_672v_automute(struct hda_codec *codec)
4063{
4064 unsigned int present;
4065
4066 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4067 present = snd_hda_codec_read(codec, 0x0f, 0,
4068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4069 if (present) {
4070 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4071 snd_hda_codec_write(codec, 0x0f, 0,
4072 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4073 } else {
4074 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4075 snd_hda_codec_write(codec, 0x0f, 0,
4076 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4077 }
4078}
4079
4080static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4081 unsigned int res)
4082{
4083 if ((res >> 26) == ALC880_HP_EVENT)
4084 alc260_replacer_672v_automute(codec);
4085}
4086
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004087/* Test configuration for debugging, modelled after the ALC880 test
4088 * configuration.
4089 */
4090#ifdef CONFIG_SND_DEBUG
4091static hda_nid_t alc260_test_dac_nids[1] = {
4092 0x02,
4093};
4094static hda_nid_t alc260_test_adc_nids[2] = {
4095 0x04, 0x05,
4096};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004097/* For testing the ALC260, each input MUX needs its own definition since
4098 * the signal assignments are different. This assumes that the first ADC
4099 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004100 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004101static struct hda_input_mux alc260_test_capture_sources[2] = {
4102 {
4103 .num_items = 7,
4104 .items = {
4105 { "MIC1 pin", 0x0 },
4106 { "MIC2 pin", 0x1 },
4107 { "LINE1 pin", 0x2 },
4108 { "LINE2 pin", 0x3 },
4109 { "CD pin", 0x4 },
4110 { "LINE-OUT pin", 0x5 },
4111 { "HP-OUT pin", 0x6 },
4112 },
4113 },
4114 {
4115 .num_items = 8,
4116 .items = {
4117 { "MIC1 pin", 0x0 },
4118 { "MIC2 pin", 0x1 },
4119 { "LINE1 pin", 0x2 },
4120 { "LINE2 pin", 0x3 },
4121 { "CD pin", 0x4 },
4122 { "Mixer", 0x5 },
4123 { "LINE-OUT pin", 0x6 },
4124 { "HP-OUT pin", 0x7 },
4125 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004126 },
4127};
4128static struct snd_kcontrol_new alc260_test_mixer[] = {
4129 /* Output driver widgets */
4130 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4131 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4132 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4133 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4134 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4135 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4136
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004137 /* Modes for retasking pin widgets
4138 * Note: the ALC260 doesn't seem to act on requests to enable mic
4139 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4140 * mention this restriction. At this stage it's not clear whether
4141 * this behaviour is intentional or is a hardware bug in chip
4142 * revisions available at least up until early 2006. Therefore for
4143 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4144 * choices, but if it turns out that the lack of mic bias for these
4145 * NIDs is intentional we could change their modes from
4146 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4147 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004148 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4149 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4150 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4151 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4152 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4153 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4154
4155 /* Loopback mixer controls */
4156 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4157 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4158 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4159 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4160 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4161 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4162 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4163 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4164 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4165 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4166 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4167 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4168 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4169 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4170 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4171 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004172
4173 /* Controls for GPIO pins, assuming they are configured as outputs */
4174 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4175 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4176 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4177 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4178
Jonathan Woithe92621f12006-02-28 11:47:47 +01004179 /* Switches to allow the digital IO pins to be enabled. The datasheet
4180 * is ambigious as to which NID is which; testing on laptops which
4181 * make this output available should provide clarification.
4182 */
4183 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4184 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4185
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004186 { } /* end */
4187};
4188static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004189 /* Enable all GPIOs as outputs with an initial value of 0 */
4190 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4191 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4192 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4193
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004194 /* Enable retasking pins as output, initially without power amp */
4195 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4196 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4197 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4199 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4200 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201
Jonathan Woithe92621f12006-02-28 11:47:47 +01004202 /* Disable digital (SPDIF) pins initially, but users can enable
4203 * them via a mixer switch. In the case of SPDIF-out, this initverb
4204 * payload also sets the generation to 0, output to be in "consumer"
4205 * PCM format, copyright asserted, no pre-emphasis and no validity
4206 * control.
4207 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004208 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4209 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4210
Jonathan Woithef7ace402006-02-28 11:46:14 +01004211 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004212 * OUT1 sum bus when acting as an output.
4213 */
4214 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4215 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4216 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4217 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4218
4219 /* Start with output sum widgets muted and their output gains at min */
4220 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4223 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4226 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4227 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4228 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4229
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004230 /* Unmute retasking pin widget output buffers since the default
4231 * state appears to be output. As the pin mode is changed by the
4232 * user the pin mode control will take care of enabling the pin's
4233 * input/output buffers as needed.
4234 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004235 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4239 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4240 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 /* Also unmute the mono-out pin widget */
4242 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004244 /* Mute capture amp left and right */
4245 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004246 /* Set ADC connection select to match default mixer setting (mic1
4247 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004248 */
4249 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4250
4251 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004252 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004253 */
4254 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4255 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4256
4257 /* Mute all inputs to mixer widget (even unconnected ones) */
4258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4266
4267 { }
4268};
4269#endif
4270
Linus Torvalds1da177e2005-04-16 15:20:36 -07004271static struct hda_pcm_stream alc260_pcm_analog_playback = {
4272 .substreams = 1,
4273 .channels_min = 2,
4274 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004275};
4276
4277static struct hda_pcm_stream alc260_pcm_analog_capture = {
4278 .substreams = 1,
4279 .channels_min = 2,
4280 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004281};
4282
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004283#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4284#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4285
Kailang Yangdf694da2005-12-05 19:42:22 +01004286/*
4287 * for BIOS auto-configuration
4288 */
4289
4290static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4291 const char *pfx)
4292{
4293 hda_nid_t nid_vol;
4294 unsigned long vol_val, sw_val;
4295 char name[32];
4296 int err;
4297
4298 if (nid >= 0x0f && nid < 0x11) {
4299 nid_vol = nid - 0x7;
4300 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4301 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4302 } else if (nid == 0x11) {
4303 nid_vol = nid - 0x7;
4304 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4305 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4306 } else if (nid >= 0x12 && nid <= 0x15) {
4307 nid_vol = 0x08;
4308 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4309 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4310 } else
4311 return 0; /* N/A */
4312
4313 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004314 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4315 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004316 return err;
4317 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004318 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4319 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004320 return err;
4321 return 1;
4322}
4323
4324/* add playback controls from the parsed DAC table */
4325static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4326 const struct auto_pin_cfg *cfg)
4327{
4328 hda_nid_t nid;
4329 int err;
4330
4331 spec->multiout.num_dacs = 1;
4332 spec->multiout.dac_nids = spec->private_dac_nids;
4333 spec->multiout.dac_nids[0] = 0x02;
4334
4335 nid = cfg->line_out_pins[0];
4336 if (nid) {
4337 err = alc260_add_playback_controls(spec, nid, "Front");
4338 if (err < 0)
4339 return err;
4340 }
4341
Takashi Iwai82bc9552006-03-21 11:24:42 +01004342 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004343 if (nid) {
4344 err = alc260_add_playback_controls(spec, nid, "Speaker");
4345 if (err < 0)
4346 return err;
4347 }
4348
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004349 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004350 if (nid) {
4351 err = alc260_add_playback_controls(spec, nid, "Headphone");
4352 if (err < 0)
4353 return err;
4354 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004355 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004356}
4357
4358/* create playback/capture controls for input pins */
4359static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4360 const struct auto_pin_cfg *cfg)
4361{
Kailang Yangdf694da2005-12-05 19:42:22 +01004362 struct hda_input_mux *imux = &spec->private_imux;
4363 int i, err, idx;
4364
4365 for (i = 0; i < AUTO_PIN_LAST; i++) {
4366 if (cfg->input_pins[i] >= 0x12) {
4367 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004368 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004369 auto_pin_cfg_labels[i], idx,
4370 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004371 if (err < 0)
4372 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004373 imux->items[imux->num_items].label =
4374 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004375 imux->items[imux->num_items].index = idx;
4376 imux->num_items++;
4377 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004378 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004379 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004380 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004381 auto_pin_cfg_labels[i], idx,
4382 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004383 if (err < 0)
4384 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004385 imux->items[imux->num_items].label =
4386 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004387 imux->items[imux->num_items].index = idx;
4388 imux->num_items++;
4389 }
4390 }
4391 return 0;
4392}
4393
4394static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4395 hda_nid_t nid, int pin_type,
4396 int sel_idx)
4397{
4398 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004399 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4400 pin_type);
4401 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4402 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004403 /* need the manual connection? */
4404 if (nid >= 0x12) {
4405 int idx = nid - 0x12;
4406 snd_hda_codec_write(codec, idx + 0x0b, 0,
4407 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004408 }
4409}
4410
4411static void alc260_auto_init_multi_out(struct hda_codec *codec)
4412{
4413 struct alc_spec *spec = codec->spec;
4414 hda_nid_t nid;
4415
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004416 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004417 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004418 if (nid) {
4419 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4420 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4421 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004422
Takashi Iwai82bc9552006-03-21 11:24:42 +01004423 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004424 if (nid)
4425 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4426
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004427 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004428 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004429 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004430}
Kailang Yangdf694da2005-12-05 19:42:22 +01004431
4432#define ALC260_PIN_CD_NID 0x16
4433static void alc260_auto_init_analog_input(struct hda_codec *codec)
4434{
4435 struct alc_spec *spec = codec->spec;
4436 int i;
4437
4438 for (i = 0; i < AUTO_PIN_LAST; i++) {
4439 hda_nid_t nid = spec->autocfg.input_pins[i];
4440 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004441 snd_hda_codec_write(codec, nid, 0,
4442 AC_VERB_SET_PIN_WIDGET_CONTROL,
4443 i <= AUTO_PIN_FRONT_MIC ?
4444 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004445 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004446 snd_hda_codec_write(codec, nid, 0,
4447 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004448 AMP_OUT_MUTE);
4449 }
4450 }
4451}
4452
4453/*
4454 * generic initialization of ADC, input mixers and output mixers
4455 */
4456static struct hda_verb alc260_volume_init_verbs[] = {
4457 /*
4458 * Unmute ADC0-1 and set the default input to mic-in
4459 */
4460 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4461 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4462 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4463 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4464
4465 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4466 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004467 * Note: PASD motherboards uses the Line In 2 as the input for
4468 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004469 */
4470 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4472 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4476
4477 /*
4478 * Set up output mixers (0x08 - 0x0a)
4479 */
4480 /* set vol=0 to output mixers */
4481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4482 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4483 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4484 /* set up input amps for analog loopback */
4485 /* Amp Indices: DAC = 0, mixer = 1 */
4486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4492
4493 { }
4494};
4495
4496static int alc260_parse_auto_config(struct hda_codec *codec)
4497{
4498 struct alc_spec *spec = codec->spec;
4499 unsigned int wcap;
4500 int err;
4501 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4502
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004503 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4504 alc260_ignore);
4505 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004506 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004507 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4508 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004509 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004510 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004511 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004512 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4513 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004514 return err;
4515
4516 spec->multiout.max_channels = 2;
4517
4518 if (spec->autocfg.dig_out_pin)
4519 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4520 if (spec->kctl_alloc)
4521 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4522
4523 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4524
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004525 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004526 spec->input_mux = &spec->private_imux;
4527
4528 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004529 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004530 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4531 if (wcap != AC_WID_AUD_IN) {
4532 spec->adc_nids = alc260_adc_nids_alt;
4533 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4534 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004535 } else {
4536 spec->adc_nids = alc260_adc_nids;
4537 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4538 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004539 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004540 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004541
4542 return 1;
4543}
4544
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004545/* additional initialization for auto-configuration model */
4546static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004547{
Kailang Yangdf694da2005-12-05 19:42:22 +01004548 alc260_auto_init_multi_out(codec);
4549 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004550}
4551
4552/*
4553 * ALC260 configurations
4554 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004555static const char *alc260_models[ALC260_MODEL_LAST] = {
4556 [ALC260_BASIC] = "basic",
4557 [ALC260_HP] = "hp",
4558 [ALC260_HP_3013] = "hp-3013",
4559 [ALC260_FUJITSU_S702X] = "fujitsu",
4560 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004561 [ALC260_WILL] = "will",
4562 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004563#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004564 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004565#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004566 [ALC260_AUTO] = "auto",
4567};
4568
4569static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004570 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004571 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004572 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004573 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004574 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4575 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4576 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4577 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4578 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4579 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4580 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4581 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4582 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4583 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4584 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4585 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004586 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4587 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004588 {}
4589};
4590
Kailang Yangdf694da2005-12-05 19:42:22 +01004591static struct alc_config_preset alc260_presets[] = {
4592 [ALC260_BASIC] = {
4593 .mixers = { alc260_base_output_mixer,
4594 alc260_input_mixer,
4595 alc260_pc_beep_mixer,
4596 alc260_capture_mixer },
4597 .init_verbs = { alc260_init_verbs },
4598 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4599 .dac_nids = alc260_dac_nids,
4600 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4601 .adc_nids = alc260_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] = {
4607 .mixers = { alc260_base_output_mixer,
4608 alc260_input_mixer,
4609 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004610 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004611 .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_HP_3013] = {
4620 .mixers = { alc260_hp_3013_mixer,
4621 alc260_input_mixer,
4622 alc260_capture_alt_mixer },
4623 .init_verbs = { alc260_hp_3013_init_verbs },
4624 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4625 .dac_nids = alc260_dac_nids,
4626 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4627 .adc_nids = alc260_hp_adc_nids,
4628 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4629 .channel_mode = alc260_modes,
4630 .input_mux = &alc260_capture_source,
4631 },
4632 [ALC260_FUJITSU_S702X] = {
4633 .mixers = { alc260_fujitsu_mixer,
4634 alc260_capture_mixer },
4635 .init_verbs = { alc260_fujitsu_init_verbs },
4636 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4637 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004638 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4639 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004640 .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_fujitsu_capture_sources),
4643 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004644 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004645 [ALC260_ACER] = {
4646 .mixers = { alc260_acer_mixer,
4647 alc260_capture_mixer },
4648 .init_verbs = { alc260_acer_init_verbs },
4649 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4650 .dac_nids = alc260_dac_nids,
4651 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4652 .adc_nids = alc260_dual_adc_nids,
4653 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4654 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004655 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4656 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004657 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004658 [ALC260_WILL] = {
4659 .mixers = { alc260_will_mixer,
4660 alc260_capture_mixer },
4661 .init_verbs = { alc260_init_verbs, alc260_will_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 },
4671 [ALC260_REPLACER_672V] = {
4672 .mixers = { alc260_replacer_672v_mixer,
4673 alc260_capture_mixer },
4674 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4675 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4676 .dac_nids = alc260_dac_nids,
4677 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4678 .adc_nids = alc260_adc_nids,
4679 .dig_out_nid = ALC260_DIGOUT_NID,
4680 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4681 .channel_mode = alc260_modes,
4682 .input_mux = &alc260_capture_source,
4683 .unsol_event = alc260_replacer_672v_unsol_event,
4684 .init_hook = alc260_replacer_672v_automute,
4685 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004686#ifdef CONFIG_SND_DEBUG
4687 [ALC260_TEST] = {
4688 .mixers = { alc260_test_mixer,
4689 alc260_capture_mixer },
4690 .init_verbs = { alc260_test_init_verbs },
4691 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4692 .dac_nids = alc260_test_dac_nids,
4693 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4694 .adc_nids = alc260_test_adc_nids,
4695 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4696 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004697 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4698 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004699 },
4700#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004701};
4702
Linus Torvalds1da177e2005-04-16 15:20:36 -07004703static int patch_alc260(struct hda_codec *codec)
4704{
4705 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004706 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004707
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004708 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004709 if (spec == NULL)
4710 return -ENOMEM;
4711
4712 codec->spec = spec;
4713
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004714 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4715 alc260_models,
4716 alc260_cfg_tbl);
4717 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004718 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4719 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004720 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004721 }
4722
Kailang Yangdf694da2005-12-05 19:42:22 +01004723 if (board_config == ALC260_AUTO) {
4724 /* automatic parse from the BIOS config */
4725 err = alc260_parse_auto_config(codec);
4726 if (err < 0) {
4727 alc_free(codec);
4728 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004729 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004730 printk(KERN_INFO
4731 "hda_codec: Cannot set up configuration "
4732 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004733 board_config = ALC260_BASIC;
4734 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004735 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004736
Kailang Yangdf694da2005-12-05 19:42:22 +01004737 if (board_config != ALC260_AUTO)
4738 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004739
4740 spec->stream_name_analog = "ALC260 Analog";
4741 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4742 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4743
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004744 spec->stream_name_digital = "ALC260 Digital";
4745 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4746 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4747
Linus Torvalds1da177e2005-04-16 15:20:36 -07004748 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004749 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004750 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004751
4752 return 0;
4753}
4754
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004755
Linus Torvalds1da177e2005-04-16 15:20:36 -07004756/*
4757 * ALC882 support
4758 *
4759 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4760 * configuration. Each pin widget can choose any input DACs and a mixer.
4761 * Each ADC is connected from a mixer of all inputs. This makes possible
4762 * 6-channel independent captures.
4763 *
4764 * In addition, an independent DAC for the multi-playback (not used in this
4765 * driver yet).
4766 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004767#define ALC882_DIGOUT_NID 0x06
4768#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004769
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004770static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771 { 8, NULL }
4772};
4773
4774static hda_nid_t alc882_dac_nids[4] = {
4775 /* front, rear, clfe, rear_surr */
4776 0x02, 0x03, 0x04, 0x05
4777};
4778
Kailang Yangdf694da2005-12-05 19:42:22 +01004779/* identical with ALC880 */
4780#define alc882_adc_nids alc880_adc_nids
4781#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004782
4783/* input MUX */
4784/* FIXME: should be a matrix-type input source selection */
4785
4786static struct hda_input_mux alc882_capture_source = {
4787 .num_items = 4,
4788 .items = {
4789 { "Mic", 0x0 },
4790 { "Front Mic", 0x1 },
4791 { "Line", 0x2 },
4792 { "CD", 0x4 },
4793 },
4794};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004795#define alc882_mux_enum_info alc_mux_enum_info
4796#define alc882_mux_enum_get alc_mux_enum_get
4797
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004798static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4799 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004800{
4801 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4802 struct alc_spec *spec = codec->spec;
4803 const struct hda_input_mux *imux = spec->input_mux;
4804 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4805 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4806 hda_nid_t nid = capture_mixers[adc_idx];
4807 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4808 unsigned int i, idx;
4809
4810 idx = ucontrol->value.enumerated.item[0];
4811 if (idx >= imux->num_items)
4812 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004813 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004814 return 0;
4815 for (i = 0; i < imux->num_items; i++) {
4816 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4817 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4818 v | (imux->items[i].index << 8));
4819 }
4820 *cur_val = idx;
4821 return 1;
4822}
4823
Kailang Yangdf694da2005-12-05 19:42:22 +01004824/*
Kailang Yang272a5272007-05-14 11:00:38 +02004825 * 2ch mode
4826 */
4827static struct hda_verb alc882_3ST_ch2_init[] = {
4828 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4829 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4830 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4831 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4832 { } /* end */
4833};
4834
4835/*
4836 * 6ch mode
4837 */
4838static struct hda_verb alc882_3ST_ch6_init[] = {
4839 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4840 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4841 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4842 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4843 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4844 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4845 { } /* end */
4846};
4847
4848static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4849 { 2, alc882_3ST_ch2_init },
4850 { 6, alc882_3ST_ch6_init },
4851};
4852
4853/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004854 * 6ch mode
4855 */
4856static struct hda_verb alc882_sixstack_ch6_init[] = {
4857 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4858 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4859 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4860 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4861 { } /* end */
4862};
4863
4864/*
4865 * 8ch mode
4866 */
4867static struct hda_verb alc882_sixstack_ch8_init[] = {
4868 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4869 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4870 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4871 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4872 { } /* end */
4873};
4874
4875static struct hda_channel_mode alc882_sixstack_modes[2] = {
4876 { 6, alc882_sixstack_ch6_init },
4877 { 8, alc882_sixstack_ch8_init },
4878};
4879
Linus Torvalds1da177e2005-04-16 15:20:36 -07004880/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4881 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4882 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004883static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004884 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004885 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004886 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004887 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004888 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4889 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004890 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4891 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004892 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004893 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004894 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4895 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4896 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4897 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4898 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004900 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4902 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004903 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004904 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4905 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4906 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004907 { } /* end */
4908};
4909
Kailang Yangbdd148a2007-05-08 15:19:08 +02004910static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4912 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4921 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4922 { } /* end */
4923};
4924
Kailang Yang272a5272007-05-14 11:00:38 +02004925static struct snd_kcontrol_new alc882_targa_mixer[] = {
4926 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4927 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4929 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4930 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4935 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4936 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4937 { } /* end */
4938};
4939
4940/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4941 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4942 */
4943static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4945 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4948 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4949 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4950 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4951 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4952 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4953 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4956 { } /* end */
4957};
4958
Kailang Yangdf694da2005-12-05 19:42:22 +01004959static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4960 {
4961 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4962 .name = "Channel Mode",
4963 .info = alc_ch_mode_info,
4964 .get = alc_ch_mode_get,
4965 .put = alc_ch_mode_put,
4966 },
4967 { } /* end */
4968};
4969
Linus Torvalds1da177e2005-04-16 15:20:36 -07004970static struct hda_verb alc882_init_verbs[] = {
4971 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4973 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4974 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004975 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004976 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4977 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4978 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004979 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004980 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4981 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004983 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004984 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4985 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4986 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004987
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004990 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004991 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004992 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004993 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004994 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004995 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004997 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004998 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004999 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005001 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005002 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005003 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005005 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005006 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5007 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005008 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005009 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5010 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005011 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005012 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5013 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5015 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5016 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005017 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005018 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005019
5020 /* FIXME: use matrix-type input source selection */
5021 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5022 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005023 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5024 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005027 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005028 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5029 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005032 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5037 /* ADC1: mute amp left and right */
5038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005039 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005040 /* ADC2: mute amp left and right */
5041 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005042 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005043 /* ADC3: mute amp left and right */
5044 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005045 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005046
5047 { }
5048};
5049
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005050static struct hda_verb alc882_eapd_verbs[] = {
5051 /* change to EAPD mode */
5052 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005053 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005054 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005055};
5056
Tobin Davis9102cd12006-12-15 10:02:12 +01005057/* Mac Pro test */
5058static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5059 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5060 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5062 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5063 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5064 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5065 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5066 { } /* end */
5067};
5068
5069static struct hda_verb alc882_macpro_init_verbs[] = {
5070 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5074 /* Front Pin: output 0 (0x0c) */
5075 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5076 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5077 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5078 /* Front Mic pin: input vref at 80% */
5079 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5081 /* Speaker: output */
5082 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5083 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5084 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5085 /* Headphone output (output 0 - 0x0c) */
5086 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5087 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5088 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5089
5090 /* FIXME: use matrix-type input source selection */
5091 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5092 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5093 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5097 /* Input mixer2 */
5098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5102 /* Input mixer3 */
5103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5107 /* ADC1: mute amp left and right */
5108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5109 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5110 /* ADC2: mute amp left and right */
5111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5112 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5113 /* ADC3: mute amp left and right */
5114 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5115 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5116
5117 { }
5118};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119
Kailang Yang272a5272007-05-14 11:00:38 +02005120static struct hda_verb alc882_targa_verbs[] = {
5121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5122 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5123
5124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5125 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5126
5127 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5128 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5129 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5130
5131 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5132 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5133 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5134 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5135 { } /* end */
5136};
5137
5138/* toggle speaker-output according to the hp-jack state */
5139static void alc882_targa_automute(struct hda_codec *codec)
5140{
5141 unsigned int present;
5142
5143 present = snd_hda_codec_read(codec, 0x14, 0,
5144 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5145 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5146 0x80, present ? 0x80 : 0);
5147 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5148 0x80, present ? 0x80 : 0);
5149 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5150}
5151
5152static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5153{
5154 /* Looks like the unsol event is incompatible with the standard
5155 * definition. 4bit tag is placed at 26 bit!
5156 */
5157 if (((res >> 26) == ALC880_HP_EVENT)) {
5158 alc882_targa_automute(codec);
5159 }
5160}
5161
5162static struct hda_verb alc882_asus_a7j_verbs[] = {
5163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5165
5166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5168 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5169
5170 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5171 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5172 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5173
5174 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5175 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5176 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5177 { } /* end */
5178};
5179
Tobin Davis9102cd12006-12-15 10:02:12 +01005180static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5181{
5182 unsigned int gpiostate, gpiomask, gpiodir;
5183
5184 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5185 AC_VERB_GET_GPIO_DATA, 0);
5186
5187 if (!muted)
5188 gpiostate |= (1 << pin);
5189 else
5190 gpiostate &= ~(1 << pin);
5191
5192 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5193 AC_VERB_GET_GPIO_MASK, 0);
5194 gpiomask |= (1 << pin);
5195
5196 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5197 AC_VERB_GET_GPIO_DIRECTION, 0);
5198 gpiodir |= (1 << pin);
5199
5200
5201 snd_hda_codec_write(codec, codec->afg, 0,
5202 AC_VERB_SET_GPIO_MASK, gpiomask);
5203 snd_hda_codec_write(codec, codec->afg, 0,
5204 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5205
5206 msleep(1);
5207
5208 snd_hda_codec_write(codec, codec->afg, 0,
5209 AC_VERB_SET_GPIO_DATA, gpiostate);
5210}
5211
Kailang Yangdf694da2005-12-05 19:42:22 +01005212/*
5213 * generic initialization of ADC, input mixers and output mixers
5214 */
5215static struct hda_verb alc882_auto_init_verbs[] = {
5216 /*
5217 * Unmute ADC0-2 and set the default input to mic-in
5218 */
5219 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5221 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5223 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5225
5226 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5227 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005228 * Note: PASD motherboards uses the Line In 2 as the input for
5229 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005230 */
5231 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5237
5238 /*
5239 * Set up output mixers (0x0c - 0x0f)
5240 */
5241 /* set vol=0 to output mixers */
5242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5245 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5246 /* set up input amps for analog loopback */
5247 /* Amp Indices: DAC = 0, mixer = 1 */
5248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5255 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5256 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5257 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5258
5259 /* FIXME: use matrix-type input source selection */
5260 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5261 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5262 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5263 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5264 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5265 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5266 /* Input mixer2 */
5267 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5271 /* Input mixer3 */
5272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5274 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5275 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5276
5277 { }
5278};
5279
5280/* capture mixer elements */
5281static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5282 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5283 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5284 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5285 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5286 {
5287 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5288 /* The multiple "Capture Source" controls confuse alsamixer
5289 * So call somewhat different..
5290 * FIXME: the controls appear in the "playback" view!
5291 */
5292 /* .name = "Capture Source", */
5293 .name = "Input Source",
5294 .count = 2,
5295 .info = alc882_mux_enum_info,
5296 .get = alc882_mux_enum_get,
5297 .put = alc882_mux_enum_put,
5298 },
5299 { } /* end */
5300};
5301
5302static struct snd_kcontrol_new alc882_capture_mixer[] = {
5303 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5304 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5305 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5306 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5307 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5308 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5309 {
5310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5311 /* The multiple "Capture Source" controls confuse alsamixer
5312 * So call somewhat different..
5313 * FIXME: the controls appear in the "playback" view!
5314 */
5315 /* .name = "Capture Source", */
5316 .name = "Input Source",
5317 .count = 3,
5318 .info = alc882_mux_enum_info,
5319 .get = alc882_mux_enum_get,
5320 .put = alc882_mux_enum_put,
5321 },
5322 { } /* end */
5323};
5324
5325/* pcm configuration: identiacal with ALC880 */
5326#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5327#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5328#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5329#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5330
5331/*
5332 * configuration and preset
5333 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005334static const char *alc882_models[ALC882_MODEL_LAST] = {
5335 [ALC882_3ST_DIG] = "3stack-dig",
5336 [ALC882_6ST_DIG] = "6stack-dig",
5337 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005338 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005339 [ALC885_MACPRO] = "macpro",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005340 [ALC882_AUTO] = "auto",
5341};
5342
5343static struct snd_pci_quirk alc882_cfg_tbl[] = {
5344 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5345 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5346 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005347 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005348 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005349 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005350 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005351 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005352 {}
5353};
5354
5355static struct alc_config_preset alc882_presets[] = {
5356 [ALC882_3ST_DIG] = {
5357 .mixers = { alc882_base_mixer },
5358 .init_verbs = { alc882_init_verbs },
5359 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5360 .dac_nids = alc882_dac_nids,
5361 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005362 .dig_in_nid = ALC882_DIGIN_NID,
5363 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5364 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005365 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005366 .input_mux = &alc882_capture_source,
5367 },
5368 [ALC882_6ST_DIG] = {
5369 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5370 .init_verbs = { alc882_init_verbs },
5371 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5372 .dac_nids = alc882_dac_nids,
5373 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005374 .dig_in_nid = ALC882_DIGIN_NID,
5375 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5376 .channel_mode = alc882_sixstack_modes,
5377 .input_mux = &alc882_capture_source,
5378 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005379 [ALC882_ARIMA] = {
5380 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5381 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5382 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5383 .dac_nids = alc882_dac_nids,
5384 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5385 .channel_mode = alc882_sixstack_modes,
5386 .input_mux = &alc882_capture_source,
5387 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005388 [ALC882_W2JC] = {
5389 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5390 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5391 alc880_gpio1_init_verbs },
5392 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5393 .dac_nids = alc882_dac_nids,
5394 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5395 .channel_mode = alc880_threestack_modes,
5396 .need_dac_fix = 1,
5397 .input_mux = &alc882_capture_source,
5398 .dig_out_nid = ALC882_DIGOUT_NID,
5399 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005400 [ALC885_MACPRO] = {
5401 .mixers = { alc882_macpro_mixer },
5402 .init_verbs = { alc882_macpro_init_verbs },
5403 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5404 .dac_nids = alc882_dac_nids,
5405 .dig_out_nid = ALC882_DIGOUT_NID,
5406 .dig_in_nid = ALC882_DIGIN_NID,
5407 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5408 .channel_mode = alc882_ch_modes,
5409 .input_mux = &alc882_capture_source,
5410 },
Kailang Yang272a5272007-05-14 11:00:38 +02005411 [ALC882_TARGA] = {
5412 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5413 alc882_capture_mixer },
5414 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5415 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5416 .dac_nids = alc882_dac_nids,
5417 .dig_out_nid = ALC882_DIGOUT_NID,
5418 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5419 .adc_nids = alc882_adc_nids,
5420 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5421 .channel_mode = alc882_3ST_6ch_modes,
5422 .need_dac_fix = 1,
5423 .input_mux = &alc882_capture_source,
5424 .unsol_event = alc882_targa_unsol_event,
5425 .init_hook = alc882_targa_automute,
5426 },
5427 [ALC882_ASUS_A7J] = {
5428 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5429 alc882_capture_mixer },
5430 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5431 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5432 .dac_nids = alc882_dac_nids,
5433 .dig_out_nid = ALC882_DIGOUT_NID,
5434 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5435 .adc_nids = alc882_adc_nids,
5436 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5437 .channel_mode = alc882_3ST_6ch_modes,
5438 .need_dac_fix = 1,
5439 .input_mux = &alc882_capture_source,
5440 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005441};
5442
5443
5444/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005445 * Pin config fixes
5446 */
5447enum {
5448 PINFIX_ABIT_AW9D_MAX
5449};
5450
5451static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5452 { 0x15, 0x01080104 }, /* side */
5453 { 0x16, 0x01011012 }, /* rear */
5454 { 0x17, 0x01016011 }, /* clfe */
5455 { }
5456};
5457
5458static const struct alc_pincfg *alc882_pin_fixes[] = {
5459 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5460};
5461
5462static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5463 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5464 {}
5465};
5466
5467/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005468 * BIOS auto configuration
5469 */
5470static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5471 hda_nid_t nid, int pin_type,
5472 int dac_idx)
5473{
5474 /* set as output */
5475 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005476 int idx;
5477
Kailang Yangdf694da2005-12-05 19:42:22 +01005478 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5479 idx = 4;
5480 else
5481 idx = spec->multiout.dac_nids[dac_idx] - 2;
5482
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005483 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5484 pin_type);
5485 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5486 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005487 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5488
5489}
5490
5491static void alc882_auto_init_multi_out(struct hda_codec *codec)
5492{
5493 struct alc_spec *spec = codec->spec;
5494 int i;
5495
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005496 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005497 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005498 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005499 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005500 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005501 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005502 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005503 }
5504}
5505
5506static void alc882_auto_init_hp_out(struct hda_codec *codec)
5507{
5508 struct alc_spec *spec = codec->spec;
5509 hda_nid_t pin;
5510
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005511 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005512 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005513 /* use dac 0 */
5514 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005515}
5516
5517#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5518#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5519
5520static void alc882_auto_init_analog_input(struct hda_codec *codec)
5521{
5522 struct alc_spec *spec = codec->spec;
5523 int i;
5524
5525 for (i = 0; i < AUTO_PIN_LAST; i++) {
5526 hda_nid_t nid = spec->autocfg.input_pins[i];
5527 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005528 snd_hda_codec_write(codec, nid, 0,
5529 AC_VERB_SET_PIN_WIDGET_CONTROL,
5530 i <= AUTO_PIN_FRONT_MIC ?
5531 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005532 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005533 snd_hda_codec_write(codec, nid, 0,
5534 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005535 AMP_OUT_MUTE);
5536 }
5537 }
5538}
5539
5540/* almost identical with ALC880 parser... */
5541static int alc882_parse_auto_config(struct hda_codec *codec)
5542{
5543 struct alc_spec *spec = codec->spec;
5544 int err = alc880_parse_auto_config(codec);
5545
5546 if (err < 0)
5547 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005548 else if (err > 0)
5549 /* hack - override the init verbs */
5550 spec->init_verbs[0] = alc882_auto_init_verbs;
5551 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005552}
5553
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005554/* additional initialization for auto-configuration model */
5555static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005556{
Kailang Yangdf694da2005-12-05 19:42:22 +01005557 alc882_auto_init_multi_out(codec);
5558 alc882_auto_init_hp_out(codec);
5559 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005560}
5561
Linus Torvalds1da177e2005-04-16 15:20:36 -07005562static int patch_alc882(struct hda_codec *codec)
5563{
5564 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005565 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005566
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005567 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005568 if (spec == NULL)
5569 return -ENOMEM;
5570
Linus Torvalds1da177e2005-04-16 15:20:36 -07005571 codec->spec = spec;
5572
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005573 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5574 alc882_models,
5575 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005576
Kailang Yangdf694da2005-12-05 19:42:22 +01005577 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005578 /* Pick up systems that don't supply PCI SSID */
5579 switch (codec->subsystem_id) {
5580 case 0x106b0c00: /* Mac Pro */
5581 board_config = ALC885_MACPRO;
5582 break;
5583 default:
5584 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5585 "trying auto-probe from BIOS...\n");
5586 board_config = ALC882_AUTO;
5587 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005588 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005589
Takashi Iwaif95474e2007-07-10 00:47:43 +02005590 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5591
Kailang Yangdf694da2005-12-05 19:42:22 +01005592 if (board_config == ALC882_AUTO) {
5593 /* automatic parse from the BIOS config */
5594 err = alc882_parse_auto_config(codec);
5595 if (err < 0) {
5596 alc_free(codec);
5597 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005598 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005599 printk(KERN_INFO
5600 "hda_codec: Cannot set up configuration "
5601 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005602 board_config = ALC882_3ST_DIG;
5603 }
5604 }
5605
5606 if (board_config != ALC882_AUTO)
5607 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005608
Tobin Davis9102cd12006-12-15 10:02:12 +01005609 if (board_config == ALC885_MACPRO) {
5610 alc882_gpio_mute(codec, 0, 0);
5611 alc882_gpio_mute(codec, 1, 0);
5612 }
5613
Linus Torvalds1da177e2005-04-16 15:20:36 -07005614 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005615 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5616 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005617
5618 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005619 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5620 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005621
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005622 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005623 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005624 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005625 /* get type */
5626 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005627 if (wcap != AC_WID_AUD_IN) {
5628 spec->adc_nids = alc882_adc_nids_alt;
5629 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005630 spec->mixers[spec->num_mixers] =
5631 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005632 spec->num_mixers++;
5633 } else {
5634 spec->adc_nids = alc882_adc_nids;
5635 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5636 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5637 spec->num_mixers++;
5638 }
5639 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005640
5641 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005642 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005643 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005644
5645 return 0;
5646}
5647
5648/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005649 * ALC883 support
5650 *
5651 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5652 * configuration. Each pin widget can choose any input DACs and a mixer.
5653 * Each ADC is connected from a mixer of all inputs. This makes possible
5654 * 6-channel independent captures.
5655 *
5656 * In addition, an independent DAC for the multi-playback (not used in this
5657 * driver yet).
5658 */
5659#define ALC883_DIGOUT_NID 0x06
5660#define ALC883_DIGIN_NID 0x0a
5661
5662static hda_nid_t alc883_dac_nids[4] = {
5663 /* front, rear, clfe, rear_surr */
5664 0x02, 0x04, 0x03, 0x05
5665};
5666
5667static hda_nid_t alc883_adc_nids[2] = {
5668 /* ADC1-2 */
5669 0x08, 0x09,
5670};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005671
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005672/* input MUX */
5673/* FIXME: should be a matrix-type input source selection */
5674
5675static struct hda_input_mux alc883_capture_source = {
5676 .num_items = 4,
5677 .items = {
5678 { "Mic", 0x0 },
5679 { "Front Mic", 0x1 },
5680 { "Line", 0x2 },
5681 { "CD", 0x4 },
5682 },
5683};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005684
5685static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5686 .num_items = 2,
5687 .items = {
5688 { "Mic", 0x1 },
5689 { "Line", 0x2 },
5690 },
5691};
5692
Kailang Yang272a5272007-05-14 11:00:38 +02005693static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5694 .num_items = 4,
5695 .items = {
5696 { "Mic", 0x0 },
5697 { "iMic", 0x1 },
5698 { "Line", 0x2 },
5699 { "CD", 0x4 },
5700 },
5701};
5702
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005703#define alc883_mux_enum_info alc_mux_enum_info
5704#define alc883_mux_enum_get alc_mux_enum_get
5705
5706static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5707 struct snd_ctl_elem_value *ucontrol)
5708{
5709 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5710 struct alc_spec *spec = codec->spec;
5711 const struct hda_input_mux *imux = spec->input_mux;
5712 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5713 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5714 hda_nid_t nid = capture_mixers[adc_idx];
5715 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5716 unsigned int i, idx;
5717
5718 idx = ucontrol->value.enumerated.item[0];
5719 if (idx >= imux->num_items)
5720 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005721 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005722 return 0;
5723 for (i = 0; i < imux->num_items; i++) {
5724 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5725 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5726 v | (imux->items[i].index << 8));
5727 }
5728 *cur_val = idx;
5729 return 1;
5730}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005731
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005732/*
5733 * 2ch mode
5734 */
5735static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5736 { 2, NULL }
5737};
5738
5739/*
5740 * 2ch mode
5741 */
5742static struct hda_verb alc883_3ST_ch2_init[] = {
5743 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5744 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5745 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5746 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5747 { } /* end */
5748};
5749
5750/*
5751 * 6ch mode
5752 */
5753static struct hda_verb alc883_3ST_ch6_init[] = {
5754 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5755 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5756 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5757 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5758 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5759 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5760 { } /* end */
5761};
5762
5763static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5764 { 2, alc883_3ST_ch2_init },
5765 { 6, alc883_3ST_ch6_init },
5766};
5767
5768/*
5769 * 6ch mode
5770 */
5771static struct hda_verb alc883_sixstack_ch6_init[] = {
5772 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5773 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5774 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5775 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5776 { } /* end */
5777};
5778
5779/*
5780 * 8ch mode
5781 */
5782static struct hda_verb alc883_sixstack_ch8_init[] = {
5783 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5784 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5785 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5786 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5787 { } /* end */
5788};
5789
5790static struct hda_channel_mode alc883_sixstack_modes[2] = {
5791 { 6, alc883_sixstack_ch6_init },
5792 { 8, alc883_sixstack_ch8_init },
5793};
5794
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005795static struct hda_verb alc883_medion_eapd_verbs[] = {
5796 /* eanable EAPD on medion laptop */
5797 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5798 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5799 { }
5800};
5801
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005802/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5803 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5804 */
5805
5806static struct snd_kcontrol_new alc883_base_mixer[] = {
5807 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5809 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5810 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5811 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5812 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5813 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5814 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5815 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5816 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5818 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5819 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5820 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5821 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005823 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5825 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005826 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5828 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5829 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5830 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5831 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5832 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5833 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5834 {
5835 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5836 /* .name = "Capture Source", */
5837 .name = "Input Source",
5838 .count = 2,
5839 .info = alc883_mux_enum_info,
5840 .get = alc883_mux_enum_get,
5841 .put = alc883_mux_enum_put,
5842 },
5843 { } /* end */
5844};
5845
5846static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5847 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5848 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5849 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5850 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5851 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5852 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5853 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5854 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005856 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5857 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005858 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005859 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5860 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5861 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5862 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5863 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5864 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5865 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5866 {
5867 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5868 /* .name = "Capture Source", */
5869 .name = "Input Source",
5870 .count = 2,
5871 .info = alc883_mux_enum_info,
5872 .get = alc883_mux_enum_get,
5873 .put = alc883_mux_enum_put,
5874 },
5875 { } /* end */
5876};
5877
5878static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5882 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5885 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5886 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5887 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005894 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5895 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005896 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005897 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5898 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5899 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5900 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5901 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5902 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5903 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5904 {
5905 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5906 /* .name = "Capture Source", */
5907 .name = "Input Source",
5908 .count = 2,
5909 .info = alc883_mux_enum_info,
5910 .get = alc883_mux_enum_get,
5911 .put = alc883_mux_enum_put,
5912 },
5913 { } /* end */
5914};
5915
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005916static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005917 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5918 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5919 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5920 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5921 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5922 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5923 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5924 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5927 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005931 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005932 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5933 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005934 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5936 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5937 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5938 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5939 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5940
5941 {
5942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5943 /* .name = "Capture Source", */
5944 .name = "Input Source",
5945 .count = 1,
5946 .info = alc883_mux_enum_info,
5947 .get = alc883_mux_enum_get,
5948 .put = alc883_mux_enum_put,
5949 },
5950 { } /* end */
5951};
5952
Kailang Yangccc656c2006-10-17 12:32:26 +02005953static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5954 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5955 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5956 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5957 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5958 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5959 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5960 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5961 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5962 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5963 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5964 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5965 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5966 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005968 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005969 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5970 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5971 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5972 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5973 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5974 {
5975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5976 /* .name = "Capture Source", */
5977 .name = "Input Source",
5978 .count = 2,
5979 .info = alc883_mux_enum_info,
5980 .get = alc883_mux_enum_get,
5981 .put = alc883_mux_enum_put,
5982 },
5983 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005984};
Kailang Yangccc656c2006-10-17 12:32:26 +02005985
5986static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5987 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5989 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5990 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5991 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5995 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5996 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5997 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5998 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5999 {
6000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6001 /* .name = "Capture Source", */
6002 .name = "Input Source",
6003 .count = 2,
6004 .info = alc883_mux_enum_info,
6005 .get = alc883_mux_enum_get,
6006 .put = alc883_mux_enum_put,
6007 },
6008 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006009};
Kailang Yangccc656c2006-10-17 12:32:26 +02006010
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006011static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6013 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6014 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6015 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6018 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6020 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6021 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6022 {
6023 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6024 /* .name = "Capture Source", */
6025 .name = "Input Source",
6026 .count = 1,
6027 .info = alc883_mux_enum_info,
6028 .get = alc883_mux_enum_get,
6029 .put = alc883_mux_enum_put,
6030 },
6031 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006032};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006033
Kailang Yang272a5272007-05-14 11:00:38 +02006034static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6035 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6036 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6037 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6038 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6039 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6040 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6041 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6042 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6043 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6044 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6045 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6046 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6047 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6048 {
6049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6050 /* .name = "Capture Source", */
6051 .name = "Input Source",
6052 .count = 2,
6053 .info = alc883_mux_enum_info,
6054 .get = alc883_mux_enum_get,
6055 .put = alc883_mux_enum_put,
6056 },
6057 { } /* end */
6058};
6059
6060static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6063 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6065 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6067 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6070 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6071 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6072 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6073 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6074 {
6075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6076 /* .name = "Capture Source", */
6077 .name = "Input Source",
6078 .count = 2,
6079 .info = alc883_mux_enum_info,
6080 .get = alc883_mux_enum_get,
6081 .put = alc883_mux_enum_put,
6082 },
6083 { } /* end */
6084};
6085
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006086static struct snd_kcontrol_new alc888_hp_nettle_mixer[] = {
6087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6088 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6090 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6093 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6094 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6095 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6096 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6097 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6098 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6099 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6100 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6101 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6103 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6104 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6105 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6106 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6107 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6108 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6109 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6110 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6111 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6112 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6113 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6114 {
6115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6116 /* .name = "Capture Source", */
6117 .name = "Input Source",
6118 .count = 2,
6119 .info = alc883_mux_enum_info,
6120 .get = alc883_mux_enum_get,
6121 .put = alc883_mux_enum_put,
6122 },
6123 { } /* end */
6124};
6125
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006126static struct snd_kcontrol_new alc888_hp_lucknow_mixer[] = {
6127 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6128 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6129 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6130 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6131 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6132 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6133 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6134 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6143 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6144 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6145 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6146 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6147 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6148 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6149 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6150 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6151 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6152 {
6153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6154 /* .name = "Capture Source", */
6155 .name = "Input Source",
6156 .count = 2,
6157 .info = alc883_mux_enum_info,
6158 .get = alc883_mux_enum_get,
6159 .put = alc883_mux_enum_put,
6160 },
6161 { } /* end */
6162};
6163
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006164static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6165 {
6166 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6167 .name = "Channel Mode",
6168 .info = alc_ch_mode_info,
6169 .get = alc_ch_mode_get,
6170 .put = alc_ch_mode_put,
6171 },
6172 { } /* end */
6173};
6174
6175static struct hda_verb alc883_init_verbs[] = {
6176 /* ADC1: mute amp left and right */
6177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6178 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6179 /* ADC2: mute amp left and right */
6180 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6181 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6182 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6183 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6184 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6186 /* Rear mixer */
6187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6189 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6190 /* CLFE mixer */
6191 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6193 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6194 /* Side mixer */
6195 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6196 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6198
6199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6204
6205 /* Front Pin: output 0 (0x0c) */
6206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6208 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6209 /* Rear Pin: output 1 (0x0d) */
6210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6212 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6213 /* CLFE Pin: output 2 (0x0e) */
6214 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6215 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6216 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6217 /* Side Pin: output 3 (0x0f) */
6218 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6220 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6221 /* Mic (rear) pin: input vref at 80% */
6222 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6223 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6224 /* Front Mic pin: input vref at 80% */
6225 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6226 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6227 /* Line In pin: input */
6228 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6229 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6230 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6231 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6232 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6233 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6234 /* CD pin widget for input */
6235 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6236
6237 /* FIXME: use matrix-type input source selection */
6238 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6239 /* Input mixer2 */
6240 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6242 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6244 /* Input mixer3 */
6245 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6247 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6249 { }
6250};
6251
Kailang Yangccc656c2006-10-17 12:32:26 +02006252static struct hda_verb alc883_tagra_verbs[] = {
6253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6255
6256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6258
6259 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6260 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6261 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6262
6263 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006264 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6265 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6266 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006267
6268 { } /* end */
6269};
6270
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006271static struct hda_verb alc883_lenovo_101e_verbs[] = {
6272 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6273 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6274 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6275 { } /* end */
6276};
6277
Kailang Yang272a5272007-05-14 11:00:38 +02006278static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6279 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6281 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6283 { } /* end */
6284};
6285
6286static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6289 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6290 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6291 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6292 { } /* end */
6293};
6294
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006295static struct hda_verb alc888_hp_nettle_verbs[] = {
6296 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6298 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6299 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6300 { }
6301};
6302
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006303static struct hda_verb alc888_hp_lucknow_verbs[] = {
6304 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6305 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6306 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6307 { }
6308};
6309
6310static struct hda_verb alc888_hp_lucknow_2ch_init[] = {
6311 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6312 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6313 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6314 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6315 { }
6316};
6317
6318static struct hda_verb alc888_hp_lucknow_6ch_init[] = {
6319 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6320 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6321 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6322 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6323 { }
6324};
6325
6326static struct hda_channel_mode alc888_hp_lucknow_modes[2] = {
6327 { 2, alc888_hp_lucknow_2ch_init },
6328 { 6, alc888_hp_lucknow_6ch_init },
6329};
6330
Kailang Yang272a5272007-05-14 11:00:38 +02006331/* toggle front-jack and RCA according to the hp-jack state */
6332static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6333{
6334 unsigned int present;
6335
6336 present = snd_hda_codec_read(codec, 0x1b, 0,
6337 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6338 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6339 0x80, present ? 0x80 : 0);
6340 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6341 0x80, present ? 0x80 : 0);
6342 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6343 0x80, present ? 0x80 : 0);
6344 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6345 0x80, present ? 0x80 : 0);
6346
6347}
6348
6349/* toggle RCA according to the front-jack state */
6350static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6351{
6352 unsigned int present;
6353
6354 present = snd_hda_codec_read(codec, 0x14, 0,
6355 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6356 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6357 0x80, present ? 0x80 : 0);
6358 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6359 0x80, present ? 0x80 : 0);
6360
6361}
6362static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6363 unsigned int res)
6364{
6365 if ((res >> 26) == ALC880_HP_EVENT)
6366 alc888_lenovo_ms7195_front_automute(codec);
6367 if ((res >> 26) == ALC880_FRONT_EVENT)
6368 alc888_lenovo_ms7195_rca_automute(codec);
6369}
6370
6371static struct hda_verb alc883_medion_md2_verbs[] = {
6372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6374
6375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6376
6377 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6378 { } /* end */
6379};
6380
6381/* toggle speaker-output according to the hp-jack state */
6382static void alc883_medion_md2_automute(struct hda_codec *codec)
6383{
6384 unsigned int present;
6385
6386 present = snd_hda_codec_read(codec, 0x14, 0,
6387 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6388 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6389 0x80, present ? 0x80 : 0);
6390 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6391 0x80, present ? 0x80 : 0);
6392}
6393
6394static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6395 unsigned int res)
6396{
6397 if ((res >> 26) == ALC880_HP_EVENT)
6398 alc883_medion_md2_automute(codec);
6399}
6400
Kailang Yangccc656c2006-10-17 12:32:26 +02006401/* toggle speaker-output according to the hp-jack state */
6402static void alc883_tagra_automute(struct hda_codec *codec)
6403{
6404 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006405 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006406
6407 present = snd_hda_codec_read(codec, 0x14, 0,
6408 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006409 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006410 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006411 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006412 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006413 0x80, bits);
6414 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6415 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006416}
6417
6418static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6419{
6420 if ((res >> 26) == ALC880_HP_EVENT)
6421 alc883_tagra_automute(codec);
6422}
6423
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006424static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6425{
6426 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006427 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006428
6429 present = snd_hda_codec_read(codec, 0x14, 0,
6430 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006431 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006432 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006433 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006434 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006435 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006436}
6437
6438static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6439{
6440 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006441 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006442
6443 present = snd_hda_codec_read(codec, 0x1b, 0,
6444 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006445 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006446 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006447 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006448 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006449 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006450 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006451 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006452 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006453 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006454}
6455
6456static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6457 unsigned int res)
6458{
6459 if ((res >> 26) == ALC880_HP_EVENT)
6460 alc883_lenovo_101e_all_automute(codec);
6461 if ((res >> 26) == ALC880_FRONT_EVENT)
6462 alc883_lenovo_101e_ispeaker_automute(codec);
6463}
6464
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006465/*
6466 * generic initialization of ADC, input mixers and output mixers
6467 */
6468static struct hda_verb alc883_auto_init_verbs[] = {
6469 /*
6470 * Unmute ADC0-2 and set the default input to mic-in
6471 */
6472 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6473 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6474 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6475 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6476
6477 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6478 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006479 * Note: PASD motherboards uses the Line In 2 as the input for
6480 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006481 */
6482 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6485 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6486 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6487 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6488
6489 /*
6490 * Set up output mixers (0x0c - 0x0f)
6491 */
6492 /* set vol=0 to output mixers */
6493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6496 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6497 /* set up input amps for analog loopback */
6498 /* Amp Indices: DAC = 0, mixer = 1 */
6499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6501 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6503 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6506 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6507 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6508 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6509
6510 /* FIXME: use matrix-type input source selection */
6511 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6512 /* Input mixer1 */
6513 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6515 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006516 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006517 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6518 /* Input mixer2 */
6519 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006522 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6524
6525 { }
6526};
6527
6528/* capture mixer elements */
6529static struct snd_kcontrol_new alc883_capture_mixer[] = {
6530 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6531 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6532 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6533 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6534 {
6535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6536 /* The multiple "Capture Source" controls confuse alsamixer
6537 * So call somewhat different..
6538 * FIXME: the controls appear in the "playback" view!
6539 */
6540 /* .name = "Capture Source", */
6541 .name = "Input Source",
6542 .count = 2,
6543 .info = alc882_mux_enum_info,
6544 .get = alc882_mux_enum_get,
6545 .put = alc882_mux_enum_put,
6546 },
6547 { } /* end */
6548};
6549
6550/* pcm configuration: identiacal with ALC880 */
6551#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6552#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6553#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6554#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6555
6556/*
6557 * configuration and preset
6558 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006559static const char *alc883_models[ALC883_MODEL_LAST] = {
6560 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6561 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6562 [ALC883_3ST_6ch] = "3stack-6ch",
6563 [ALC883_6ST_DIG] = "6stack-dig",
6564 [ALC883_TARGA_DIG] = "targa-dig",
6565 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006566 [ALC883_ACER] = "acer",
6567 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006568 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006569 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006570 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006571 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6572 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006573 [ALC888_HP_NETTLE] = "hp-nettle",
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006574 [ALC888_HP_LUCKNOW] = "hp-lucknow",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006575 [ALC883_AUTO] = "auto",
6576};
6577
6578static struct snd_pci_quirk alc883_cfg_tbl[] = {
6579 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006580 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006581 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6582 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6583 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006584 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006585 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6586 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006587 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006588 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02006589 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006590 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006591 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006592 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006593 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6594 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6595 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6596 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6597 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6598 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6599 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6600 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6601 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6602 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006603 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006604 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6605 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6606 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006607 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6608 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6609 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006610 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_HP_NETTLE),
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006611 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_HP_LUCKNOW),
Kailang Yang272a5272007-05-14 11:00:38 +02006612 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006613 {}
6614};
6615
6616static struct alc_config_preset alc883_presets[] = {
6617 [ALC883_3ST_2ch_DIG] = {
6618 .mixers = { alc883_3ST_2ch_mixer },
6619 .init_verbs = { alc883_init_verbs },
6620 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6621 .dac_nids = alc883_dac_nids,
6622 .dig_out_nid = ALC883_DIGOUT_NID,
6623 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6624 .adc_nids = alc883_adc_nids,
6625 .dig_in_nid = ALC883_DIGIN_NID,
6626 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6627 .channel_mode = alc883_3ST_2ch_modes,
6628 .input_mux = &alc883_capture_source,
6629 },
6630 [ALC883_3ST_6ch_DIG] = {
6631 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6632 .init_verbs = { alc883_init_verbs },
6633 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6634 .dac_nids = alc883_dac_nids,
6635 .dig_out_nid = ALC883_DIGOUT_NID,
6636 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6637 .adc_nids = alc883_adc_nids,
6638 .dig_in_nid = ALC883_DIGIN_NID,
6639 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6640 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006641 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006642 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006643 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006644 [ALC883_3ST_6ch] = {
6645 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6646 .init_verbs = { alc883_init_verbs },
6647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6648 .dac_nids = alc883_dac_nids,
6649 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6650 .adc_nids = alc883_adc_nids,
6651 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6652 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006653 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006654 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006655 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006656 [ALC883_6ST_DIG] = {
6657 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6658 .init_verbs = { alc883_init_verbs },
6659 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6660 .dac_nids = alc883_dac_nids,
6661 .dig_out_nid = ALC883_DIGOUT_NID,
6662 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6663 .adc_nids = alc883_adc_nids,
6664 .dig_in_nid = ALC883_DIGIN_NID,
6665 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6666 .channel_mode = alc883_sixstack_modes,
6667 .input_mux = &alc883_capture_source,
6668 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006669 [ALC883_TARGA_DIG] = {
6670 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6671 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6672 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6673 .dac_nids = alc883_dac_nids,
6674 .dig_out_nid = ALC883_DIGOUT_NID,
6675 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6676 .adc_nids = alc883_adc_nids,
6677 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6678 .channel_mode = alc883_3ST_6ch_modes,
6679 .need_dac_fix = 1,
6680 .input_mux = &alc883_capture_source,
6681 .unsol_event = alc883_tagra_unsol_event,
6682 .init_hook = alc883_tagra_automute,
6683 },
6684 [ALC883_TARGA_2ch_DIG] = {
6685 .mixers = { alc883_tagra_2ch_mixer},
6686 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6687 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6688 .dac_nids = alc883_dac_nids,
6689 .dig_out_nid = ALC883_DIGOUT_NID,
6690 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6691 .adc_nids = alc883_adc_nids,
6692 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6693 .channel_mode = alc883_3ST_2ch_modes,
6694 .input_mux = &alc883_capture_source,
6695 .unsol_event = alc883_tagra_unsol_event,
6696 .init_hook = alc883_tagra_automute,
6697 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02006698 [ALC883_ACER] = {
6699 .mixers = { alc883_base_mixer,
6700 alc883_chmode_mixer },
6701 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6702 * and the headphone jack. Turn this on and rely on the
6703 * standard mute methods whenever the user wants to turn
6704 * these outputs off.
6705 */
6706 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6708 .dac_nids = alc883_dac_nids,
6709 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6710 .adc_nids = alc883_adc_nids,
6711 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6712 .channel_mode = alc883_3ST_2ch_modes,
6713 .input_mux = &alc883_capture_source,
6714 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006715 [ALC883_MEDION] = {
6716 .mixers = { alc883_fivestack_mixer,
6717 alc883_chmode_mixer },
6718 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006719 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006720 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6721 .dac_nids = alc883_dac_nids,
6722 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6723 .adc_nids = alc883_adc_nids,
6724 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6725 .channel_mode = alc883_sixstack_modes,
6726 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006727 },
Kailang Yang272a5272007-05-14 11:00:38 +02006728 [ALC883_MEDION_MD2] = {
6729 .mixers = { alc883_medion_md2_mixer},
6730 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6731 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6732 .dac_nids = alc883_dac_nids,
6733 .dig_out_nid = ALC883_DIGOUT_NID,
6734 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6735 .adc_nids = alc883_adc_nids,
6736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6737 .channel_mode = alc883_3ST_2ch_modes,
6738 .input_mux = &alc883_capture_source,
6739 .unsol_event = alc883_medion_md2_unsol_event,
6740 .init_hook = alc883_medion_md2_automute,
6741 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006742 [ALC883_LAPTOP_EAPD] = {
6743 .mixers = { alc883_base_mixer,
6744 alc883_chmode_mixer },
6745 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6746 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6747 .dac_nids = alc883_dac_nids,
6748 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6749 .adc_nids = alc883_adc_nids,
6750 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6751 .channel_mode = alc883_3ST_2ch_modes,
6752 .input_mux = &alc883_capture_source,
6753 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006754 [ALC883_LENOVO_101E_2ch] = {
6755 .mixers = { alc883_lenovo_101e_2ch_mixer},
6756 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6757 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6758 .dac_nids = alc883_dac_nids,
6759 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6760 .adc_nids = alc883_adc_nids,
6761 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6762 .channel_mode = alc883_3ST_2ch_modes,
6763 .input_mux = &alc883_lenovo_101e_capture_source,
6764 .unsol_event = alc883_lenovo_101e_unsol_event,
6765 .init_hook = alc883_lenovo_101e_all_automute,
6766 },
Kailang Yang272a5272007-05-14 11:00:38 +02006767 [ALC883_LENOVO_NB0763] = {
6768 .mixers = { alc883_lenovo_nb0763_mixer },
6769 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6770 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6771 .dac_nids = alc883_dac_nids,
6772 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6773 .adc_nids = alc883_adc_nids,
6774 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6775 .channel_mode = alc883_3ST_2ch_modes,
6776 .need_dac_fix = 1,
6777 .input_mux = &alc883_lenovo_nb0763_capture_source,
6778 .unsol_event = alc883_medion_md2_unsol_event,
6779 .init_hook = alc883_medion_md2_automute,
6780 },
6781 [ALC888_LENOVO_MS7195_DIG] = {
6782 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6783 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6784 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6785 .dac_nids = alc883_dac_nids,
6786 .dig_out_nid = ALC883_DIGOUT_NID,
6787 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6788 .adc_nids = alc883_adc_nids,
6789 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6790 .channel_mode = alc883_3ST_6ch_modes,
6791 .need_dac_fix = 1,
6792 .input_mux = &alc883_capture_source,
6793 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6794 .init_hook = alc888_lenovo_ms7195_front_automute,
6795 },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006796 [ALC888_HP_NETTLE] = {
6797 .mixers = { alc888_hp_nettle_mixer, alc883_chmode_mixer },
6798 .init_verbs = { alc883_init_verbs, alc888_hp_nettle_verbs },
6799 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6800 .dac_nids = alc883_dac_nids,
6801 .dig_out_nid = ALC883_DIGOUT_NID,
6802 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6803 .adc_nids = alc883_adc_nids,
6804 .dig_in_nid = ALC883_DIGIN_NID,
6805 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6806 .channel_mode = alc883_sixstack_modes,
6807 .input_mux = &alc883_capture_source,
6808 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006809 [ALC888_HP_LUCKNOW] = {
6810 .mixers = { alc888_hp_lucknow_mixer, alc883_chmode_mixer },
6811 .init_verbs = { alc883_init_verbs, alc888_hp_lucknow_verbs },
6812 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6813 .dac_nids = alc883_dac_nids,
6814 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6815 .adc_nids = alc883_adc_nids,
6816 .num_channel_mode = ARRAY_SIZE(alc888_hp_lucknow_modes),
6817 .channel_mode = alc888_hp_lucknow_modes,
6818 .need_dac_fix = 1,
6819 .input_mux = &alc883_capture_source,
6820 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006821};
6822
6823
6824/*
6825 * BIOS auto configuration
6826 */
6827static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6828 hda_nid_t nid, int pin_type,
6829 int dac_idx)
6830{
6831 /* set as output */
6832 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006833 int idx;
6834
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006835 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6836 idx = 4;
6837 else
6838 idx = spec->multiout.dac_nids[dac_idx] - 2;
6839
6840 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6841 pin_type);
6842 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6843 AMP_OUT_UNMUTE);
6844 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6845
6846}
6847
6848static void alc883_auto_init_multi_out(struct hda_codec *codec)
6849{
6850 struct alc_spec *spec = codec->spec;
6851 int i;
6852
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006853 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006854 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006855 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006856 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006857 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006858 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006859 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006860 }
6861}
6862
6863static void alc883_auto_init_hp_out(struct hda_codec *codec)
6864{
6865 struct alc_spec *spec = codec->spec;
6866 hda_nid_t pin;
6867
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006868 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006869 if (pin) /* connect to front */
6870 /* use dac 0 */
6871 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6872}
6873
6874#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6875#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6876
6877static void alc883_auto_init_analog_input(struct hda_codec *codec)
6878{
6879 struct alc_spec *spec = codec->spec;
6880 int i;
6881
6882 for (i = 0; i < AUTO_PIN_LAST; i++) {
6883 hda_nid_t nid = spec->autocfg.input_pins[i];
6884 if (alc883_is_input_pin(nid)) {
6885 snd_hda_codec_write(codec, nid, 0,
6886 AC_VERB_SET_PIN_WIDGET_CONTROL,
6887 (i <= AUTO_PIN_FRONT_MIC ?
6888 PIN_VREF80 : PIN_IN));
6889 if (nid != ALC883_PIN_CD_NID)
6890 snd_hda_codec_write(codec, nid, 0,
6891 AC_VERB_SET_AMP_GAIN_MUTE,
6892 AMP_OUT_MUTE);
6893 }
6894 }
6895}
6896
6897/* almost identical with ALC880 parser... */
6898static int alc883_parse_auto_config(struct hda_codec *codec)
6899{
6900 struct alc_spec *spec = codec->spec;
6901 int err = alc880_parse_auto_config(codec);
6902
6903 if (err < 0)
6904 return err;
6905 else if (err > 0)
6906 /* hack - override the init verbs */
6907 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006908 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6909 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006910 return err;
6911}
6912
6913/* additional initialization for auto-configuration model */
6914static void alc883_auto_init(struct hda_codec *codec)
6915{
6916 alc883_auto_init_multi_out(codec);
6917 alc883_auto_init_hp_out(codec);
6918 alc883_auto_init_analog_input(codec);
6919}
6920
6921static int patch_alc883(struct hda_codec *codec)
6922{
6923 struct alc_spec *spec;
6924 int err, board_config;
6925
6926 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6927 if (spec == NULL)
6928 return -ENOMEM;
6929
6930 codec->spec = spec;
6931
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006932 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6933 alc883_models,
6934 alc883_cfg_tbl);
6935 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006936 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6937 "trying auto-probe from BIOS...\n");
6938 board_config = ALC883_AUTO;
6939 }
6940
6941 if (board_config == ALC883_AUTO) {
6942 /* automatic parse from the BIOS config */
6943 err = alc883_parse_auto_config(codec);
6944 if (err < 0) {
6945 alc_free(codec);
6946 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006947 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006948 printk(KERN_INFO
6949 "hda_codec: Cannot set up configuration "
6950 "from BIOS. Using base mode...\n");
6951 board_config = ALC883_3ST_2ch_DIG;
6952 }
6953 }
6954
6955 if (board_config != ALC883_AUTO)
6956 setup_preset(spec, &alc883_presets[board_config]);
6957
6958 spec->stream_name_analog = "ALC883 Analog";
6959 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6960 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6961
6962 spec->stream_name_digital = "ALC883 Digital";
6963 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6964 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6965
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006966 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006967 spec->adc_nids = alc883_adc_nids;
6968 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6969 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006970
6971 codec->patch_ops = alc_patch_ops;
6972 if (board_config == ALC883_AUTO)
6973 spec->init_hook = alc883_auto_init;
6974
6975 return 0;
6976}
6977
6978/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006979 * ALC262 support
6980 */
6981
6982#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6983#define ALC262_DIGIN_NID ALC880_DIGIN_NID
6984
6985#define alc262_dac_nids alc260_dac_nids
6986#define alc262_adc_nids alc882_adc_nids
6987#define alc262_adc_nids_alt alc882_adc_nids_alt
6988
6989#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01006990#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01006991
6992static struct snd_kcontrol_new alc262_base_mixer[] = {
6993 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6994 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6995 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6996 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007001 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007004 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007005 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7006 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7007 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7009 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7010 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007011 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007012};
7013
Kailang Yangccc656c2006-10-17 12:32:26 +02007014static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7015 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7016 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7017 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7018 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7019 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7020 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007023 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007024 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7025 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007026 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007027 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7028 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7029 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7031 { } /* end */
7032};
7033
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007034static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7035 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7036 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7037 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7038 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7039 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7040
7041 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7042 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007043 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007044 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7045 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007046 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007047 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7048 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7049 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7050 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7051 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7052 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7053 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7054 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7055 { } /* end */
7056};
7057
Kailang Yangcd7509a2007-01-26 18:33:17 +01007058static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7059 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7060 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7061 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7063 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7064 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7065 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7066 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007067 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7073 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7074 { } /* end */
7075};
7076
7077static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7078 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7079 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007080 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007081 { } /* end */
7082};
7083
Kailang Yang272a5272007-05-14 11:00:38 +02007084static struct snd_kcontrol_new alc262_sony_mixer[] = {
7085 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7086 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7087 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7089 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7090 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7091 { } /* end */
7092};
7093
Kailang Yang83c34212007-07-05 11:43:05 +02007094static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7096 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7097 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7100 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7101 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7102 { } /* end */
7103};
Kailang Yang272a5272007-05-14 11:00:38 +02007104
Kailang Yangdf694da2005-12-05 19:42:22 +01007105#define alc262_capture_mixer alc882_capture_mixer
7106#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7107
7108/*
7109 * generic initialization of ADC, input mixers and output mixers
7110 */
7111static struct hda_verb alc262_init_verbs[] = {
7112 /*
7113 * Unmute ADC0-2 and set the default input to mic-in
7114 */
7115 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7117 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7119 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7121
7122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7123 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007124 * Note: PASD motherboards uses the Line In 2 as the input for
7125 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007126 */
7127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7133
7134 /*
7135 * Set up output mixers (0x0c - 0x0e)
7136 */
7137 /* set vol=0 to output mixers */
7138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7139 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7141 /* set up input amps for analog loopback */
7142 /* Amp Indices: DAC = 0, mixer = 1 */
7143 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7149
7150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7151 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7152 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7153 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7154 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7155 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7156
7157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7159 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7160 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7161 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7162
7163 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7164 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7165
7166 /* FIXME: use matrix-type input source selection */
7167 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7168 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7173 /* Input mixer2 */
7174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7176 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7177 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7178 /* Input mixer3 */
7179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007183
7184 { }
7185};
7186
Kailang Yangccc656c2006-10-17 12:32:26 +02007187static struct hda_verb alc262_hippo_unsol_verbs[] = {
7188 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7189 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7190 {}
7191};
7192
7193static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7194 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7196 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7197
7198 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7199 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7200 {}
7201};
7202
Kailang Yang272a5272007-05-14 11:00:38 +02007203static struct hda_verb alc262_sony_unsol_verbs[] = {
7204 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7205 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7206 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7207
7208 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7210};
7211
Kailang Yangccc656c2006-10-17 12:32:26 +02007212/* mute/unmute internal speaker according to the hp jack and mute state */
7213static void alc262_hippo_automute(struct hda_codec *codec, int force)
7214{
7215 struct alc_spec *spec = codec->spec;
7216 unsigned int mute;
7217
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007218 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007219 unsigned int present;
7220 /* need to execute and sync at first */
7221 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7222 present = snd_hda_codec_read(codec, 0x15, 0,
7223 AC_VERB_GET_PIN_SENSE, 0);
7224 spec->jack_present = (present & 0x80000000) != 0;
7225 spec->sense_updated = 1;
7226 }
7227 if (spec->jack_present) {
7228 /* mute internal speaker */
7229 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7230 0x80, 0x80);
7231 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7232 0x80, 0x80);
7233 } else {
7234 /* unmute internal speaker if necessary */
7235 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7236 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7237 0x80, mute & 0x80);
7238 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7239 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7240 0x80, mute & 0x80);
7241 }
7242}
7243
7244/* unsolicited event for HP jack sensing */
7245static void alc262_hippo_unsol_event(struct hda_codec *codec,
7246 unsigned int res)
7247{
7248 if ((res >> 26) != ALC880_HP_EVENT)
7249 return;
7250 alc262_hippo_automute(codec, 1);
7251}
7252
7253static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7254{
7255 struct alc_spec *spec = codec->spec;
7256 unsigned int mute;
7257
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007258 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007259 unsigned int present;
7260 /* need to execute and sync at first */
7261 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7262 present = snd_hda_codec_read(codec, 0x1b, 0,
7263 AC_VERB_GET_PIN_SENSE, 0);
7264 spec->jack_present = (present & 0x80000000) != 0;
7265 spec->sense_updated = 1;
7266 }
7267 if (spec->jack_present) {
7268 /* mute internal speaker */
7269 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7270 0x80, 0x80);
7271 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7272 0x80, 0x80);
7273 } else {
7274 /* unmute internal speaker if necessary */
7275 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7276 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7277 0x80, mute & 0x80);
7278 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7279 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7280 0x80, mute & 0x80);
7281 }
7282}
7283
7284/* unsolicited event for HP jack sensing */
7285static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7286 unsigned int res)
7287{
7288 if ((res >> 26) != ALC880_HP_EVENT)
7289 return;
7290 alc262_hippo1_automute(codec, 1);
7291}
7292
Takashi Iwai834be882006-03-01 14:16:17 +01007293/*
7294 * fujitsu model
7295 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7296 */
7297
7298#define ALC_HP_EVENT 0x37
7299
7300static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7301 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7302 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7303 {}
7304};
7305
7306static struct hda_input_mux alc262_fujitsu_capture_source = {
7307 .num_items = 2,
7308 .items = {
7309 { "Mic", 0x0 },
7310 { "CD", 0x4 },
7311 },
7312};
7313
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007314static struct hda_input_mux alc262_HP_capture_source = {
7315 .num_items = 5,
7316 .items = {
7317 { "Mic", 0x0 },
7318 { "Front Mic", 0x3 },
7319 { "Line", 0x2 },
7320 { "CD", 0x4 },
7321 { "AUX IN", 0x6 },
7322 },
7323};
7324
Takashi Iwai834be882006-03-01 14:16:17 +01007325/* mute/unmute internal speaker according to the hp jack and mute state */
7326static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7327{
7328 struct alc_spec *spec = codec->spec;
7329 unsigned int mute;
7330
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007331 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007332 unsigned int present;
7333 /* need to execute and sync at first */
7334 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7335 present = snd_hda_codec_read(codec, 0x14, 0,
7336 AC_VERB_GET_PIN_SENSE, 0);
7337 spec->jack_present = (present & 0x80000000) != 0;
7338 spec->sense_updated = 1;
7339 }
7340 if (spec->jack_present) {
7341 /* mute internal speaker */
7342 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7343 0x80, 0x80);
7344 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7345 0x80, 0x80);
7346 } else {
7347 /* unmute internal speaker if necessary */
7348 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7349 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7350 0x80, mute & 0x80);
7351 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7352 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7353 0x80, mute & 0x80);
7354 }
7355}
7356
7357/* unsolicited event for HP jack sensing */
7358static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7359 unsigned int res)
7360{
7361 if ((res >> 26) != ALC_HP_EVENT)
7362 return;
7363 alc262_fujitsu_automute(codec, 1);
7364}
7365
7366/* bind volumes of both NID 0x0c and 0x0d */
7367static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7368 struct snd_ctl_elem_value *ucontrol)
7369{
7370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7371 long *valp = ucontrol->value.integer.value;
7372 int change;
7373
7374 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7375 0x7f, valp[0] & 0x7f);
7376 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7377 0x7f, valp[1] & 0x7f);
7378 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7379 0x7f, valp[0] & 0x7f);
7380 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7381 0x7f, valp[1] & 0x7f);
7382 return change;
7383}
7384
7385/* bind hp and internal speaker mute (with plug check) */
7386static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7387 struct snd_ctl_elem_value *ucontrol)
7388{
7389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7390 long *valp = ucontrol->value.integer.value;
7391 int change;
7392
7393 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7394 0x80, valp[0] ? 0 : 0x80);
7395 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7396 0x80, valp[1] ? 0 : 0x80);
7397 if (change || codec->in_resume)
7398 alc262_fujitsu_automute(codec, codec->in_resume);
7399 return change;
7400}
7401
7402static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7403 {
7404 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7405 .name = "Master Playback Volume",
7406 .info = snd_hda_mixer_amp_volume_info,
7407 .get = snd_hda_mixer_amp_volume_get,
7408 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007409 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007410 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7411 },
7412 {
7413 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7414 .name = "Master Playback Switch",
7415 .info = snd_hda_mixer_amp_switch_info,
7416 .get = snd_hda_mixer_amp_switch_get,
7417 .put = alc262_fujitsu_master_sw_put,
7418 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7419 },
7420 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7421 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7425 { } /* end */
7426};
7427
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007428/* additional init verbs for Benq laptops */
7429static struct hda_verb alc262_EAPD_verbs[] = {
7430 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7431 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7432 {}
7433};
7434
Kailang Yang83c34212007-07-05 11:43:05 +02007435static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7436 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7438
7439 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7440 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7441 {}
7442};
7443
Kailang Yangdf694da2005-12-05 19:42:22 +01007444/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007445static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7446 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007447{
7448 hda_nid_t nid;
7449 int err;
7450
7451 spec->multiout.num_dacs = 1; /* only use one dac */
7452 spec->multiout.dac_nids = spec->private_dac_nids;
7453 spec->multiout.dac_nids[0] = 2;
7454
7455 nid = cfg->line_out_pins[0];
7456 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007457 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7458 "Front Playback Volume",
7459 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7460 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007461 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007462 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7463 "Front Playback Switch",
7464 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7465 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007466 return err;
7467 }
7468
Takashi Iwai82bc9552006-03-21 11:24:42 +01007469 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007470 if (nid) {
7471 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007472 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7473 "Speaker Playback Volume",
7474 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7475 HDA_OUTPUT));
7476 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007477 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007478 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7479 "Speaker Playback Switch",
7480 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7481 HDA_OUTPUT));
7482 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007483 return err;
7484 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007485 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7486 "Speaker Playback Switch",
7487 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7488 HDA_OUTPUT));
7489 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007490 return err;
7491 }
7492 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007493 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007494 if (nid) {
7495 /* spec->multiout.hp_nid = 2; */
7496 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007497 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7498 "Headphone Playback Volume",
7499 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7500 HDA_OUTPUT));
7501 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007502 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007503 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7504 "Headphone Playback Switch",
7505 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7506 HDA_OUTPUT));
7507 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007508 return err;
7509 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007510 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7511 "Headphone Playback Switch",
7512 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7513 HDA_OUTPUT));
7514 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007515 return err;
7516 }
7517 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007518 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007519}
7520
7521/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007522#define alc262_auto_create_analog_input_ctls \
7523 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007524
7525/*
7526 * generic initialization of ADC, input mixers and output mixers
7527 */
7528static struct hda_verb alc262_volume_init_verbs[] = {
7529 /*
7530 * Unmute ADC0-2 and set the default input to mic-in
7531 */
7532 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7533 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7534 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7536 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7538
7539 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7540 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007541 * Note: PASD motherboards uses the Line In 2 as the input for
7542 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007543 */
7544 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7550
7551 /*
7552 * Set up output mixers (0x0c - 0x0f)
7553 */
7554 /* set vol=0 to output mixers */
7555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7558
7559 /* set up input amps for analog loopback */
7560 /* Amp Indices: DAC = 0, mixer = 1 */
7561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7567
7568 /* FIXME: use matrix-type input source selection */
7569 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7570 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7575 /* Input mixer2 */
7576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7577 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7578 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7579 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7580 /* Input mixer3 */
7581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7583 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7584 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7585
7586 { }
7587};
7588
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007589static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7590 /*
7591 * Unmute ADC0-2 and set the default input to mic-in
7592 */
7593 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7595 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7596 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7597 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7599
7600 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7601 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007602 * Note: PASD motherboards uses the Line In 2 as the input for
7603 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007604 */
7605 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7610 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7611 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7613
7614 /*
7615 * Set up output mixers (0x0c - 0x0e)
7616 */
7617 /* set vol=0 to output mixers */
7618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7620 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7621
7622 /* set up input amps for analog loopback */
7623 /* Amp Indices: DAC = 0, mixer = 1 */
7624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7627 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7628 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7629 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7630
7631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7634
7635 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7637
7638 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7639 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7640
7641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7643 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7645 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7646
7647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7648 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7649 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7650 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7651 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7652 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7653
7654
7655 /* FIXME: use matrix-type input source selection */
7656 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7657 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7662 /* Input mixer2 */
7663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7667 /* Input mixer3 */
7668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7672
7673 { }
7674};
7675
Kailang Yangcd7509a2007-01-26 18:33:17 +01007676static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7677 /*
7678 * Unmute ADC0-2 and set the default input to mic-in
7679 */
7680 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7682 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7683 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7684 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7686
7687 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7688 * mixer widget
7689 * Note: PASD motherboards uses the Line In 2 as the input for front
7690 * panel mic (mic 2)
7691 */
7692 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7701 /*
7702 * Set up output mixers (0x0c - 0x0e)
7703 */
7704 /* set vol=0 to output mixers */
7705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7706 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7708
7709 /* set up input amps for analog loopback */
7710 /* Amp Indices: DAC = 0, mixer = 1 */
7711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7714 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7716 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7717
7718
7719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7720 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7721 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7724 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7725 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7726
7727 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7728 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7729
7730 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7731 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7732
7733 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7734 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7735 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7737 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7738 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7739
7740 /* FIXME: use matrix-type input source selection */
7741 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7742 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7744 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7748 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7750 /* Input mixer2 */
7751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7752 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7756 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7757 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7758 /* Input mixer3 */
7759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7762 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7763 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7764 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7766
7767 { }
7768};
7769
Kailang Yangdf694da2005-12-05 19:42:22 +01007770/* pcm configuration: identiacal with ALC880 */
7771#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7772#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7773#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7774#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7775
7776/*
7777 * BIOS auto configuration
7778 */
7779static int alc262_parse_auto_config(struct hda_codec *codec)
7780{
7781 struct alc_spec *spec = codec->spec;
7782 int err;
7783 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7784
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007785 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7786 alc262_ignore);
7787 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007788 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007789 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007790 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007791 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7792 if (err < 0)
7793 return err;
7794 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7795 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007796 return err;
7797
7798 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7799
7800 if (spec->autocfg.dig_out_pin)
7801 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7802 if (spec->autocfg.dig_in_pin)
7803 spec->dig_in_nid = ALC262_DIGIN_NID;
7804
7805 if (spec->kctl_alloc)
7806 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7807
7808 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007809 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007810 spec->input_mux = &spec->private_imux;
7811
7812 return 1;
7813}
7814
7815#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7816#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7817#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7818
7819
7820/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007821static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007822{
Kailang Yangdf694da2005-12-05 19:42:22 +01007823 alc262_auto_init_multi_out(codec);
7824 alc262_auto_init_hp_out(codec);
7825 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007826}
7827
7828/*
7829 * configuration and preset
7830 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007831static const char *alc262_models[ALC262_MODEL_LAST] = {
7832 [ALC262_BASIC] = "basic",
7833 [ALC262_HIPPO] = "hippo",
7834 [ALC262_HIPPO_1] = "hippo_1",
7835 [ALC262_FUJITSU] = "fujitsu",
7836 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007837 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007838 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02007839 [ALC262_BENQ_T31] = "benq-t31",
7840 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007841 [ALC262_AUTO] = "auto",
7842};
7843
7844static struct snd_pci_quirk alc262_cfg_tbl[] = {
7845 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7846 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7847 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007848 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7849 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007850 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007851 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007852 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007853 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007854 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7855 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7856 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7857 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7858 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7859 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7860 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7861 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007862 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7863 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7864 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7865 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02007866 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Kailang Yang272a5272007-05-14 11:00:38 +02007867 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7868 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7869 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007870 {}
7871};
7872
7873static struct alc_config_preset alc262_presets[] = {
7874 [ALC262_BASIC] = {
7875 .mixers = { alc262_base_mixer },
7876 .init_verbs = { alc262_init_verbs },
7877 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7878 .dac_nids = alc262_dac_nids,
7879 .hp_nid = 0x03,
7880 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7881 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007882 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007883 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007884 [ALC262_HIPPO] = {
7885 .mixers = { alc262_base_mixer },
7886 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7887 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7888 .dac_nids = alc262_dac_nids,
7889 .hp_nid = 0x03,
7890 .dig_out_nid = ALC262_DIGOUT_NID,
7891 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7892 .channel_mode = alc262_modes,
7893 .input_mux = &alc262_capture_source,
7894 .unsol_event = alc262_hippo_unsol_event,
7895 },
7896 [ALC262_HIPPO_1] = {
7897 .mixers = { alc262_hippo1_mixer },
7898 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7899 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7900 .dac_nids = alc262_dac_nids,
7901 .hp_nid = 0x02,
7902 .dig_out_nid = ALC262_DIGOUT_NID,
7903 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7904 .channel_mode = alc262_modes,
7905 .input_mux = &alc262_capture_source,
7906 .unsol_event = alc262_hippo1_unsol_event,
7907 },
Takashi Iwai834be882006-03-01 14:16:17 +01007908 [ALC262_FUJITSU] = {
7909 .mixers = { alc262_fujitsu_mixer },
7910 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7911 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7912 .dac_nids = alc262_dac_nids,
7913 .hp_nid = 0x03,
7914 .dig_out_nid = ALC262_DIGOUT_NID,
7915 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7916 .channel_mode = alc262_modes,
7917 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007918 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007919 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007920 [ALC262_HP_BPC] = {
7921 .mixers = { alc262_HP_BPC_mixer },
7922 .init_verbs = { alc262_HP_BPC_init_verbs },
7923 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7924 .dac_nids = alc262_dac_nids,
7925 .hp_nid = 0x03,
7926 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7927 .channel_mode = alc262_modes,
7928 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007929 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007930 [ALC262_HP_BPC_D7000_WF] = {
7931 .mixers = { alc262_HP_BPC_WildWest_mixer },
7932 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7933 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7934 .dac_nids = alc262_dac_nids,
7935 .hp_nid = 0x03,
7936 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7937 .channel_mode = alc262_modes,
7938 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007939 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007940 [ALC262_HP_BPC_D7000_WL] = {
7941 .mixers = { alc262_HP_BPC_WildWest_mixer,
7942 alc262_HP_BPC_WildWest_option_mixer },
7943 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7944 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7945 .dac_nids = alc262_dac_nids,
7946 .hp_nid = 0x03,
7947 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7948 .channel_mode = alc262_modes,
7949 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007950 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007951 [ALC262_BENQ_ED8] = {
7952 .mixers = { alc262_base_mixer },
7953 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7954 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7955 .dac_nids = alc262_dac_nids,
7956 .hp_nid = 0x03,
7957 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7958 .channel_mode = alc262_modes,
7959 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007960 },
Kailang Yang272a5272007-05-14 11:00:38 +02007961 [ALC262_SONY_ASSAMD] = {
7962 .mixers = { alc262_sony_mixer },
7963 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7964 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7965 .dac_nids = alc262_dac_nids,
7966 .hp_nid = 0x02,
7967 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7968 .channel_mode = alc262_modes,
7969 .input_mux = &alc262_capture_source,
7970 .unsol_event = alc262_hippo_unsol_event,
Kailang Yang83c34212007-07-05 11:43:05 +02007971 },
7972 [ALC262_BENQ_T31] = {
7973 .mixers = { alc262_benq_t31_mixer },
7974 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
7975 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7976 .dac_nids = alc262_dac_nids,
7977 .hp_nid = 0x03,
7978 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7979 .channel_mode = alc262_modes,
7980 .input_mux = &alc262_capture_source,
7981 .unsol_event = alc262_hippo_unsol_event,
Kailang Yang272a5272007-05-14 11:00:38 +02007982 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007983};
7984
7985static int patch_alc262(struct hda_codec *codec)
7986{
7987 struct alc_spec *spec;
7988 int board_config;
7989 int err;
7990
Robert P. J. Daydc041e02006-12-19 14:44:15 +01007991 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01007992 if (spec == NULL)
7993 return -ENOMEM;
7994
7995 codec->spec = spec;
7996#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007997 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7998 * under-run
7999 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008000 {
8001 int tmp;
8002 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8003 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8004 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8005 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8006 }
8007#endif
8008
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008009 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8010 alc262_models,
8011 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01008012
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008013 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008014 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8015 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008016 board_config = ALC262_AUTO;
8017 }
8018
8019 if (board_config == ALC262_AUTO) {
8020 /* automatic parse from the BIOS config */
8021 err = alc262_parse_auto_config(codec);
8022 if (err < 0) {
8023 alc_free(codec);
8024 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008025 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008026 printk(KERN_INFO
8027 "hda_codec: Cannot set up configuration "
8028 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008029 board_config = ALC262_BASIC;
8030 }
8031 }
8032
8033 if (board_config != ALC262_AUTO)
8034 setup_preset(spec, &alc262_presets[board_config]);
8035
8036 spec->stream_name_analog = "ALC262 Analog";
8037 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8038 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8039
8040 spec->stream_name_digital = "ALC262 Digital";
8041 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8042 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8043
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008044 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008045 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01008046 unsigned int wcap = get_wcaps(codec, 0x07);
8047
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008048 /* get type */
8049 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01008050 if (wcap != AC_WID_AUD_IN) {
8051 spec->adc_nids = alc262_adc_nids_alt;
8052 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008053 spec->mixers[spec->num_mixers] =
8054 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01008055 spec->num_mixers++;
8056 } else {
8057 spec->adc_nids = alc262_adc_nids;
8058 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8059 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8060 spec->num_mixers++;
8061 }
8062 }
8063
8064 codec->patch_ops = alc_patch_ops;
8065 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008066 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01008067
Kailang Yangdf694da2005-12-05 19:42:22 +01008068 return 0;
8069}
8070
Kailang Yangdf694da2005-12-05 19:42:22 +01008071/*
Kailang Yanga361d842007-06-05 12:30:55 +02008072 * ALC268 channel source setting (2 channel)
8073 */
8074#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8075#define alc268_modes alc260_modes
8076
8077static hda_nid_t alc268_dac_nids[2] = {
8078 /* front, hp */
8079 0x02, 0x03
8080};
8081
8082static hda_nid_t alc268_adc_nids[2] = {
8083 /* ADC0-1 */
8084 0x08, 0x07
8085};
8086
8087static hda_nid_t alc268_adc_nids_alt[1] = {
8088 /* ADC0 */
8089 0x08
8090};
8091
8092static struct snd_kcontrol_new alc268_base_mixer[] = {
8093 /* output mixer control */
8094 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8095 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8096 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8097 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8098 { }
8099};
8100
8101/*
8102 * generic initialization of ADC, input mixers and output mixers
8103 */
8104static struct hda_verb alc268_base_init_verbs[] = {
8105 /* Unmute DAC0-1 and set vol = 0 */
8106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8107 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8108 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8109 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8110 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8111 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8112
8113 /*
8114 * Set up output mixers (0x0c - 0x0e)
8115 */
8116 /* set vol=0 to output mixers */
8117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8120 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8121
8122 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8123 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8124
8125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8127 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8128 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8130 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8131 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8132 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8133
8134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8135 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8136 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8137 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8139 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8140 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8141 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8142
8143 /* FIXME: use matrix-type input source selection */
8144 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8145 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8146 /* Input mixer2 */
8147 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8148 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8149 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8150 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8151
8152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8154 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8156 { }
8157};
8158
8159/*
8160 * generic initialization of ADC, input mixers and output mixers
8161 */
8162static struct hda_verb alc268_volume_init_verbs[] = {
8163 /* set output DAC */
8164 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8165 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8166 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8167 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8168
8169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8170 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8171 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8172 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8173 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8174
8175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8179 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8180
8181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8182 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8184 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8185
8186 /* set PCBEEP vol = 0 */
8187 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8188
8189 { }
8190};
8191
8192#define alc268_mux_enum_info alc_mux_enum_info
8193#define alc268_mux_enum_get alc_mux_enum_get
8194
8195static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8196 struct snd_ctl_elem_value *ucontrol)
8197{
8198 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8199 struct alc_spec *spec = codec->spec;
8200 const struct hda_input_mux *imux = spec->input_mux;
8201 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8202 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8203 hda_nid_t nid = capture_mixers[adc_idx];
8204 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8205 unsigned int i, idx;
8206
8207 idx = ucontrol->value.enumerated.item[0];
8208 if (idx >= imux->num_items)
8209 idx = imux->num_items - 1;
8210 if (*cur_val == idx && !codec->in_resume)
8211 return 0;
8212 for (i = 0; i < imux->num_items; i++) {
8213 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8214 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8215 v | (imux->items[i].index << 8));
8216 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8217 idx );
8218 }
8219 *cur_val = idx;
8220 return 1;
8221}
8222
8223static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8224 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8225 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8226 {
8227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8228 /* The multiple "Capture Source" controls confuse alsamixer
8229 * So call somewhat different..
8230 * FIXME: the controls appear in the "playback" view!
8231 */
8232 /* .name = "Capture Source", */
8233 .name = "Input Source",
8234 .count = 1,
8235 .info = alc268_mux_enum_info,
8236 .get = alc268_mux_enum_get,
8237 .put = alc268_mux_enum_put,
8238 },
8239 { } /* end */
8240};
8241
8242static struct snd_kcontrol_new alc268_capture_mixer[] = {
8243 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8244 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8245 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8246 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8247 {
8248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8249 /* The multiple "Capture Source" controls confuse alsamixer
8250 * So call somewhat different..
8251 * FIXME: the controls appear in the "playback" view!
8252 */
8253 /* .name = "Capture Source", */
8254 .name = "Input Source",
8255 .count = 2,
8256 .info = alc268_mux_enum_info,
8257 .get = alc268_mux_enum_get,
8258 .put = alc268_mux_enum_put,
8259 },
8260 { } /* end */
8261};
8262
8263static struct hda_input_mux alc268_capture_source = {
8264 .num_items = 4,
8265 .items = {
8266 { "Mic", 0x0 },
8267 { "Front Mic", 0x1 },
8268 { "Line", 0x2 },
8269 { "CD", 0x3 },
8270 },
8271};
8272
8273/* create input playback/capture controls for the given pin */
8274static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8275 const char *ctlname, int idx)
8276{
8277 char name[32];
8278 int err;
8279
8280 sprintf(name, "%s Playback Volume", ctlname);
8281 if (nid == 0x14) {
8282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8283 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8284 HDA_OUTPUT));
8285 if (err < 0)
8286 return err;
8287 } else if (nid == 0x15) {
8288 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8289 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8290 HDA_OUTPUT));
8291 if (err < 0)
8292 return err;
8293 } else
8294 return -1;
8295 sprintf(name, "%s Playback Switch", ctlname);
8296 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8297 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8298 if (err < 0)
8299 return err;
8300 return 0;
8301}
8302
8303/* add playback controls from the parsed DAC table */
8304static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8305 const struct auto_pin_cfg *cfg)
8306{
8307 hda_nid_t nid;
8308 int err;
8309
8310 spec->multiout.num_dacs = 2; /* only use one dac */
8311 spec->multiout.dac_nids = spec->private_dac_nids;
8312 spec->multiout.dac_nids[0] = 2;
8313 spec->multiout.dac_nids[1] = 3;
8314
8315 nid = cfg->line_out_pins[0];
8316 if (nid)
8317 alc268_new_analog_output(spec, nid, "Front", 0);
8318
8319 nid = cfg->speaker_pins[0];
8320 if (nid == 0x1d) {
8321 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8322 "Speaker Playback Volume",
8323 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8324 if (err < 0)
8325 return err;
8326 }
8327 nid = cfg->hp_pins[0];
8328 if (nid)
8329 alc268_new_analog_output(spec, nid, "Headphone", 0);
8330
8331 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8332 if (nid == 0x16) {
8333 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8334 "Mono Playback Switch",
8335 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8336 if (err < 0)
8337 return err;
8338 }
8339 return 0;
8340}
8341
8342/* create playback/capture controls for input pins */
8343static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8344 const struct auto_pin_cfg *cfg)
8345{
8346 struct hda_input_mux *imux = &spec->private_imux;
8347 int i, idx1;
8348
8349 for (i = 0; i < AUTO_PIN_LAST; i++) {
8350 switch(cfg->input_pins[i]) {
8351 case 0x18:
8352 idx1 = 0; /* Mic 1 */
8353 break;
8354 case 0x19:
8355 idx1 = 1; /* Mic 2 */
8356 break;
8357 case 0x1a:
8358 idx1 = 2; /* Line In */
8359 break;
8360 case 0x1c:
8361 idx1 = 3; /* CD */
8362 break;
8363 default:
8364 continue;
8365 }
8366 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8367 imux->items[imux->num_items].index = idx1;
8368 imux->num_items++;
8369 }
8370 return 0;
8371}
8372
8373static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8374{
8375 struct alc_spec *spec = codec->spec;
8376 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8377 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8378 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8379 unsigned int dac_vol1, dac_vol2;
8380
8381 if (speaker_nid) {
8382 snd_hda_codec_write(codec, speaker_nid, 0,
8383 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8384 snd_hda_codec_write(codec, 0x0f, 0,
8385 AC_VERB_SET_AMP_GAIN_MUTE,
8386 AMP_IN_UNMUTE(1));
8387 snd_hda_codec_write(codec, 0x10, 0,
8388 AC_VERB_SET_AMP_GAIN_MUTE,
8389 AMP_IN_UNMUTE(1));
8390 } else {
8391 snd_hda_codec_write(codec, 0x0f, 0,
8392 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8393 snd_hda_codec_write(codec, 0x10, 0,
8394 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8395 }
8396
8397 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8398 if (line_nid == 0x14)
8399 dac_vol2 = AMP_OUT_ZERO;
8400 else if (line_nid == 0x15)
8401 dac_vol1 = AMP_OUT_ZERO;
8402 if (hp_nid == 0x14)
8403 dac_vol2 = AMP_OUT_ZERO;
8404 else if (hp_nid == 0x15)
8405 dac_vol1 = AMP_OUT_ZERO;
8406 if (line_nid != 0x16 || hp_nid != 0x16 ||
8407 spec->autocfg.line_out_pins[1] != 0x16 ||
8408 spec->autocfg.line_out_pins[2] != 0x16)
8409 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8410
8411 snd_hda_codec_write(codec, 0x02, 0,
8412 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8413 snd_hda_codec_write(codec, 0x03, 0,
8414 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8415}
8416
8417/* pcm configuration: identiacal with ALC880 */
8418#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8419#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8420#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8421
8422/*
8423 * BIOS auto configuration
8424 */
8425static int alc268_parse_auto_config(struct hda_codec *codec)
8426{
8427 struct alc_spec *spec = codec->spec;
8428 int err;
8429 static hda_nid_t alc268_ignore[] = { 0 };
8430
8431 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8432 alc268_ignore);
8433 if (err < 0)
8434 return err;
8435 if (!spec->autocfg.line_outs)
8436 return 0; /* can't find valid BIOS pin config */
8437
8438 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8439 if (err < 0)
8440 return err;
8441 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8442 if (err < 0)
8443 return err;
8444
8445 spec->multiout.max_channels = 2;
8446
8447 /* digital only support output */
8448 if (spec->autocfg.dig_out_pin)
8449 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8450
8451 if (spec->kctl_alloc)
8452 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8453
8454 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8455 spec->num_mux_defs = 1;
8456 spec->input_mux = &spec->private_imux;
8457
8458 return 1;
8459}
8460
8461#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8462#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8463#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8464
8465/* init callback for auto-configuration model -- overriding the default init */
8466static void alc268_auto_init(struct hda_codec *codec)
8467{
8468 alc268_auto_init_multi_out(codec);
8469 alc268_auto_init_hp_out(codec);
8470 alc268_auto_init_mono_speaker_out(codec);
8471 alc268_auto_init_analog_input(codec);
8472}
8473
8474/*
8475 * configuration and preset
8476 */
8477static const char *alc268_models[ALC268_MODEL_LAST] = {
8478 [ALC268_3ST] = "3stack",
8479 [ALC268_AUTO] = "auto",
8480};
8481
8482static struct snd_pci_quirk alc268_cfg_tbl[] = {
8483 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8484 {}
8485};
8486
8487static struct alc_config_preset alc268_presets[] = {
8488 [ALC268_3ST] = {
8489 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8490 .init_verbs = { alc268_base_init_verbs },
8491 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8492 .dac_nids = alc268_dac_nids,
8493 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8494 .adc_nids = alc268_adc_nids_alt,
8495 .hp_nid = 0x03,
8496 .dig_out_nid = ALC268_DIGOUT_NID,
8497 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8498 .channel_mode = alc268_modes,
8499 .input_mux = &alc268_capture_source,
8500 },
8501};
8502
8503static int patch_alc268(struct hda_codec *codec)
8504{
8505 struct alc_spec *spec;
8506 int board_config;
8507 int err;
8508
8509 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8510 if (spec == NULL)
8511 return -ENOMEM;
8512
8513 codec->spec = spec;
8514
8515 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8516 alc268_models,
8517 alc268_cfg_tbl);
8518
8519 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8520 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8521 "trying auto-probe from BIOS...\n");
8522 board_config = ALC268_AUTO;
8523 }
8524
8525 if (board_config == ALC268_AUTO) {
8526 /* automatic parse from the BIOS config */
8527 err = alc268_parse_auto_config(codec);
8528 if (err < 0) {
8529 alc_free(codec);
8530 return err;
8531 } else if (!err) {
8532 printk(KERN_INFO
8533 "hda_codec: Cannot set up configuration "
8534 "from BIOS. Using base mode...\n");
8535 board_config = ALC268_3ST;
8536 }
8537 }
8538
8539 if (board_config != ALC268_AUTO)
8540 setup_preset(spec, &alc268_presets[board_config]);
8541
8542 spec->stream_name_analog = "ALC268 Analog";
8543 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8544 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8545
8546 spec->stream_name_digital = "ALC268 Digital";
8547 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8548
8549 if (board_config == ALC268_AUTO) {
8550 if (!spec->adc_nids && spec->input_mux) {
8551 /* check whether NID 0x07 is valid */
8552 unsigned int wcap = get_wcaps(codec, 0x07);
8553
8554 /* get type */
8555 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8556 if (wcap != AC_WID_AUD_IN) {
8557 spec->adc_nids = alc268_adc_nids_alt;
8558 spec->num_adc_nids =
8559 ARRAY_SIZE(alc268_adc_nids_alt);
8560 spec->mixers[spec->num_mixers] =
8561 alc268_capture_alt_mixer;
8562 spec->num_mixers++;
8563 } else {
8564 spec->adc_nids = alc268_adc_nids;
8565 spec->num_adc_nids =
8566 ARRAY_SIZE(alc268_adc_nids);
8567 spec->mixers[spec->num_mixers] =
8568 alc268_capture_mixer;
8569 spec->num_mixers++;
8570 }
8571 }
8572 }
8573 codec->patch_ops = alc_patch_ops;
8574 if (board_config == ALC268_AUTO)
8575 spec->init_hook = alc268_auto_init;
8576
8577 return 0;
8578}
8579
8580/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008581 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8582 */
8583
8584/*
8585 * set the path ways for 2 channel output
8586 * need to set the codec line out and mic 1 pin widgets to inputs
8587 */
8588static struct hda_verb alc861_threestack_ch2_init[] = {
8589 /* set pin widget 1Ah (line in) for input */
8590 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008591 /* set pin widget 18h (mic1/2) for input, for mic also enable
8592 * the vref
8593 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008594 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8595
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008596 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8597#if 0
8598 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8599 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8600#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008601 { } /* end */
8602};
8603/*
8604 * 6ch mode
8605 * need to set the codec line out and mic 1 pin widgets to outputs
8606 */
8607static struct hda_verb alc861_threestack_ch6_init[] = {
8608 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8609 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8610 /* set pin widget 18h (mic1) for output (CLFE)*/
8611 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8612
8613 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008614 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008615
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008616 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8617#if 0
8618 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8619 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8620#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008621 { } /* end */
8622};
8623
8624static struct hda_channel_mode alc861_threestack_modes[2] = {
8625 { 2, alc861_threestack_ch2_init },
8626 { 6, alc861_threestack_ch6_init },
8627};
Takashi Iwai22309c32006-08-09 16:57:28 +02008628/* Set mic1 as input and unmute the mixer */
8629static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8630 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8631 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8632 { } /* end */
8633};
8634/* Set mic1 as output and mute mixer */
8635static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8636 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8637 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8638 { } /* end */
8639};
8640
8641static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8642 { 2, alc861_uniwill_m31_ch2_init },
8643 { 4, alc861_uniwill_m31_ch4_init },
8644};
Kailang Yangdf694da2005-12-05 19:42:22 +01008645
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008646/* Set mic1 and line-in as input and unmute the mixer */
8647static struct hda_verb alc861_asus_ch2_init[] = {
8648 /* set pin widget 1Ah (line in) for input */
8649 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008650 /* set pin widget 18h (mic1/2) for input, for mic also enable
8651 * the vref
8652 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008653 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8654
8655 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8656#if 0
8657 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8658 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8659#endif
8660 { } /* end */
8661};
8662/* Set mic1 nad line-in as output and mute mixer */
8663static struct hda_verb alc861_asus_ch6_init[] = {
8664 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8665 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8666 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8667 /* set pin widget 18h (mic1) for output (CLFE)*/
8668 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8669 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8670 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8671 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8672
8673 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8674#if 0
8675 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8676 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8677#endif
8678 { } /* end */
8679};
8680
8681static struct hda_channel_mode alc861_asus_modes[2] = {
8682 { 2, alc861_asus_ch2_init },
8683 { 6, alc861_asus_ch6_init },
8684};
8685
Kailang Yangdf694da2005-12-05 19:42:22 +01008686/* patch-ALC861 */
8687
8688static struct snd_kcontrol_new alc861_base_mixer[] = {
8689 /* output mixer control */
8690 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8691 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8692 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8693 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8694 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8695
8696 /*Input mixer control */
8697 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8698 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8699 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8700 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8701 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8702 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8704 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008707
Kailang Yangdf694da2005-12-05 19:42:22 +01008708 /* Capture mixer control */
8709 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8710 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8711 {
8712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8713 .name = "Capture Source",
8714 .count = 1,
8715 .info = alc_mux_enum_info,
8716 .get = alc_mux_enum_get,
8717 .put = alc_mux_enum_put,
8718 },
8719 { } /* end */
8720};
8721
8722static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8723 /* output mixer control */
8724 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8725 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8726 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8727 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8728 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8729
8730 /* Input mixer control */
8731 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8732 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8733 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8734 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8735 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8736 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8738 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8739 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008741
Kailang Yangdf694da2005-12-05 19:42:22 +01008742 /* Capture mixer control */
8743 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8744 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8745 {
8746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8747 .name = "Capture Source",
8748 .count = 1,
8749 .info = alc_mux_enum_info,
8750 .get = alc_mux_enum_get,
8751 .put = alc_mux_enum_put,
8752 },
8753 {
8754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8755 .name = "Channel Mode",
8756 .info = alc_ch_mode_info,
8757 .get = alc_ch_mode_get,
8758 .put = alc_ch_mode_put,
8759 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8760 },
8761 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008762};
8763
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008764static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008765 /* output mixer control */
8766 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8768 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8769
8770 /*Capture mixer control */
8771 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8772 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8773 {
8774 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8775 .name = "Capture Source",
8776 .count = 1,
8777 .info = alc_mux_enum_info,
8778 .get = alc_mux_enum_get,
8779 .put = alc_mux_enum_put,
8780 },
8781
8782 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008783};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008784
Takashi Iwai22309c32006-08-09 16:57:28 +02008785static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8786 /* output mixer control */
8787 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8788 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8789 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8790 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8791 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8792
8793 /* Input mixer control */
8794 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8795 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8796 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8797 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8798 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8799 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8801 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008804
Takashi Iwai22309c32006-08-09 16:57:28 +02008805 /* Capture mixer control */
8806 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8807 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8808 {
8809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8810 .name = "Capture Source",
8811 .count = 1,
8812 .info = alc_mux_enum_info,
8813 .get = alc_mux_enum_get,
8814 .put = alc_mux_enum_put,
8815 },
8816 {
8817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8818 .name = "Channel Mode",
8819 .info = alc_ch_mode_info,
8820 .get = alc_ch_mode_get,
8821 .put = alc_ch_mode_put,
8822 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8823 },
8824 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008825};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008826
8827static struct snd_kcontrol_new alc861_asus_mixer[] = {
8828 /* output mixer control */
8829 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8830 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8831 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8832 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8833 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8834
8835 /* Input mixer control */
8836 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8837 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8838 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8839 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8840 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8841 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8843 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8844 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8846
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008847 /* Capture mixer control */
8848 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8849 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8850 {
8851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8852 .name = "Capture Source",
8853 .count = 1,
8854 .info = alc_mux_enum_info,
8855 .get = alc_mux_enum_get,
8856 .put = alc_mux_enum_put,
8857 },
8858 {
8859 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8860 .name = "Channel Mode",
8861 .info = alc_ch_mode_info,
8862 .get = alc_ch_mode_get,
8863 .put = alc_ch_mode_put,
8864 .private_value = ARRAY_SIZE(alc861_asus_modes),
8865 },
8866 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008867};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008868
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008869/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008870static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008871 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8872 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8873 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8874 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8875 { }
8876};
8877
Kailang Yangdf694da2005-12-05 19:42:22 +01008878/*
8879 * generic initialization of ADC, input mixers and output mixers
8880 */
8881static struct hda_verb alc861_base_init_verbs[] = {
8882 /*
8883 * Unmute ADC0 and set the default input to mic-in
8884 */
8885 /* port-A for surround (rear panel) */
8886 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8887 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8888 /* port-B for mic-in (rear panel) with vref */
8889 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8890 /* port-C for line-in (rear panel) */
8891 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8892 /* port-D for Front */
8893 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8894 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8895 /* port-E for HP out (front panel) */
8896 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8897 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008898 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008899 /* port-F for mic-in (front panel) with vref */
8900 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8901 /* port-G for CLFE (rear panel) */
8902 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8903 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8904 /* port-H for side (rear panel) */
8905 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8906 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8907 /* CD-in */
8908 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8909 /* route front mic to ADC1*/
8910 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8911 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8912
8913 /* Unmute DAC0~3 & spdif out*/
8914 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8915 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8916 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8917 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8919
8920 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8921 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8922 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8923 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8924 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8925
8926 /* Unmute Stereo Mixer 15 */
8927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008931
8932 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8933 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8934 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8935 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8936 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8937 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8938 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8939 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008940 /* hp used DAC 3 (Front) */
8941 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008942 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8943
8944 { }
8945};
8946
8947static struct hda_verb alc861_threestack_init_verbs[] = {
8948 /*
8949 * Unmute ADC0 and set the default input to mic-in
8950 */
8951 /* port-A for surround (rear panel) */
8952 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8953 /* port-B for mic-in (rear panel) with vref */
8954 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8955 /* port-C for line-in (rear panel) */
8956 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8957 /* port-D for Front */
8958 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8959 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8960 /* port-E for HP out (front panel) */
8961 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8962 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008963 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008964 /* port-F for mic-in (front panel) with vref */
8965 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8966 /* port-G for CLFE (rear panel) */
8967 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8968 /* port-H for side (rear panel) */
8969 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8970 /* CD-in */
8971 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8972 /* route front mic to ADC1*/
8973 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8975 /* Unmute DAC0~3 & spdif out*/
8976 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8977 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8978 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8979 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8981
8982 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8983 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8984 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8985 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8986 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8987
8988 /* Unmute Stereo Mixer 15 */
8989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008992 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008993
8994 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8995 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8996 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8997 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8998 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8999 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9000 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9001 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009002 /* hp used DAC 3 (Front) */
9003 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9005 { }
9006};
Takashi Iwai22309c32006-08-09 16:57:28 +02009007
9008static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9009 /*
9010 * Unmute ADC0 and set the default input to mic-in
9011 */
9012 /* port-A for surround (rear panel) */
9013 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9014 /* port-B for mic-in (rear panel) with vref */
9015 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9016 /* port-C for line-in (rear panel) */
9017 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9018 /* port-D for Front */
9019 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9020 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9021 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009022 /* this has to be set to VREF80 */
9023 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009024 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009025 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009026 /* port-F for mic-in (front panel) with vref */
9027 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9028 /* port-G for CLFE (rear panel) */
9029 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9030 /* port-H for side (rear panel) */
9031 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9032 /* CD-in */
9033 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9034 /* route front mic to ADC1*/
9035 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9036 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9037 /* Unmute DAC0~3 & spdif out*/
9038 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9039 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9040 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9041 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9042 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9043
9044 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9045 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9046 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9047 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9048 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9049
9050 /* Unmute Stereo Mixer 15 */
9051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02009055
9056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9057 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9058 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9059 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9061 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9063 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009064 /* hp used DAC 3 (Front) */
9065 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9067 { }
9068};
9069
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009070static struct hda_verb alc861_asus_init_verbs[] = {
9071 /*
9072 * Unmute ADC0 and set the default input to mic-in
9073 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009074 /* port-A for surround (rear panel)
9075 * according to codec#0 this is the HP jack
9076 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009077 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9078 /* route front PCM to HP */
9079 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9080 /* port-B for mic-in (rear panel) with vref */
9081 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9082 /* port-C for line-in (rear panel) */
9083 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9084 /* port-D for Front */
9085 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9086 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9087 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009088 /* this has to be set to VREF80 */
9089 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009090 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009091 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009092 /* port-F for mic-in (front panel) with vref */
9093 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9094 /* port-G for CLFE (rear panel) */
9095 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9096 /* port-H for side (rear panel) */
9097 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9098 /* CD-in */
9099 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9100 /* route front mic to ADC1*/
9101 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9102 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9103 /* Unmute DAC0~3 & spdif out*/
9104 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9105 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9106 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9107 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9109 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9110 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9111 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9112 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9113 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9114
9115 /* Unmute Stereo Mixer 15 */
9116 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009120
9121 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9122 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9123 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9124 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9125 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9126 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9127 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9128 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009129 /* hp used DAC 3 (Front) */
9130 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009131 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9132 { }
9133};
9134
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009135/* additional init verbs for ASUS laptops */
9136static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9137 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9138 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9139 { }
9140};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009141
Kailang Yangdf694da2005-12-05 19:42:22 +01009142/*
9143 * generic initialization of ADC, input mixers and output mixers
9144 */
9145static struct hda_verb alc861_auto_init_verbs[] = {
9146 /*
9147 * Unmute ADC0 and set the default input to mic-in
9148 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009149 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9151
9152 /* Unmute DAC0~3 & spdif out*/
9153 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9154 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9155 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9156 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9158
9159 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9160 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9161 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9162 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9163 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9164
9165 /* Unmute Stereo Mixer 15 */
9166 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9167 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9168 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9169 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9170
9171 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9172 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9173 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9174 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9175 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9177 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9179
9180 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9181 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009184 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9185 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009186 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9187 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009188
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009189 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009190
9191 { }
9192};
9193
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009194static struct hda_verb alc861_toshiba_init_verbs[] = {
9195 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009196
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009197 { }
9198};
9199
9200/* toggle speaker-output according to the hp-jack state */
9201static void alc861_toshiba_automute(struct hda_codec *codec)
9202{
9203 unsigned int present;
9204
9205 present = snd_hda_codec_read(codec, 0x0f, 0,
9206 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9207 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
9208 0x80, present ? 0x80 : 0);
9209 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
9210 0x80, present ? 0x80 : 0);
9211 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
9212 0x80, present ? 0 : 0x80);
9213 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
9214 0x80, present ? 0 : 0x80);
9215}
9216
9217static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9218 unsigned int res)
9219{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009220 if ((res >> 26) == ALC880_HP_EVENT)
9221 alc861_toshiba_automute(codec);
9222}
9223
Kailang Yangdf694da2005-12-05 19:42:22 +01009224/* pcm configuration: identiacal with ALC880 */
9225#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9226#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9227#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9228#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9229
9230
9231#define ALC861_DIGOUT_NID 0x07
9232
9233static struct hda_channel_mode alc861_8ch_modes[1] = {
9234 { 8, NULL }
9235};
9236
9237static hda_nid_t alc861_dac_nids[4] = {
9238 /* front, surround, clfe, side */
9239 0x03, 0x06, 0x05, 0x04
9240};
9241
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009242static hda_nid_t alc660_dac_nids[3] = {
9243 /* front, clfe, surround */
9244 0x03, 0x05, 0x06
9245};
9246
Kailang Yangdf694da2005-12-05 19:42:22 +01009247static hda_nid_t alc861_adc_nids[1] = {
9248 /* ADC0-2 */
9249 0x08,
9250};
9251
9252static struct hda_input_mux alc861_capture_source = {
9253 .num_items = 5,
9254 .items = {
9255 { "Mic", 0x0 },
9256 { "Front Mic", 0x3 },
9257 { "Line", 0x1 },
9258 { "CD", 0x4 },
9259 { "Mixer", 0x5 },
9260 },
9261};
9262
9263/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009264static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9265 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009266{
9267 int i;
9268 hda_nid_t nid;
9269
9270 spec->multiout.dac_nids = spec->private_dac_nids;
9271 for (i = 0; i < cfg->line_outs; i++) {
9272 nid = cfg->line_out_pins[i];
9273 if (nid) {
9274 if (i >= ARRAY_SIZE(alc861_dac_nids))
9275 continue;
9276 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9277 }
9278 }
9279 spec->multiout.num_dacs = cfg->line_outs;
9280 return 0;
9281}
9282
9283/* add playback controls from the parsed DAC table */
9284static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9285 const struct auto_pin_cfg *cfg)
9286{
9287 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009288 static const char *chname[4] = {
9289 "Front", "Surround", NULL /*CLFE*/, "Side"
9290 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009291 hda_nid_t nid;
9292 int i, idx, err;
9293
9294 for (i = 0; i < cfg->line_outs; i++) {
9295 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009296 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009297 continue;
9298 if (nid == 0x05) {
9299 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009300 err = add_control(spec, ALC_CTL_BIND_MUTE,
9301 "Center Playback Switch",
9302 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9303 HDA_OUTPUT));
9304 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009305 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009306 err = add_control(spec, ALC_CTL_BIND_MUTE,
9307 "LFE Playback Switch",
9308 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9309 HDA_OUTPUT));
9310 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009311 return err;
9312 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009313 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9314 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009315 if (nid == alc861_dac_nids[idx])
9316 break;
9317 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009318 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9319 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9320 HDA_OUTPUT));
9321 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009322 return err;
9323 }
9324 }
9325 return 0;
9326}
9327
9328static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9329{
9330 int err;
9331 hda_nid_t nid;
9332
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009333 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009334 return 0;
9335
9336 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9337 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009338 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9339 "Headphone Playback Switch",
9340 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9341 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009342 return err;
9343 spec->multiout.hp_nid = nid;
9344 }
9345 return 0;
9346}
9347
9348/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009349static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9350 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009351{
Kailang Yangdf694da2005-12-05 19:42:22 +01009352 struct hda_input_mux *imux = &spec->private_imux;
9353 int i, err, idx, idx1;
9354
9355 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009356 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009357 case 0x0c:
9358 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009359 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009360 break;
9361 case 0x0f:
9362 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009363 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009364 break;
9365 case 0x0d:
9366 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009367 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009368 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009369 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009370 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009371 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009372 break;
9373 case 0x11:
9374 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009375 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009376 break;
9377 default:
9378 continue;
9379 }
9380
Takashi Iwai4a471b72005-12-07 13:56:29 +01009381 err = new_analog_input(spec, cfg->input_pins[i],
9382 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009383 if (err < 0)
9384 return err;
9385
Takashi Iwai4a471b72005-12-07 13:56:29 +01009386 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009387 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009388 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009389 }
9390 return 0;
9391}
9392
9393static struct snd_kcontrol_new alc861_capture_mixer[] = {
9394 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9395 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9396
9397 {
9398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9399 /* The multiple "Capture Source" controls confuse alsamixer
9400 * So call somewhat different..
9401 *FIXME: the controls appear in the "playback" view!
9402 */
9403 /* .name = "Capture Source", */
9404 .name = "Input Source",
9405 .count = 1,
9406 .info = alc_mux_enum_info,
9407 .get = alc_mux_enum_get,
9408 .put = alc_mux_enum_put,
9409 },
9410 { } /* end */
9411};
9412
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009413static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9414 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009415 int pin_type, int dac_idx)
9416{
9417 /* set as output */
9418
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009419 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9420 pin_type);
9421 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9422 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009423
9424}
9425
9426static void alc861_auto_init_multi_out(struct hda_codec *codec)
9427{
9428 struct alc_spec *spec = codec->spec;
9429 int i;
9430
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009431 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009432 for (i = 0; i < spec->autocfg.line_outs; i++) {
9433 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009434 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009435 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009436 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009437 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009438 }
9439}
9440
9441static void alc861_auto_init_hp_out(struct hda_codec *codec)
9442{
9443 struct alc_spec *spec = codec->spec;
9444 hda_nid_t pin;
9445
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009446 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009447 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009448 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9449 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009450}
9451
9452static void alc861_auto_init_analog_input(struct hda_codec *codec)
9453{
9454 struct alc_spec *spec = codec->spec;
9455 int i;
9456
9457 for (i = 0; i < AUTO_PIN_LAST; i++) {
9458 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009459 if (nid >= 0x0c && nid <= 0x11) {
9460 snd_hda_codec_write(codec, nid, 0,
9461 AC_VERB_SET_PIN_WIDGET_CONTROL,
9462 i <= AUTO_PIN_FRONT_MIC ?
9463 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 }
9465 }
9466}
9467
9468/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009469/* return 1 if successful, 0 if the proper config is not found,
9470 * or a negative error code
9471 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009472static int alc861_parse_auto_config(struct hda_codec *codec)
9473{
9474 struct alc_spec *spec = codec->spec;
9475 int err;
9476 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9477
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009478 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9479 alc861_ignore);
9480 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009481 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009482 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009483 return 0; /* can't find valid BIOS pin config */
9484
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009485 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9486 if (err < 0)
9487 return err;
9488 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9489 if (err < 0)
9490 return err;
9491 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9492 if (err < 0)
9493 return err;
9494 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9495 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009496 return err;
9497
9498 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9499
9500 if (spec->autocfg.dig_out_pin)
9501 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9502
9503 if (spec->kctl_alloc)
9504 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9505
9506 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9507
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009508 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009509 spec->input_mux = &spec->private_imux;
9510
9511 spec->adc_nids = alc861_adc_nids;
9512 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9513 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9514 spec->num_mixers++;
9515
9516 return 1;
9517}
9518
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009519/* additional initialization for auto-configuration model */
9520static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009521{
Kailang Yangdf694da2005-12-05 19:42:22 +01009522 alc861_auto_init_multi_out(codec);
9523 alc861_auto_init_hp_out(codec);
9524 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009525}
9526
9527
9528/*
9529 * configuration and preset
9530 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009531static const char *alc861_models[ALC861_MODEL_LAST] = {
9532 [ALC861_3ST] = "3stack",
9533 [ALC660_3ST] = "3stack-660",
9534 [ALC861_3ST_DIG] = "3stack-dig",
9535 [ALC861_6ST_DIG] = "6stack-dig",
9536 [ALC861_UNIWILL_M31] = "uniwill-m31",
9537 [ALC861_TOSHIBA] = "toshiba",
9538 [ALC861_ASUS] = "asus",
9539 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9540 [ALC861_AUTO] = "auto",
9541};
9542
9543static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009544 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009545 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9546 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009547 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +02009548 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009549 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +02009550 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +01009551 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +02009552 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9553 * Any other models that need this preset?
9554 */
9555 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009556 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009557 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009558 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009559 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009560 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009561 {}
9562};
9563
9564static struct alc_config_preset alc861_presets[] = {
9565 [ALC861_3ST] = {
9566 .mixers = { alc861_3ST_mixer },
9567 .init_verbs = { alc861_threestack_init_verbs },
9568 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9569 .dac_nids = alc861_dac_nids,
9570 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9571 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009572 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009573 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9574 .adc_nids = alc861_adc_nids,
9575 .input_mux = &alc861_capture_source,
9576 },
9577 [ALC861_3ST_DIG] = {
9578 .mixers = { alc861_base_mixer },
9579 .init_verbs = { alc861_threestack_init_verbs },
9580 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9581 .dac_nids = alc861_dac_nids,
9582 .dig_out_nid = ALC861_DIGOUT_NID,
9583 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9584 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009585 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009586 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9587 .adc_nids = alc861_adc_nids,
9588 .input_mux = &alc861_capture_source,
9589 },
9590 [ALC861_6ST_DIG] = {
9591 .mixers = { alc861_base_mixer },
9592 .init_verbs = { alc861_base_init_verbs },
9593 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9594 .dac_nids = alc861_dac_nids,
9595 .dig_out_nid = ALC861_DIGOUT_NID,
9596 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9597 .channel_mode = alc861_8ch_modes,
9598 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9599 .adc_nids = alc861_adc_nids,
9600 .input_mux = &alc861_capture_source,
9601 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009602 [ALC660_3ST] = {
9603 .mixers = { alc861_3ST_mixer },
9604 .init_verbs = { alc861_threestack_init_verbs },
9605 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9606 .dac_nids = alc660_dac_nids,
9607 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9608 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009609 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009610 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9611 .adc_nids = alc861_adc_nids,
9612 .input_mux = &alc861_capture_source,
9613 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009614 [ALC861_UNIWILL_M31] = {
9615 .mixers = { alc861_uniwill_m31_mixer },
9616 .init_verbs = { alc861_uniwill_m31_init_verbs },
9617 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9618 .dac_nids = alc861_dac_nids,
9619 .dig_out_nid = ALC861_DIGOUT_NID,
9620 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9621 .channel_mode = alc861_uniwill_m31_modes,
9622 .need_dac_fix = 1,
9623 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9624 .adc_nids = alc861_adc_nids,
9625 .input_mux = &alc861_capture_source,
9626 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009627 [ALC861_TOSHIBA] = {
9628 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009629 .init_verbs = { alc861_base_init_verbs,
9630 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009631 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9632 .dac_nids = alc861_dac_nids,
9633 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9634 .channel_mode = alc883_3ST_2ch_modes,
9635 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9636 .adc_nids = alc861_adc_nids,
9637 .input_mux = &alc861_capture_source,
9638 .unsol_event = alc861_toshiba_unsol_event,
9639 .init_hook = alc861_toshiba_automute,
9640 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009641 [ALC861_ASUS] = {
9642 .mixers = { alc861_asus_mixer },
9643 .init_verbs = { alc861_asus_init_verbs },
9644 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9645 .dac_nids = alc861_dac_nids,
9646 .dig_out_nid = ALC861_DIGOUT_NID,
9647 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9648 .channel_mode = alc861_asus_modes,
9649 .need_dac_fix = 1,
9650 .hp_nid = 0x06,
9651 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9652 .adc_nids = alc861_adc_nids,
9653 .input_mux = &alc861_capture_source,
9654 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009655 [ALC861_ASUS_LAPTOP] = {
9656 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9657 .init_verbs = { alc861_asus_init_verbs,
9658 alc861_asus_laptop_init_verbs },
9659 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9660 .dac_nids = alc861_dac_nids,
9661 .dig_out_nid = ALC861_DIGOUT_NID,
9662 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9663 .channel_mode = alc883_3ST_2ch_modes,
9664 .need_dac_fix = 1,
9665 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9666 .adc_nids = alc861_adc_nids,
9667 .input_mux = &alc861_capture_source,
9668 },
9669};
Kailang Yangdf694da2005-12-05 19:42:22 +01009670
9671
9672static int patch_alc861(struct hda_codec *codec)
9673{
9674 struct alc_spec *spec;
9675 int board_config;
9676 int err;
9677
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009678 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009679 if (spec == NULL)
9680 return -ENOMEM;
9681
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009682 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009683
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009684 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9685 alc861_models,
9686 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009687
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009688 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009689 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9690 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009691 board_config = ALC861_AUTO;
9692 }
9693
9694 if (board_config == ALC861_AUTO) {
9695 /* automatic parse from the BIOS config */
9696 err = alc861_parse_auto_config(codec);
9697 if (err < 0) {
9698 alc_free(codec);
9699 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009700 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009701 printk(KERN_INFO
9702 "hda_codec: Cannot set up configuration "
9703 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009704 board_config = ALC861_3ST_DIG;
9705 }
9706 }
9707
9708 if (board_config != ALC861_AUTO)
9709 setup_preset(spec, &alc861_presets[board_config]);
9710
9711 spec->stream_name_analog = "ALC861 Analog";
9712 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9713 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9714
9715 spec->stream_name_digital = "ALC861 Digital";
9716 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9717 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9718
9719 codec->patch_ops = alc_patch_ops;
9720 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009721 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009722
9723 return 0;
9724}
9725
9726/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009727 * ALC861-VD support
9728 *
9729 * Based on ALC882
9730 *
9731 * In addition, an independent DAC
9732 */
9733#define ALC861VD_DIGOUT_NID 0x06
9734
9735static hda_nid_t alc861vd_dac_nids[4] = {
9736 /* front, surr, clfe, side surr */
9737 0x02, 0x03, 0x04, 0x05
9738};
9739
9740/* dac_nids for ALC660vd are in a different order - according to
9741 * Realtek's driver.
9742 * This should probably tesult in a different mixer for 6stack models
9743 * of ALC660vd codecs, but for now there is only 3stack mixer
9744 * - and it is the same as in 861vd.
9745 * adc_nids in ALC660vd are (is) the same as in 861vd
9746 */
9747static hda_nid_t alc660vd_dac_nids[3] = {
9748 /* front, rear, clfe, rear_surr */
9749 0x02, 0x04, 0x03
9750};
9751
9752static hda_nid_t alc861vd_adc_nids[1] = {
9753 /* ADC0 */
9754 0x09,
9755};
9756
9757/* input MUX */
9758/* FIXME: should be a matrix-type input source selection */
9759static struct hda_input_mux alc861vd_capture_source = {
9760 .num_items = 4,
9761 .items = {
9762 { "Mic", 0x0 },
9763 { "Front Mic", 0x1 },
9764 { "Line", 0x2 },
9765 { "CD", 0x4 },
9766 },
9767};
9768
Kailang Yang272a5272007-05-14 11:00:38 +02009769static struct hda_input_mux alc861vd_dallas_capture_source = {
9770 .num_items = 3,
9771 .items = {
9772 { "Front Mic", 0x0 },
9773 { "ATAPI Mic", 0x1 },
9774 { "Line In", 0x5 },
9775 },
9776};
9777
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009778#define alc861vd_mux_enum_info alc_mux_enum_info
9779#define alc861vd_mux_enum_get alc_mux_enum_get
9780
9781static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9782 struct snd_ctl_elem_value *ucontrol)
9783{
9784 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9785 struct alc_spec *spec = codec->spec;
9786 const struct hda_input_mux *imux = spec->input_mux;
9787 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9788 static hda_nid_t capture_mixers[1] = { 0x22 };
9789 hda_nid_t nid = capture_mixers[adc_idx];
9790 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9791 unsigned int i, idx;
9792
9793 idx = ucontrol->value.enumerated.item[0];
9794 if (idx >= imux->num_items)
9795 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009796 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009797 return 0;
9798 for (i = 0; i < imux->num_items; i++) {
9799 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9800 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9801 v | (imux->items[i].index << 8));
9802 }
9803 *cur_val = idx;
9804 return 1;
9805}
9806
9807/*
9808 * 2ch mode
9809 */
9810static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9811 { 2, NULL }
9812};
9813
9814/*
9815 * 6ch mode
9816 */
9817static struct hda_verb alc861vd_6stack_ch6_init[] = {
9818 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9819 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9820 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9821 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9822 { } /* end */
9823};
9824
9825/*
9826 * 8ch mode
9827 */
9828static struct hda_verb alc861vd_6stack_ch8_init[] = {
9829 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9830 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9831 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9832 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9833 { } /* end */
9834};
9835
9836static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9837 { 6, alc861vd_6stack_ch6_init },
9838 { 8, alc861vd_6stack_ch8_init },
9839};
9840
9841static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9842 {
9843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9844 .name = "Channel Mode",
9845 .info = alc_ch_mode_info,
9846 .get = alc_ch_mode_get,
9847 .put = alc_ch_mode_put,
9848 },
9849 { } /* end */
9850};
9851
9852static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9853 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9854 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9855
9856 {
9857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9858 /* The multiple "Capture Source" controls confuse alsamixer
9859 * So call somewhat different..
9860 *FIXME: the controls appear in the "playback" view!
9861 */
9862 /* .name = "Capture Source", */
9863 .name = "Input Source",
9864 .count = 1,
9865 .info = alc861vd_mux_enum_info,
9866 .get = alc861vd_mux_enum_get,
9867 .put = alc861vd_mux_enum_put,
9868 },
9869 { } /* end */
9870};
9871
9872/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9873 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9874 */
9875static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9876 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9878
9879 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9880 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9881
9882 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9883 HDA_OUTPUT),
9884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9885 HDA_OUTPUT),
9886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9888
9889 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9890 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9891
9892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9893
9894 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9897
9898 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9900 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9901
9902 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9903 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9904
9905 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9906 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9907
9908 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9909 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9910
9911 { } /* end */
9912};
9913
9914static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9915 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9916 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9917
9918 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9919
9920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9923
9924 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9925 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9926 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9927
9928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9930
9931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9933
9934 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9935 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9936
9937 { } /* end */
9938};
9939
Kailang Yangbdd148a2007-05-08 15:19:08 +02009940static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9941 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9942 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9943 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9944
9945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9946
9947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9950
9951 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9952 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9953 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9954
9955 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9956 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9957
9958 { } /* end */
9959};
9960
Kailang Yang272a5272007-05-14 11:00:38 +02009961/* Pin assignment: Front=0x14, HP = 0x15,
9962 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9963 */
9964static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9965 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9966 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9968 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9969 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9970 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9971 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9972 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9973 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9974 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9975 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9976 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9977 {
9978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9979 /* .name = "Capture Source", */
9980 .name = "Input Source",
9981 .count = 1,
9982 .info = alc882_mux_enum_info,
9983 .get = alc882_mux_enum_get,
9984 .put = alc882_mux_enum_put,
9985 },
9986 { } /* end */
9987};
9988
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009989/*
9990 * generic initialization of ADC, input mixers and output mixers
9991 */
9992static struct hda_verb alc861vd_volume_init_verbs[] = {
9993 /*
9994 * Unmute ADC0 and set the default input to mic-in
9995 */
9996 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9997 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9998
9999 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10000 * the analog-loopback mixer widget
10001 */
10002 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10008
10009 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020010010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010014
10015 /*
10016 * Set up output mixers (0x02 - 0x05)
10017 */
10018 /* set vol=0 to output mixers */
10019 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10020 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10021 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10022 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10023
10024 /* set up input amps for analog loopback */
10025 /* Amp Indices: DAC = 0, mixer = 1 */
10026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10031 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10032 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10033 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10034
10035 { }
10036};
10037
10038/*
10039 * 3-stack pin configuration:
10040 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10041 */
10042static struct hda_verb alc861vd_3stack_init_verbs[] = {
10043 /*
10044 * Set pin mode and muting
10045 */
10046 /* set front pin widgets 0x14 for output */
10047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10049 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10050
10051 /* Mic (rear) pin: input vref at 80% */
10052 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10054 /* Front Mic pin: input vref at 80% */
10055 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10056 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10057 /* Line In pin: input */
10058 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10059 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10060 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10063 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10064 /* CD pin widget for input */
10065 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10066
10067 { }
10068};
10069
10070/*
10071 * 6-stack pin configuration:
10072 */
10073static struct hda_verb alc861vd_6stack_init_verbs[] = {
10074 /*
10075 * Set pin mode and muting
10076 */
10077 /* set front pin widgets 0x14 for output */
10078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10079 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10080 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10081
10082 /* Rear Pin: output 1 (0x0d) */
10083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10084 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10085 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10086 /* CLFE Pin: output 2 (0x0e) */
10087 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10088 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10089 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10090 /* Side Pin: output 3 (0x0f) */
10091 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10093 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10094
10095 /* Mic (rear) pin: input vref at 80% */
10096 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10097 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10098 /* Front Mic pin: input vref at 80% */
10099 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10100 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10101 /* Line In pin: input */
10102 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10103 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10104 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10105 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10106 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10107 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10108 /* CD pin widget for input */
10109 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10110
10111 { }
10112};
10113
Kailang Yangbdd148a2007-05-08 15:19:08 +020010114static struct hda_verb alc861vd_eapd_verbs[] = {
10115 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10116 { }
10117};
10118
10119static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10120 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10123 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10124 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10125 {}
10126};
10127
10128/* toggle speaker-output according to the hp-jack state */
10129static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10130{
10131 unsigned int present;
10132 unsigned char bits;
10133
10134 present = snd_hda_codec_read(codec, 0x1b, 0,
10135 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10136 bits = present ? 0x80 : 0;
10137 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10138 0x80, bits);
10139 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10140 0x80, bits);
10141}
10142
10143static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10144{
10145 unsigned int present;
10146 unsigned char bits;
10147
10148 present = snd_hda_codec_read(codec, 0x18, 0,
10149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10150 bits = present ? 0x80 : 0;
10151 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10152 0x80, bits);
10153 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10154 0x80, bits);
10155}
10156
10157static void alc861vd_lenovo_automute(struct hda_codec *codec)
10158{
10159 alc861vd_lenovo_hp_automute(codec);
10160 alc861vd_lenovo_mic_automute(codec);
10161}
10162
10163static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10164 unsigned int res)
10165{
10166 switch (res >> 26) {
10167 case ALC880_HP_EVENT:
10168 alc861vd_lenovo_hp_automute(codec);
10169 break;
10170 case ALC880_MIC_EVENT:
10171 alc861vd_lenovo_mic_automute(codec);
10172 break;
10173 }
10174}
10175
Kailang Yang272a5272007-05-14 11:00:38 +020010176static struct hda_verb alc861vd_dallas_verbs[] = {
10177 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10178 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10179 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10180 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10181
10182 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10183 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10184 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10185 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10186 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10187 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10188 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10189 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10190
10191 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10192 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10195 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10197 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10198 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10199
10200 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10202 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10204 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10207 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10208
10209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10213
10214 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10215 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10216 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10217
10218 { } /* end */
10219};
10220
10221/* toggle speaker-output according to the hp-jack state */
10222static void alc861vd_dallas_automute(struct hda_codec *codec)
10223{
10224 unsigned int present;
10225
10226 present = snd_hda_codec_read(codec, 0x15, 0,
10227 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10228 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10229 0x80, present ? 0x80 : 0);
10230 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10231 0x80, present ? 0x80 : 0);
10232}
10233
10234static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10235{
10236 if ((res >> 26) == ALC880_HP_EVENT)
10237 alc861vd_dallas_automute(codec);
10238}
10239
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010240/* pcm configuration: identiacal with ALC880 */
10241#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10242#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10243#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10244#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10245
10246/*
10247 * configuration and preset
10248 */
10249static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10250 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +020010251 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010252 [ALC861VD_3ST] = "3stack",
10253 [ALC861VD_3ST_DIG] = "3stack-digout",
10254 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010255 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010256 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010257 [ALC861VD_AUTO] = "auto",
10258};
10259
10260static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010261 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010262 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010263 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010264 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10265 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10266
Kailang Yang272a5272007-05-14 11:00:38 +020010267 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10268 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010269 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10270 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010271 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010272 {}
10273};
10274
10275static struct alc_config_preset alc861vd_presets[] = {
10276 [ALC660VD_3ST] = {
10277 .mixers = { alc861vd_3st_mixer },
10278 .init_verbs = { alc861vd_volume_init_verbs,
10279 alc861vd_3stack_init_verbs },
10280 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10281 .dac_nids = alc660vd_dac_nids,
10282 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10283 .adc_nids = alc861vd_adc_nids,
10284 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10285 .channel_mode = alc861vd_3stack_2ch_modes,
10286 .input_mux = &alc861vd_capture_source,
10287 },
Mike Crash6963f842007-06-25 12:12:51 +020010288 [ALC660VD_3ST_DIG] = {
10289 .mixers = { alc861vd_3st_mixer },
10290 .init_verbs = { alc861vd_volume_init_verbs,
10291 alc861vd_3stack_init_verbs },
10292 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10293 .dac_nids = alc660vd_dac_nids,
10294 .dig_out_nid = ALC861VD_DIGOUT_NID,
10295 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10296 .adc_nids = alc861vd_adc_nids,
10297 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10298 .channel_mode = alc861vd_3stack_2ch_modes,
10299 .input_mux = &alc861vd_capture_source,
10300 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010301 [ALC861VD_3ST] = {
10302 .mixers = { alc861vd_3st_mixer },
10303 .init_verbs = { alc861vd_volume_init_verbs,
10304 alc861vd_3stack_init_verbs },
10305 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10306 .dac_nids = alc861vd_dac_nids,
10307 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10308 .channel_mode = alc861vd_3stack_2ch_modes,
10309 .input_mux = &alc861vd_capture_source,
10310 },
10311 [ALC861VD_3ST_DIG] = {
10312 .mixers = { alc861vd_3st_mixer },
10313 .init_verbs = { alc861vd_volume_init_verbs,
10314 alc861vd_3stack_init_verbs },
10315 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10316 .dac_nids = alc861vd_dac_nids,
10317 .dig_out_nid = ALC861VD_DIGOUT_NID,
10318 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10319 .channel_mode = alc861vd_3stack_2ch_modes,
10320 .input_mux = &alc861vd_capture_source,
10321 },
10322 [ALC861VD_6ST_DIG] = {
10323 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10324 .init_verbs = { alc861vd_volume_init_verbs,
10325 alc861vd_6stack_init_verbs },
10326 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10327 .dac_nids = alc861vd_dac_nids,
10328 .dig_out_nid = ALC861VD_DIGOUT_NID,
10329 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10330 .channel_mode = alc861vd_6stack_modes,
10331 .input_mux = &alc861vd_capture_source,
10332 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010333 [ALC861VD_LENOVO] = {
10334 .mixers = { alc861vd_lenovo_mixer },
10335 .init_verbs = { alc861vd_volume_init_verbs,
10336 alc861vd_3stack_init_verbs,
10337 alc861vd_eapd_verbs,
10338 alc861vd_lenovo_unsol_verbs },
10339 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10340 .dac_nids = alc660vd_dac_nids,
10341 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10342 .adc_nids = alc861vd_adc_nids,
10343 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10344 .channel_mode = alc861vd_3stack_2ch_modes,
10345 .input_mux = &alc861vd_capture_source,
10346 .unsol_event = alc861vd_lenovo_unsol_event,
10347 .init_hook = alc861vd_lenovo_automute,
10348 },
Kailang Yang272a5272007-05-14 11:00:38 +020010349 [ALC861VD_DALLAS] = {
10350 .mixers = { alc861vd_dallas_mixer },
10351 .init_verbs = { alc861vd_dallas_verbs },
10352 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10353 .dac_nids = alc861vd_dac_nids,
10354 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10355 .adc_nids = alc861vd_adc_nids,
10356 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10357 .channel_mode = alc861vd_3stack_2ch_modes,
10358 .input_mux = &alc861vd_dallas_capture_source,
10359 .unsol_event = alc861vd_dallas_unsol_event,
10360 .init_hook = alc861vd_dallas_automute,
10361 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010362};
10363
10364/*
10365 * BIOS auto configuration
10366 */
10367static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10368 hda_nid_t nid, int pin_type, int dac_idx)
10369{
10370 /* set as output */
10371 snd_hda_codec_write(codec, nid, 0,
10372 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10373 snd_hda_codec_write(codec, nid, 0,
10374 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10375}
10376
10377static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10378{
10379 struct alc_spec *spec = codec->spec;
10380 int i;
10381
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010382 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010383 for (i = 0; i <= HDA_SIDE; i++) {
10384 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010385 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010386 if (nid)
10387 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010388 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010389 }
10390}
10391
10392
10393static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10394{
10395 struct alc_spec *spec = codec->spec;
10396 hda_nid_t pin;
10397
10398 pin = spec->autocfg.hp_pins[0];
10399 if (pin) /* connect to front and use dac 0 */
10400 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10401}
10402
10403#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10404#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10405
10406static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10407{
10408 struct alc_spec *spec = codec->spec;
10409 int i;
10410
10411 for (i = 0; i < AUTO_PIN_LAST; i++) {
10412 hda_nid_t nid = spec->autocfg.input_pins[i];
10413 if (alc861vd_is_input_pin(nid)) {
10414 snd_hda_codec_write(codec, nid, 0,
10415 AC_VERB_SET_PIN_WIDGET_CONTROL,
10416 i <= AUTO_PIN_FRONT_MIC ?
10417 PIN_VREF80 : PIN_IN);
10418 if (nid != ALC861VD_PIN_CD_NID)
10419 snd_hda_codec_write(codec, nid, 0,
10420 AC_VERB_SET_AMP_GAIN_MUTE,
10421 AMP_OUT_MUTE);
10422 }
10423 }
10424}
10425
10426#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10427#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10428
10429/* add playback controls from the parsed DAC table */
10430/* Based on ALC880 version. But ALC861VD has separate,
10431 * different NIDs for mute/unmute switch and volume control */
10432static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10433 const struct auto_pin_cfg *cfg)
10434{
10435 char name[32];
10436 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10437 hda_nid_t nid_v, nid_s;
10438 int i, err;
10439
10440 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010441 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010442 continue;
10443 nid_v = alc861vd_idx_to_mixer_vol(
10444 alc880_dac_to_idx(
10445 spec->multiout.dac_nids[i]));
10446 nid_s = alc861vd_idx_to_mixer_switch(
10447 alc880_dac_to_idx(
10448 spec->multiout.dac_nids[i]));
10449
10450 if (i == 2) {
10451 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010452 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10453 "Center Playback Volume",
10454 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10455 HDA_OUTPUT));
10456 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010457 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010458 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10459 "LFE Playback Volume",
10460 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10461 HDA_OUTPUT));
10462 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010463 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010464 err = add_control(spec, ALC_CTL_BIND_MUTE,
10465 "Center Playback Switch",
10466 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10467 HDA_INPUT));
10468 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010469 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010470 err = add_control(spec, ALC_CTL_BIND_MUTE,
10471 "LFE Playback Switch",
10472 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10473 HDA_INPUT));
10474 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010475 return err;
10476 } else {
10477 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010478 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10479 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10480 HDA_OUTPUT));
10481 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010482 return err;
10483 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010484 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010485 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010486 HDA_INPUT));
10487 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010488 return err;
10489 }
10490 }
10491 return 0;
10492}
10493
10494/* add playback controls for speaker and HP outputs */
10495/* Based on ALC880 version. But ALC861VD has separate,
10496 * different NIDs for mute/unmute switch and volume control */
10497static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10498 hda_nid_t pin, const char *pfx)
10499{
10500 hda_nid_t nid_v, nid_s;
10501 int err;
10502 char name[32];
10503
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010504 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010505 return 0;
10506
10507 if (alc880_is_fixed_pin(pin)) {
10508 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10509 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010510 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010511 spec->multiout.hp_nid = nid_v;
10512 else
10513 spec->multiout.extra_out_nid[0] = nid_v;
10514 /* control HP volume/switch on the output mixer amp */
10515 nid_v = alc861vd_idx_to_mixer_vol(
10516 alc880_fixed_pin_idx(pin));
10517 nid_s = alc861vd_idx_to_mixer_switch(
10518 alc880_fixed_pin_idx(pin));
10519
10520 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010521 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10522 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10523 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010524 return err;
10525 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010526 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10527 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10528 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010529 return err;
10530 } else if (alc880_is_multi_pin(pin)) {
10531 /* set manual connection */
10532 /* we have only a switch on HP-out PIN */
10533 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010534 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10535 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10536 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010537 return err;
10538 }
10539 return 0;
10540}
10541
10542/* parse the BIOS configuration and set up the alc_spec
10543 * return 1 if successful, 0 if the proper config is not found,
10544 * or a negative error code
10545 * Based on ALC880 version - had to change it to override
10546 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10547static int alc861vd_parse_auto_config(struct hda_codec *codec)
10548{
10549 struct alc_spec *spec = codec->spec;
10550 int err;
10551 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10552
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10554 alc861vd_ignore);
10555 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010557 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010558 return 0; /* can't find valid BIOS pin config */
10559
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010560 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10561 if (err < 0)
10562 return err;
10563 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10564 if (err < 0)
10565 return err;
10566 err = alc861vd_auto_create_extra_out(spec,
10567 spec->autocfg.speaker_pins[0],
10568 "Speaker");
10569 if (err < 0)
10570 return err;
10571 err = alc861vd_auto_create_extra_out(spec,
10572 spec->autocfg.hp_pins[0],
10573 "Headphone");
10574 if (err < 0)
10575 return err;
10576 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10577 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010578 return err;
10579
10580 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10581
10582 if (spec->autocfg.dig_out_pin)
10583 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10584
10585 if (spec->kctl_alloc)
10586 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10587
10588 spec->init_verbs[spec->num_init_verbs++]
10589 = alc861vd_volume_init_verbs;
10590
10591 spec->num_mux_defs = 1;
10592 spec->input_mux = &spec->private_imux;
10593
10594 return 1;
10595}
10596
10597/* additional initialization for auto-configuration model */
10598static void alc861vd_auto_init(struct hda_codec *codec)
10599{
10600 alc861vd_auto_init_multi_out(codec);
10601 alc861vd_auto_init_hp_out(codec);
10602 alc861vd_auto_init_analog_input(codec);
10603}
10604
10605static int patch_alc861vd(struct hda_codec *codec)
10606{
10607 struct alc_spec *spec;
10608 int err, board_config;
10609
10610 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10611 if (spec == NULL)
10612 return -ENOMEM;
10613
10614 codec->spec = spec;
10615
10616 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10617 alc861vd_models,
10618 alc861vd_cfg_tbl);
10619
10620 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10621 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10622 "ALC861VD, trying auto-probe from BIOS...\n");
10623 board_config = ALC861VD_AUTO;
10624 }
10625
10626 if (board_config == ALC861VD_AUTO) {
10627 /* automatic parse from the BIOS config */
10628 err = alc861vd_parse_auto_config(codec);
10629 if (err < 0) {
10630 alc_free(codec);
10631 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010632 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010633 printk(KERN_INFO
10634 "hda_codec: Cannot set up configuration "
10635 "from BIOS. Using base mode...\n");
10636 board_config = ALC861VD_3ST;
10637 }
10638 }
10639
10640 if (board_config != ALC861VD_AUTO)
10641 setup_preset(spec, &alc861vd_presets[board_config]);
10642
10643 spec->stream_name_analog = "ALC861VD Analog";
10644 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10645 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10646
10647 spec->stream_name_digital = "ALC861VD Digital";
10648 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10649 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10650
10651 spec->adc_nids = alc861vd_adc_nids;
10652 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10653
10654 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10655 spec->num_mixers++;
10656
10657 codec->patch_ops = alc_patch_ops;
10658
10659 if (board_config == ALC861VD_AUTO)
10660 spec->init_hook = alc861vd_auto_init;
10661
10662 return 0;
10663}
10664
10665/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010666 * ALC662 support
10667 *
10668 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10669 * configuration. Each pin widget can choose any input DACs and a mixer.
10670 * Each ADC is connected from a mixer of all inputs. This makes possible
10671 * 6-channel independent captures.
10672 *
10673 * In addition, an independent DAC for the multi-playback (not used in this
10674 * driver yet).
10675 */
10676#define ALC662_DIGOUT_NID 0x06
10677#define ALC662_DIGIN_NID 0x0a
10678
10679static hda_nid_t alc662_dac_nids[4] = {
10680 /* front, rear, clfe, rear_surr */
10681 0x02, 0x03, 0x04
10682};
10683
10684static hda_nid_t alc662_adc_nids[1] = {
10685 /* ADC1-2 */
10686 0x09,
10687};
10688/* input MUX */
10689/* FIXME: should be a matrix-type input source selection */
10690
10691static struct hda_input_mux alc662_capture_source = {
10692 .num_items = 4,
10693 .items = {
10694 { "Mic", 0x0 },
10695 { "Front Mic", 0x1 },
10696 { "Line", 0x2 },
10697 { "CD", 0x4 },
10698 },
10699};
10700
10701static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10702 .num_items = 2,
10703 .items = {
10704 { "Mic", 0x1 },
10705 { "Line", 0x2 },
10706 },
10707};
10708#define alc662_mux_enum_info alc_mux_enum_info
10709#define alc662_mux_enum_get alc_mux_enum_get
10710
10711static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10712 struct snd_ctl_elem_value *ucontrol)
10713{
10714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10715 struct alc_spec *spec = codec->spec;
10716 const struct hda_input_mux *imux = spec->input_mux;
10717 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10718 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10719 hda_nid_t nid = capture_mixers[adc_idx];
10720 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10721 unsigned int i, idx;
10722
10723 idx = ucontrol->value.enumerated.item[0];
10724 if (idx >= imux->num_items)
10725 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010726 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010727 return 0;
10728 for (i = 0; i < imux->num_items; i++) {
10729 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10730 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10731 v | (imux->items[i].index << 8));
10732 }
10733 *cur_val = idx;
10734 return 1;
10735}
10736/*
10737 * 2ch mode
10738 */
10739static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10740 { 2, NULL }
10741};
10742
10743/*
10744 * 2ch mode
10745 */
10746static struct hda_verb alc662_3ST_ch2_init[] = {
10747 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10748 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10749 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10750 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10751 { } /* end */
10752};
10753
10754/*
10755 * 6ch mode
10756 */
10757static struct hda_verb alc662_3ST_ch6_init[] = {
10758 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10759 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10760 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10761 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10762 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10763 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10764 { } /* end */
10765};
10766
10767static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10768 { 2, alc662_3ST_ch2_init },
10769 { 6, alc662_3ST_ch6_init },
10770};
10771
10772/*
10773 * 2ch mode
10774 */
10775static struct hda_verb alc662_sixstack_ch6_init[] = {
10776 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10777 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10778 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10779 { } /* end */
10780};
10781
10782/*
10783 * 6ch mode
10784 */
10785static struct hda_verb alc662_sixstack_ch8_init[] = {
10786 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10787 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10788 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10789 { } /* end */
10790};
10791
10792static struct hda_channel_mode alc662_5stack_modes[2] = {
10793 { 2, alc662_sixstack_ch6_init },
10794 { 6, alc662_sixstack_ch8_init },
10795};
10796
10797/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10798 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10799 */
10800
10801static struct snd_kcontrol_new alc662_base_mixer[] = {
10802 /* output mixer control */
10803 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10804 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10805 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10806 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10807 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10808 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10809 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10810 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10812
10813 /*Input mixer control */
10814 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10815 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10816 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10817 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10818 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10819 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10820 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10821 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10822
10823 /* Capture mixer control */
10824 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10825 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10826 {
10827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10828 .name = "Capture Source",
10829 .count = 1,
10830 .info = alc_mux_enum_info,
10831 .get = alc_mux_enum_get,
10832 .put = alc_mux_enum_put,
10833 },
10834 { } /* end */
10835};
10836
10837static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10838 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10839 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10840 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10841 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10842 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10843 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10844 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10847 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10848 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10849 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10850 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10851 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10852 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10853 {
10854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10855 /* .name = "Capture Source", */
10856 .name = "Input Source",
10857 .count = 1,
10858 .info = alc662_mux_enum_info,
10859 .get = alc662_mux_enum_get,
10860 .put = alc662_mux_enum_put,
10861 },
10862 { } /* end */
10863};
10864
10865static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10866 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10867 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10868 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10869 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10870 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10871 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10872 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10873 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10875 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10876 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10877 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10878 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10881 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10882 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10883 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10884 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10885 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10886 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10887 {
10888 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10889 /* .name = "Capture Source", */
10890 .name = "Input Source",
10891 .count = 1,
10892 .info = alc662_mux_enum_info,
10893 .get = alc662_mux_enum_get,
10894 .put = alc662_mux_enum_put,
10895 },
10896 { } /* end */
10897};
10898
10899static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10900 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10901 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10902 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10903 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10905 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10906 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10909 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10910 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10911 {
10912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10913 /* .name = "Capture Source", */
10914 .name = "Input Source",
10915 .count = 1,
10916 .info = alc662_mux_enum_info,
10917 .get = alc662_mux_enum_get,
10918 .put = alc662_mux_enum_put,
10919 },
10920 { } /* end */
10921};
10922
10923static struct snd_kcontrol_new alc662_chmode_mixer[] = {
10924 {
10925 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10926 .name = "Channel Mode",
10927 .info = alc_ch_mode_info,
10928 .get = alc_ch_mode_get,
10929 .put = alc_ch_mode_put,
10930 },
10931 { } /* end */
10932};
10933
10934static struct hda_verb alc662_init_verbs[] = {
10935 /* ADC: mute amp left and right */
10936 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10937 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10938 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10939
10940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10945
10946 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10947 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10948 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10949 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10950 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10951 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10952
10953 /* Front Pin: output 0 (0x0c) */
10954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10956
10957 /* Rear Pin: output 1 (0x0d) */
10958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10960
10961 /* CLFE Pin: output 2 (0x0e) */
10962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10964
10965 /* Mic (rear) pin: input vref at 80% */
10966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10967 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10968 /* Front Mic pin: input vref at 80% */
10969 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10970 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10971 /* Line In pin: input */
10972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10973 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10974 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10975 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10976 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10977 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10978 /* CD pin widget for input */
10979 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10980
10981 /* FIXME: use matrix-type input source selection */
10982 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10983 /* Input mixer */
10984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10986 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10987 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10988 { }
10989};
10990
10991static struct hda_verb alc662_sue_init_verbs[] = {
10992 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10993 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10994 {}
10995};
10996
10997/*
10998 * generic initialization of ADC, input mixers and output mixers
10999 */
11000static struct hda_verb alc662_auto_init_verbs[] = {
11001 /*
11002 * Unmute ADC and set the default input to mic-in
11003 */
11004 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11005 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11006
11007 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11008 * mixer widget
11009 * Note: PASD motherboards uses the Line In 2 as the input for front
11010 * panel mic (mic 2)
11011 */
11012 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11018
11019 /*
11020 * Set up output mixers (0x0c - 0x0f)
11021 */
11022 /* set vol=0 to output mixers */
11023 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11024 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11025 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11026
11027 /* set up input amps for analog loopback */
11028 /* Amp Indices: DAC = 0, mixer = 1 */
11029 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11030 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11031 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11032 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11033 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11034 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11035
11036
11037 /* FIXME: use matrix-type input source selection */
11038 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11039 /* Input mixer */
11040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11043 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
11044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11045
11046 { }
11047};
11048
11049/* capture mixer elements */
11050static struct snd_kcontrol_new alc662_capture_mixer[] = {
11051 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11052 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11053 {
11054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11055 /* The multiple "Capture Source" controls confuse alsamixer
11056 * So call somewhat different..
11057 * FIXME: the controls appear in the "playback" view!
11058 */
11059 /* .name = "Capture Source", */
11060 .name = "Input Source",
11061 .count = 1,
11062 .info = alc882_mux_enum_info,
11063 .get = alc882_mux_enum_get,
11064 .put = alc882_mux_enum_put,
11065 },
11066 { } /* end */
11067};
11068
11069static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11070{
11071 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011072 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011073
11074 present = snd_hda_codec_read(codec, 0x14, 0,
11075 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011076 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011077 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011078 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011079 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011080 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011081}
11082
11083static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11084{
11085 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011086 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011087
11088 present = snd_hda_codec_read(codec, 0x1b, 0,
11089 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011090 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011091 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011092 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011093 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011094 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011095 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011096 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011097 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011098 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011099}
11100
11101static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11102 unsigned int res)
11103{
11104 if ((res >> 26) == ALC880_HP_EVENT)
11105 alc662_lenovo_101e_all_automute(codec);
11106 if ((res >> 26) == ALC880_FRONT_EVENT)
11107 alc662_lenovo_101e_ispeaker_automute(codec);
11108}
11109
11110
11111/* pcm configuration: identiacal with ALC880 */
11112#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11113#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11114#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11115#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11116
11117/*
11118 * configuration and preset
11119 */
11120static const char *alc662_models[ALC662_MODEL_LAST] = {
11121 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11122 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11123 [ALC662_3ST_6ch] = "3stack-6ch",
11124 [ALC662_5ST_DIG] = "6stack-dig",
11125 [ALC662_LENOVO_101E] = "lenovo-101e",
11126 [ALC662_AUTO] = "auto",
11127};
11128
11129static struct snd_pci_quirk alc662_cfg_tbl[] = {
11130 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11131 {}
11132};
11133
11134static struct alc_config_preset alc662_presets[] = {
11135 [ALC662_3ST_2ch_DIG] = {
11136 .mixers = { alc662_3ST_2ch_mixer },
11137 .init_verbs = { alc662_init_verbs },
11138 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11139 .dac_nids = alc662_dac_nids,
11140 .dig_out_nid = ALC662_DIGOUT_NID,
11141 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11142 .adc_nids = alc662_adc_nids,
11143 .dig_in_nid = ALC662_DIGIN_NID,
11144 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11145 .channel_mode = alc662_3ST_2ch_modes,
11146 .input_mux = &alc662_capture_source,
11147 },
11148 [ALC662_3ST_6ch_DIG] = {
11149 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11150 .init_verbs = { alc662_init_verbs },
11151 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11152 .dac_nids = alc662_dac_nids,
11153 .dig_out_nid = ALC662_DIGOUT_NID,
11154 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11155 .adc_nids = alc662_adc_nids,
11156 .dig_in_nid = ALC662_DIGIN_NID,
11157 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11158 .channel_mode = alc662_3ST_6ch_modes,
11159 .need_dac_fix = 1,
11160 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011161 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011162 [ALC662_3ST_6ch] = {
11163 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11164 .init_verbs = { alc662_init_verbs },
11165 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11166 .dac_nids = alc662_dac_nids,
11167 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11168 .adc_nids = alc662_adc_nids,
11169 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11170 .channel_mode = alc662_3ST_6ch_modes,
11171 .need_dac_fix = 1,
11172 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011173 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011174 [ALC662_5ST_DIG] = {
11175 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11176 .init_verbs = { alc662_init_verbs },
11177 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11178 .dac_nids = alc662_dac_nids,
11179 .dig_out_nid = ALC662_DIGOUT_NID,
11180 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11181 .adc_nids = alc662_adc_nids,
11182 .dig_in_nid = ALC662_DIGIN_NID,
11183 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11184 .channel_mode = alc662_5stack_modes,
11185 .input_mux = &alc662_capture_source,
11186 },
11187 [ALC662_LENOVO_101E] = {
11188 .mixers = { alc662_lenovo_101e_mixer },
11189 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11190 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11191 .dac_nids = alc662_dac_nids,
11192 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11193 .adc_nids = alc662_adc_nids,
11194 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11195 .channel_mode = alc662_3ST_2ch_modes,
11196 .input_mux = &alc662_lenovo_101e_capture_source,
11197 .unsol_event = alc662_lenovo_101e_unsol_event,
11198 .init_hook = alc662_lenovo_101e_all_automute,
11199 },
11200
11201};
11202
11203
11204/*
11205 * BIOS auto configuration
11206 */
11207
11208/* add playback controls from the parsed DAC table */
11209static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11210 const struct auto_pin_cfg *cfg)
11211{
11212 char name[32];
11213 static const char *chname[4] = {
11214 "Front", "Surround", NULL /*CLFE*/, "Side"
11215 };
11216 hda_nid_t nid;
11217 int i, err;
11218
11219 for (i = 0; i < cfg->line_outs; i++) {
11220 if (!spec->multiout.dac_nids[i])
11221 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011222 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011223 if (i == 2) {
11224 /* Center/LFE */
11225 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11226 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011227 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11228 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011229 if (err < 0)
11230 return err;
11231 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11232 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011233 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11234 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011235 if (err < 0)
11236 return err;
11237 err = add_control(spec, ALC_CTL_BIND_MUTE,
11238 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011239 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11240 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011241 if (err < 0)
11242 return err;
11243 err = add_control(spec, ALC_CTL_BIND_MUTE,
11244 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011245 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11246 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011247 if (err < 0)
11248 return err;
11249 } else {
11250 sprintf(name, "%s Playback Volume", chname[i]);
11251 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011252 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11253 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011254 if (err < 0)
11255 return err;
11256 sprintf(name, "%s Playback Switch", chname[i]);
11257 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011258 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11259 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011260 if (err < 0)
11261 return err;
11262 }
11263 }
11264 return 0;
11265}
11266
11267/* add playback controls for speaker and HP outputs */
11268static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11269 const char *pfx)
11270{
11271 hda_nid_t nid;
11272 int err;
11273 char name[32];
11274
11275 if (!pin)
11276 return 0;
11277
11278 if (alc880_is_fixed_pin(pin)) {
11279 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11280 /* printk("DAC nid=%x\n",nid); */
11281 /* specify the DAC as the extra output */
11282 if (!spec->multiout.hp_nid)
11283 spec->multiout.hp_nid = nid;
11284 else
11285 spec->multiout.extra_out_nid[0] = nid;
11286 /* control HP volume/switch on the output mixer amp */
11287 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11288 sprintf(name, "%s Playback Volume", pfx);
11289 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11290 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11291 if (err < 0)
11292 return err;
11293 sprintf(name, "%s Playback Switch", pfx);
11294 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11295 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11296 if (err < 0)
11297 return err;
11298 } else if (alc880_is_multi_pin(pin)) {
11299 /* set manual connection */
11300 /* we have only a switch on HP-out PIN */
11301 sprintf(name, "%s Playback Switch", pfx);
11302 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11303 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11304 if (err < 0)
11305 return err;
11306 }
11307 return 0;
11308}
11309
11310/* create playback/capture controls for input pins */
11311static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11312 const struct auto_pin_cfg *cfg)
11313{
11314 struct hda_input_mux *imux = &spec->private_imux;
11315 int i, err, idx;
11316
11317 for (i = 0; i < AUTO_PIN_LAST; i++) {
11318 if (alc880_is_input_pin(cfg->input_pins[i])) {
11319 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11320 err = new_analog_input(spec, cfg->input_pins[i],
11321 auto_pin_cfg_labels[i],
11322 idx, 0x0b);
11323 if (err < 0)
11324 return err;
11325 imux->items[imux->num_items].label =
11326 auto_pin_cfg_labels[i];
11327 imux->items[imux->num_items].index =
11328 alc880_input_pin_idx(cfg->input_pins[i]);
11329 imux->num_items++;
11330 }
11331 }
11332 return 0;
11333}
11334
11335static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11336 hda_nid_t nid, int pin_type,
11337 int dac_idx)
11338{
11339 /* set as output */
11340 snd_hda_codec_write(codec, nid, 0,
11341 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11342 snd_hda_codec_write(codec, nid, 0,
11343 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11344 /* need the manual connection? */
11345 if (alc880_is_multi_pin(nid)) {
11346 struct alc_spec *spec = codec->spec;
11347 int idx = alc880_multi_pin_idx(nid);
11348 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11349 AC_VERB_SET_CONNECT_SEL,
11350 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11351 }
11352}
11353
11354static void alc662_auto_init_multi_out(struct hda_codec *codec)
11355{
11356 struct alc_spec *spec = codec->spec;
11357 int i;
11358
11359 for (i = 0; i <= HDA_SIDE; i++) {
11360 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011361 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011362 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011363 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011364 i);
11365 }
11366}
11367
11368static void alc662_auto_init_hp_out(struct hda_codec *codec)
11369{
11370 struct alc_spec *spec = codec->spec;
11371 hda_nid_t pin;
11372
11373 pin = spec->autocfg.hp_pins[0];
11374 if (pin) /* connect to front */
11375 /* use dac 0 */
11376 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11377}
11378
11379#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11380#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11381
11382static void alc662_auto_init_analog_input(struct hda_codec *codec)
11383{
11384 struct alc_spec *spec = codec->spec;
11385 int i;
11386
11387 for (i = 0; i < AUTO_PIN_LAST; i++) {
11388 hda_nid_t nid = spec->autocfg.input_pins[i];
11389 if (alc662_is_input_pin(nid)) {
11390 snd_hda_codec_write(codec, nid, 0,
11391 AC_VERB_SET_PIN_WIDGET_CONTROL,
11392 (i <= AUTO_PIN_FRONT_MIC ?
11393 PIN_VREF80 : PIN_IN));
11394 if (nid != ALC662_PIN_CD_NID)
11395 snd_hda_codec_write(codec, nid, 0,
11396 AC_VERB_SET_AMP_GAIN_MUTE,
11397 AMP_OUT_MUTE);
11398 }
11399 }
11400}
11401
11402static int alc662_parse_auto_config(struct hda_codec *codec)
11403{
11404 struct alc_spec *spec = codec->spec;
11405 int err;
11406 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11407
11408 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11409 alc662_ignore);
11410 if (err < 0)
11411 return err;
11412 if (!spec->autocfg.line_outs)
11413 return 0; /* can't find valid BIOS pin config */
11414
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011415 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11416 if (err < 0)
11417 return err;
11418 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11419 if (err < 0)
11420 return err;
11421 err = alc662_auto_create_extra_out(spec,
11422 spec->autocfg.speaker_pins[0],
11423 "Speaker");
11424 if (err < 0)
11425 return err;
11426 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11427 "Headphone");
11428 if (err < 0)
11429 return err;
11430 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11431 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011432 return err;
11433
11434 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11435
11436 if (spec->autocfg.dig_out_pin)
11437 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11438
11439 if (spec->kctl_alloc)
11440 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11441
11442 spec->num_mux_defs = 1;
11443 spec->input_mux = &spec->private_imux;
11444
Takashi Iwai8c872862007-06-19 12:11:16 +020011445 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011446 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11447 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020011448 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011449}
11450
11451/* additional initialization for auto-configuration model */
11452static void alc662_auto_init(struct hda_codec *codec)
11453{
11454 alc662_auto_init_multi_out(codec);
11455 alc662_auto_init_hp_out(codec);
11456 alc662_auto_init_analog_input(codec);
11457}
11458
11459static int patch_alc662(struct hda_codec *codec)
11460{
11461 struct alc_spec *spec;
11462 int err, board_config;
11463
11464 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11465 if (!spec)
11466 return -ENOMEM;
11467
11468 codec->spec = spec;
11469
11470 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11471 alc662_models,
11472 alc662_cfg_tbl);
11473 if (board_config < 0) {
11474 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11475 "trying auto-probe from BIOS...\n");
11476 board_config = ALC662_AUTO;
11477 }
11478
11479 if (board_config == ALC662_AUTO) {
11480 /* automatic parse from the BIOS config */
11481 err = alc662_parse_auto_config(codec);
11482 if (err < 0) {
11483 alc_free(codec);
11484 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020011485 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011486 printk(KERN_INFO
11487 "hda_codec: Cannot set up configuration "
11488 "from BIOS. Using base mode...\n");
11489 board_config = ALC662_3ST_2ch_DIG;
11490 }
11491 }
11492
11493 if (board_config != ALC662_AUTO)
11494 setup_preset(spec, &alc662_presets[board_config]);
11495
11496 spec->stream_name_analog = "ALC662 Analog";
11497 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11498 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11499
11500 spec->stream_name_digital = "ALC662 Digital";
11501 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11502 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11503
11504 if (!spec->adc_nids && spec->input_mux) {
11505 spec->adc_nids = alc662_adc_nids;
11506 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11507 }
11508
11509 codec->patch_ops = alc_patch_ops;
11510 if (board_config == ALC662_AUTO)
11511 spec->init_hook = alc662_auto_init;
11512
11513 return 0;
11514}
11515
11516/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011517 * patch entries
11518 */
11519struct hda_codec_preset snd_hda_preset_realtek[] = {
11520 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011521 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011522 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011523 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011524 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011525 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11526 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11527 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011528 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11529 .patch = patch_alc883 },
11530 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11531 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011532 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011533 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011534 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011535 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011536 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011537 {} /* terminator */
11538};