blob: 8042766853247297d59156de75aacdefb3ccf55a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010074 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010076 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020077 ALC260_WILL,
78 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010079#ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020083 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Kailang Yangdf694da2005-12-05 19:42:22 +010086/* ALC262 models */
87enum {
88 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020089 ALC262_HIPPO,
90 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010091 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020092 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010093 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020095 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020096 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020097 ALC262_BENQ_T31,
Kailang Yangdf694da2005-12-05 19:42:22 +010098 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */
100};
101
Kailang Yanga361d842007-06-05 12:30:55 +0200102/* ALC268 models */
103enum {
104 ALC268_3ST,
105 ALC268_AUTO,
106 ALC268_MODEL_LAST /* last tag */
107};
108
Kailang Yangdf694da2005-12-05 19:42:22 +0100109/* ALC861 models */
110enum {
111 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200112 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100113 ALC861_3ST_DIG,
114 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200115 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200116 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200117 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100118 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100119 ALC861_AUTO,
120 ALC861_MODEL_LAST,
121};
122
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100123/* ALC861-VD models */
124enum {
125 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200126 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100127 ALC861VD_3ST,
128 ALC861VD_3ST_DIG,
129 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200130 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200131 ALC861VD_DALLAS,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100132 ALC861VD_AUTO,
133 ALC861VD_MODEL_LAST,
134};
135
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200136/* ALC662 models */
137enum {
138 ALC662_3ST_2ch_DIG,
139 ALC662_3ST_6ch_DIG,
140 ALC662_3ST_6ch,
141 ALC662_5ST_DIG,
142 ALC662_LENOVO_101E,
143 ALC662_AUTO,
144 ALC662_MODEL_LAST,
145};
146
Kailang Yangdf694da2005-12-05 19:42:22 +0100147/* ALC882 models */
148enum {
149 ALC882_3ST_DIG,
150 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200151 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200152 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200153 ALC882_TARGA,
154 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100155 ALC885_MACPRO,
Kailang Yang272a5272007-05-14 11:00:38 +0200156 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100157 ALC882_MODEL_LAST,
158};
159
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200160/* ALC883 models */
161enum {
162 ALC883_3ST_2ch_DIG,
163 ALC883_3ST_6ch_DIG,
164 ALC883_3ST_6ch,
165 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200166 ALC883_TARGA_DIG,
167 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200168 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200169 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200170 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100171 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200172 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200173 ALC883_LENOVO_NB0763,
174 ALC888_LENOVO_MS7195_DIG,
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +0200175 ALC888_HP_NETTLE,
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 Iwaie9edcee2005-06-13 14:16:38 +0200727 * ALC880 3-stack model
728 *
729 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200730 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
731 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 */
733
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200734static hda_nid_t alc880_dac_nids[4] = {
735 /* front, rear, clfe, rear_surr */
736 0x02, 0x05, 0x04, 0x03
737};
738
739static hda_nid_t alc880_adc_nids[3] = {
740 /* ADC0-2 */
741 0x07, 0x08, 0x09,
742};
743
744/* The datasheet says the node 0x07 is connected from inputs,
745 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100746 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200748static hda_nid_t alc880_adc_nids_alt[2] = {
749 /* ADC1-2 */
750 0x08, 0x09,
751};
752
753#define ALC880_DIGOUT_NID 0x06
754#define ALC880_DIGIN_NID 0x0a
755
756static struct hda_input_mux alc880_capture_source = {
757 .num_items = 4,
758 .items = {
759 { "Mic", 0x0 },
760 { "Front Mic", 0x3 },
761 { "Line", 0x2 },
762 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200764};
765
766/* channel source setting (2/6 channel selection for 3-stack) */
767/* 2ch mode */
768static struct hda_verb alc880_threestack_ch2_init[] = {
769 /* set line-in to input, mute it */
770 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
771 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
772 /* set mic-in to input vref 80%, mute it */
773 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
774 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 { } /* end */
776};
777
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200778/* 6ch mode */
779static struct hda_verb alc880_threestack_ch6_init[] = {
780 /* set line-in to output, unmute it */
781 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
782 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
783 /* set mic-in to output, unmute it */
784 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
785 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
786 { } /* end */
787};
788
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100789static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200790 { 2, alc880_threestack_ch2_init },
791 { 6, alc880_threestack_ch6_init },
792};
793
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100794static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200795 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100796 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200797 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100798 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200799 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
800 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100801 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
802 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
811 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
812 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200814 {
815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
816 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100817 .info = alc_ch_mode_info,
818 .get = alc_ch_mode_get,
819 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200820 },
821 { } /* end */
822};
823
824/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100825static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200826 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
827 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
828 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
829 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
830 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
831 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
832 {
833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
834 /* The multiple "Capture Source" controls confuse alsamixer
835 * So call somewhat different..
836 * FIXME: the controls appear in the "playback" view!
837 */
838 /* .name = "Capture Source", */
839 .name = "Input Source",
840 .count = 3,
841 .info = alc_mux_enum_info,
842 .get = alc_mux_enum_get,
843 .put = alc_mux_enum_put,
844 },
845 { } /* end */
846};
847
848/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100849static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200850 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
851 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
852 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
853 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 {
855 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
856 /* The multiple "Capture Source" controls confuse alsamixer
857 * So call somewhat different..
858 * FIXME: the controls appear in the "playback" view!
859 */
860 /* .name = "Capture Source", */
861 .name = "Input Source",
862 .count = 2,
863 .info = alc_mux_enum_info,
864 .get = alc_mux_enum_get,
865 .put = alc_mux_enum_put,
866 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 { } /* end */
868};
869
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200870
871
872/*
873 * ALC880 5-stack model
874 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200875 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
876 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200877 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
878 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
879 */
880
881/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100882static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200883 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100884 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 { } /* end */
886};
887
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200888/* channel source setting (6/8 channel selection for 5-stack) */
889/* 6ch mode */
890static struct hda_verb alc880_fivestack_ch6_init[] = {
891 /* set line-in to input, mute it */
892 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
893 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200894 { } /* end */
895};
896
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200897/* 8ch mode */
898static struct hda_verb alc880_fivestack_ch8_init[] = {
899 /* set line-in to output, unmute it */
900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
902 { } /* end */
903};
904
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100905static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200906 { 6, alc880_fivestack_ch6_init },
907 { 8, alc880_fivestack_ch8_init },
908};
909
910
911/*
912 * ALC880 6-stack model
913 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200914 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
915 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200916 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
917 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
918 */
919
920static hda_nid_t alc880_6st_dac_nids[4] = {
921 /* front, rear, clfe, rear_surr */
922 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200923};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200924
925static struct hda_input_mux alc880_6stack_capture_source = {
926 .num_items = 4,
927 .items = {
928 { "Mic", 0x0 },
929 { "Front Mic", 0x1 },
930 { "Line", 0x2 },
931 { "CD", 0x4 },
932 },
933};
934
935/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100936static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200937 { 8, NULL },
938};
939
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100940static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200941 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100942 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200943 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100944 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200945 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
946 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100947 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
948 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200949 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100950 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200951 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
952 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
953 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
954 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
957 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
959 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
960 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200961 {
962 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
963 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100964 .info = alc_ch_mode_info,
965 .get = alc_ch_mode_get,
966 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200967 },
968 { } /* end */
969};
970
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200971
972/*
973 * ALC880 W810 model
974 *
975 * W810 has rear IO for:
976 * Front (DAC 02)
977 * Surround (DAC 03)
978 * Center/LFE (DAC 04)
979 * Digital out (06)
980 *
981 * The system also has a pair of internal speakers, and a headphone jack.
982 * These are both connected to Line2 on the codec, hence to DAC 02.
983 *
984 * There is a variable resistor to control the speaker or headphone
985 * volume. This is a hardware-only device without a software API.
986 *
987 * Plugging headphones in will disable the internal speakers. This is
988 * implemented in hardware, not via the driver using jack sense. In
989 * a similar fashion, plugging into the rear socket marked "front" will
990 * disable both the speakers and headphones.
991 *
992 * For input, there's a microphone jack, and an "audio in" jack.
993 * These may not do anything useful with this driver yet, because I
994 * haven't setup any initialization verbs for these yet...
995 */
996
997static hda_nid_t alc880_w810_dac_nids[3] = {
998 /* front, rear/surround, clfe */
999 0x02, 0x03, 0x04
1000};
1001
1002/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001003static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001004 { 6, NULL }
1005};
1006
1007/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001008static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001009 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001010 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001011 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001012 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001013 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1014 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001015 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1016 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1018 { } /* end */
1019};
1020
1021
1022/*
1023 * Z710V model
1024 *
1025 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001026 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1027 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001028 */
1029
1030static hda_nid_t alc880_z71v_dac_nids[1] = {
1031 0x02
1032};
1033#define ALC880_Z71V_HP_DAC 0x03
1034
1035/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001036static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001037 { 2, NULL }
1038};
1039
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001040static struct snd_kcontrol_new alc880_z71v_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("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001044 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001045 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1046 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1049 { } /* end */
1050};
1051
1052
1053/* FIXME! */
1054/*
1055 * ALC880 F1734 model
1056 *
1057 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1058 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1059 */
1060
1061static hda_nid_t alc880_f1734_dac_nids[1] = {
1062 0x03
1063};
1064#define ALC880_F1734_HP_DAC 0x02
1065
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001066static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001067 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001068 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001069 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001070 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1073 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001075 { } /* end */
1076};
1077
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001078
1079/* FIXME! */
1080/*
1081 * ALC880 ASUS model
1082 *
1083 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1084 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1085 * Mic = 0x18, Line = 0x1a
1086 */
1087
1088#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1089#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1090
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001091static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001092 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001093 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001094 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001095 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001096 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1097 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001098 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1099 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001106 {
1107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1108 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001109 .info = alc_ch_mode_info,
1110 .get = alc_ch_mode_get,
1111 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001112 },
1113 { } /* end */
1114};
1115
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001116/* FIXME! */
1117/*
1118 * ALC880 ASUS W1V model
1119 *
1120 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1121 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1122 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1123 */
1124
1125/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001126static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001127 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1128 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001129 { } /* end */
1130};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001131
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001132/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001133static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001134 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1135 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1136 { } /* end */
1137};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001138
Kailang Yangdf694da2005-12-05 19:42:22 +01001139/* TCL S700 */
1140static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1141 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1142 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1144 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1145 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1148 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1149 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1150 {
1151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1152 /* The multiple "Capture Source" controls confuse alsamixer
1153 * So call somewhat different..
1154 * FIXME: the controls appear in the "playback" view!
1155 */
1156 /* .name = "Capture Source", */
1157 .name = "Input Source",
1158 .count = 1,
1159 .info = alc_mux_enum_info,
1160 .get = alc_mux_enum_get,
1161 .put = alc_mux_enum_put,
1162 },
1163 { } /* end */
1164};
1165
Kailang Yangccc656c2006-10-17 12:32:26 +02001166/* Uniwill */
1167static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1168 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1169 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1170 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1171 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1172 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1174 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1175 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1182 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1183 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1184 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1185 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1186 {
1187 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1188 .name = "Channel Mode",
1189 .info = alc_ch_mode_info,
1190 .get = alc_ch_mode_get,
1191 .put = alc_ch_mode_put,
1192 },
1193 { } /* end */
1194};
1195
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001196static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1197 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1198 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1203 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1204 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1205 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1206 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1207 { } /* end */
1208};
1209
Kailang Yangccc656c2006-10-17 12:32:26 +02001210static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1211 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1212 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1213 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1214 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1217 { } /* end */
1218};
1219
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001221 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 */
1223static int alc_build_controls(struct hda_codec *codec)
1224{
1225 struct alc_spec *spec = codec->spec;
1226 int err;
1227 int i;
1228
1229 for (i = 0; i < spec->num_mixers; i++) {
1230 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1231 if (err < 0)
1232 return err;
1233 }
1234
1235 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001236 err = snd_hda_create_spdif_out_ctls(codec,
1237 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 if (err < 0)
1239 return err;
1240 }
1241 if (spec->dig_in_nid) {
1242 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1243 if (err < 0)
1244 return err;
1245 }
1246 return 0;
1247}
1248
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001249
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250/*
1251 * initialize the codec volumes, etc
1252 */
1253
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001254/*
1255 * generic initialization of ADC, input mixers and output mixers
1256 */
1257static struct hda_verb alc880_volume_init_verbs[] = {
1258 /*
1259 * Unmute ADC0-2 and set the default input to mic-in
1260 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001261 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001263 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001265 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001268 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1269 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001270 * Note: PASD motherboards uses the Line In 2 as the input for front
1271 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001272 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001273 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1278 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001280 /*
1281 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001283 /* set vol=0 to output mixers */
1284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1287 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1288 /* set up input amps for analog loopback */
1289 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001292 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1293 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1295 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001296 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1297 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298
1299 { }
1300};
1301
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001302/*
1303 * 3-stack pin configuration:
1304 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1305 */
1306static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1307 /*
1308 * preset connection lists of input pins
1309 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1310 */
1311 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1312 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1313 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1314
1315 /*
1316 * Set pin mode and muting
1317 */
1318 /* set front pin widgets 0x14 for output */
1319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1320 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1321 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1322 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1323 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1324 /* Mic2 (as headphone out) for HP output */
1325 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1326 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1327 /* Line In pin widget for input */
1328 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1329 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1330 /* Line2 (as front mic) pin widget for input and vref at 80% */
1331 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1332 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1333 /* CD pin widget for input */
1334 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1335
1336 { }
1337};
1338
1339/*
1340 * 5-stack pin configuration:
1341 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1342 * line-in/side = 0x1a, f-mic = 0x1b
1343 */
1344static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1345 /*
1346 * preset connection lists of input pins
1347 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1348 */
1349 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1350 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1351
1352 /*
1353 * Set pin mode and muting
1354 */
1355 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1357 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1358 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1359 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001360 /* unmute pins for output (no gain on this amp) */
1361 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1363 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1364 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1365
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001367 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1369 /* Mic2 (as headphone out) for HP output */
1370 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001372 /* Line In pin widget for input */
1373 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1374 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1375 /* Line2 (as front mic) pin widget for input and vref at 80% */
1376 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1377 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1378 /* CD pin widget for input */
1379 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380
1381 { }
1382};
1383
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001384/*
1385 * W810 pin configuration:
1386 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1387 */
1388static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 /* hphone/speaker input selector: front DAC */
1390 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1391
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001392 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1397 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1398
1399 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001400 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 { }
1403};
1404
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001405/*
1406 * Z71V pin configuration:
1407 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1408 */
1409static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001414
Takashi Iwai16ded522005-06-10 19:58:24 +02001415 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001416 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001417 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001418 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001419
1420 { }
1421};
1422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001423/*
1424 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001425 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1426 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001427 */
1428static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1429 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1430
Takashi Iwai16ded522005-06-10 19:58:24 +02001431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001432 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001435 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001436 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001437 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001438 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1439
Takashi Iwai16ded522005-06-10 19:58:24 +02001440 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001441 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001442 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001443 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001444 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001445 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001446 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001447 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001448 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1449
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001450 { }
1451};
Takashi Iwai16ded522005-06-10 19:58:24 +02001452
Kailang Yangccc656c2006-10-17 12:32:26 +02001453/*
1454 * Uniwill pin configuration:
1455 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1456 * line = 0x1a
1457 */
1458static struct hda_verb alc880_uniwill_init_verbs[] = {
1459 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1460
1461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1462 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1465 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1466 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1468 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1475
1476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1477 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1478 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1479 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1482 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1483 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1484 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1485
1486 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1487 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1488
1489 { }
1490};
1491
1492/*
1493* Uniwill P53
1494* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1495 */
1496static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1497 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1498
1499 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1503 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1504 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1508 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1509 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1511
1512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1514 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1515 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1518
1519 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1520 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1521
1522 { }
1523};
1524
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001525static struct hda_verb alc880_beep_init_verbs[] = {
1526 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1527 { }
1528};
1529
Kailang Yangccc656c2006-10-17 12:32:26 +02001530/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001531static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001532{
1533 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001534 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001535
1536 present = snd_hda_codec_read(codec, 0x14, 0,
1537 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001538 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001539 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001540 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001541 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001542 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001543 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001544 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001545 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001546 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001547}
1548
1549/* auto-toggle front mic */
1550static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1551{
1552 unsigned int present;
1553 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001554
1555 present = snd_hda_codec_read(codec, 0x18, 0,
1556 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001557 bits = present ? 0x80 : 0;
1558 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1559 0x80, bits);
1560 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1561 0x80, bits);
1562}
1563
1564static void alc880_uniwill_automute(struct hda_codec *codec)
1565{
1566 alc880_uniwill_hp_automute(codec);
1567 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001568}
1569
1570static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1571 unsigned int res)
1572{
1573 /* Looks like the unsol event is incompatible with the standard
1574 * definition. 4bit tag is placed at 28 bit!
1575 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001576 switch (res >> 28) {
1577 case ALC880_HP_EVENT:
1578 alc880_uniwill_hp_automute(codec);
1579 break;
1580 case ALC880_MIC_EVENT:
1581 alc880_uniwill_mic_automute(codec);
1582 break;
1583 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001584}
1585
1586static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1587{
1588 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001589 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001590
1591 present = snd_hda_codec_read(codec, 0x14, 0,
1592 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001593 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001594 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001595 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001596 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001597 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001598}
1599
1600static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1601{
1602 unsigned int present;
1603
1604 present = snd_hda_codec_read(codec, 0x21, 0,
1605 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1606
1607 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1608 0x7f, present);
1609 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1610 0x7f, present);
1611
1612 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1613 0x7f, present);
1614 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1615 0x7f, present);
1616
1617}
1618static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1619 unsigned int res)
1620{
1621 /* Looks like the unsol event is incompatible with the standard
1622 * definition. 4bit tag is placed at 28 bit!
1623 */
1624 if ((res >> 28) == ALC880_HP_EVENT)
1625 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001626 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001627 alc880_uniwill_p53_dcvol_automute(codec);
1628}
1629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001630/* FIXME! */
1631/*
1632 * F1734 pin configuration:
1633 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1634 */
1635static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1636 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1637 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1638 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1639 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1640
1641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1645
1646 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1647 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1648 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1649 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1650 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1651 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1652 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1654 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001655
1656 { }
1657};
1658
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001659/* FIXME! */
1660/*
1661 * ASUS pin configuration:
1662 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1663 */
1664static struct hda_verb alc880_pin_asus_init_verbs[] = {
1665 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1666 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1667 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1668 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1669
1670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1673 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1674 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1675 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1676 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1677 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1678
1679 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1681 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1683 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1684 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1686 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1687 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1688
1689 { }
1690};
1691
1692/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001693#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1694#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001695
Kailang Yangdf694da2005-12-05 19:42:22 +01001696/* Clevo m520g init */
1697static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1698 /* headphone output */
1699 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1700 /* line-out */
1701 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 /* Line-in */
1704 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1706 /* CD */
1707 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1708 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 /* Mic1 (rear panel) */
1710 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1711 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1712 /* Mic2 (front panel) */
1713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1715 /* headphone */
1716 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1718 /* change to EAPD mode */
1719 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1720 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1721
1722 { }
1723};
1724
1725static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001726 /* change to EAPD mode */
1727 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1728 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1729
Kailang Yangdf694da2005-12-05 19:42:22 +01001730 /* Headphone output */
1731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1732 /* Front output*/
1733 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1734 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1735
1736 /* Line In pin widget for input */
1737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1738 /* CD pin widget for input */
1739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1740 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1741 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1742
1743 /* change to EAPD mode */
1744 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1745 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1746
1747 { }
1748};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749
1750/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001751 * LG m1 express dual
1752 *
1753 * Pin assignment:
1754 * Rear Line-In/Out (blue): 0x14
1755 * Build-in Mic-In: 0x15
1756 * Speaker-out: 0x17
1757 * HP-Out (green): 0x1b
1758 * Mic-In/Out (red): 0x19
1759 * SPDIF-Out: 0x1e
1760 */
1761
1762/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1763static hda_nid_t alc880_lg_dac_nids[3] = {
1764 0x05, 0x02, 0x03
1765};
1766
1767/* seems analog CD is not working */
1768static struct hda_input_mux alc880_lg_capture_source = {
1769 .num_items = 3,
1770 .items = {
1771 { "Mic", 0x1 },
1772 { "Line", 0x5 },
1773 { "Internal Mic", 0x6 },
1774 },
1775};
1776
1777/* 2,4,6 channel modes */
1778static struct hda_verb alc880_lg_ch2_init[] = {
1779 /* set line-in and mic-in to input */
1780 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1781 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1782 { }
1783};
1784
1785static struct hda_verb alc880_lg_ch4_init[] = {
1786 /* set line-in to out and mic-in to input */
1787 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1788 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1789 { }
1790};
1791
1792static struct hda_verb alc880_lg_ch6_init[] = {
1793 /* set line-in and mic-in to output */
1794 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1795 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1796 { }
1797};
1798
1799static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1800 { 2, alc880_lg_ch2_init },
1801 { 4, alc880_lg_ch4_init },
1802 { 6, alc880_lg_ch6_init },
1803};
1804
1805static struct snd_kcontrol_new alc880_lg_mixer[] = {
1806 /* FIXME: it's not really "master" but front channels */
1807 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1808 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1809 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1810 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1811 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1812 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1813 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1814 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1819 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1820 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1821 {
1822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1823 .name = "Channel Mode",
1824 .info = alc_ch_mode_info,
1825 .get = alc_ch_mode_get,
1826 .put = alc_ch_mode_put,
1827 },
1828 { } /* end */
1829};
1830
1831static struct hda_verb alc880_lg_init_verbs[] = {
1832 /* set capture source to mic-in */
1833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1834 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1836 /* mute all amp mixer inputs */
1837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1840 /* line-in to input */
1841 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1843 /* built-in mic */
1844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1846 /* speaker-out */
1847 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1848 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1849 /* mic-in to input */
1850 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1851 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1852 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1853 /* HP-out */
1854 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1855 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1856 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1857 /* jack sense */
1858 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1859 { }
1860};
1861
1862/* toggle speaker-output according to the hp-jack state */
1863static void alc880_lg_automute(struct hda_codec *codec)
1864{
1865 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001866 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001867
1868 present = snd_hda_codec_read(codec, 0x1b, 0,
1869 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001870 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001871 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001872 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001873 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001874 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001875}
1876
1877static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1878{
1879 /* Looks like the unsol event is incompatible with the standard
1880 * definition. 4bit tag is placed at 28 bit!
1881 */
1882 if ((res >> 28) == 0x01)
1883 alc880_lg_automute(codec);
1884}
1885
1886/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001887 * LG LW20
1888 *
1889 * Pin assignment:
1890 * Speaker-out: 0x14
1891 * Mic-In: 0x18
1892 * Built-in Mic-In: 0x19 (?)
1893 * HP-Out: 0x1b
1894 * SPDIF-Out: 0x1e
1895 */
1896
1897/* seems analog CD is not working */
1898static struct hda_input_mux alc880_lg_lw_capture_source = {
1899 .num_items = 2,
1900 .items = {
1901 { "Mic", 0x0 },
1902 { "Internal Mic", 0x1 },
1903 },
1904};
1905
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001906#define alc880_lg_lw_modes alc880_threestack_modes
1907
Takashi Iwaid6815182006-03-23 16:06:23 +01001908static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001909 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1910 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1911 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1912 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1913 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1914 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1915 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1916 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1921 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1922 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001923 {
1924 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1925 .name = "Channel Mode",
1926 .info = alc_ch_mode_info,
1927 .get = alc_ch_mode_get,
1928 .put = alc_ch_mode_put,
1929 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001930 { } /* end */
1931};
1932
1933static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001934 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1935 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1936 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1937
Takashi Iwaid6815182006-03-23 16:06:23 +01001938 /* set capture source to mic-in */
1939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1940 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1941 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1943 /* speaker-out */
1944 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1946 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001947 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1948 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1949 /* mic-in to input */
1950 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1951 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1952 /* built-in mic */
1953 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 /* jack sense */
1956 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1957 { }
1958};
1959
1960/* toggle speaker-output according to the hp-jack state */
1961static void alc880_lg_lw_automute(struct hda_codec *codec)
1962{
1963 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001964 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001965
1966 present = snd_hda_codec_read(codec, 0x1b, 0,
1967 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001968 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001969 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001970 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001971 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001972 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001973}
1974
1975static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1976{
1977 /* Looks like the unsol event is incompatible with the standard
1978 * definition. 4bit tag is placed at 28 bit!
1979 */
1980 if ((res >> 28) == 0x01)
1981 alc880_lg_lw_automute(codec);
1982}
1983
1984/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001985 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001986 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001987
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988static int alc_init(struct hda_codec *codec)
1989{
1990 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001991 unsigned int i;
1992
1993 for (i = 0; i < spec->num_init_verbs; i++)
1994 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001995
1996 if (spec->init_hook)
1997 spec->init_hook(codec);
1998
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999 return 0;
2000}
2001
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002002static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2003{
2004 struct alc_spec *spec = codec->spec;
2005
2006 if (spec->unsol_event)
2007 spec->unsol_event(codec, res);
2008}
2009
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010#ifdef CONFIG_PM
2011/*
2012 * resume
2013 */
2014static int alc_resume(struct hda_codec *codec)
2015{
2016 struct alc_spec *spec = codec->spec;
2017 int i;
2018
2019 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002020 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002021 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022 if (spec->multiout.dig_out_nid)
2023 snd_hda_resume_spdif_out(codec);
2024 if (spec->dig_in_nid)
2025 snd_hda_resume_spdif_in(codec);
2026
2027 return 0;
2028}
2029#endif
2030
2031/*
2032 * Analog playback callbacks
2033 */
2034static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2035 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002036 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002037{
2038 struct alc_spec *spec = codec->spec;
2039 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2040}
2041
2042static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2043 struct hda_codec *codec,
2044 unsigned int stream_tag,
2045 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002046 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002047{
2048 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002049 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2050 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051}
2052
2053static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2054 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002055 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056{
2057 struct alc_spec *spec = codec->spec;
2058 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2059}
2060
2061/*
2062 * Digital out
2063 */
2064static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2065 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002066 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067{
2068 struct alc_spec *spec = codec->spec;
2069 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2070}
2071
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002072static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2073 struct hda_codec *codec,
2074 unsigned int stream_tag,
2075 unsigned int format,
2076 struct snd_pcm_substream *substream)
2077{
2078 struct alc_spec *spec = codec->spec;
2079 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2080 stream_tag, format, substream);
2081}
2082
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2084 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002085 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086{
2087 struct alc_spec *spec = codec->spec;
2088 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2089}
2090
2091/*
2092 * Analog capture
2093 */
2094static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2095 struct hda_codec *codec,
2096 unsigned int stream_tag,
2097 unsigned int format,
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
2102 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2103 stream_tag, 0, format);
2104 return 0;
2105}
2106
2107static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2108 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002109 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002110{
2111 struct alc_spec *spec = codec->spec;
2112
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002113 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2114 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002115 return 0;
2116}
2117
2118
2119/*
2120 */
2121static struct hda_pcm_stream alc880_pcm_analog_playback = {
2122 .substreams = 1,
2123 .channels_min = 2,
2124 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002125 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002126 .ops = {
2127 .open = alc880_playback_pcm_open,
2128 .prepare = alc880_playback_pcm_prepare,
2129 .cleanup = alc880_playback_pcm_cleanup
2130 },
2131};
2132
2133static struct hda_pcm_stream alc880_pcm_analog_capture = {
2134 .substreams = 2,
2135 .channels_min = 2,
2136 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002137 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002138 .ops = {
2139 .prepare = alc880_capture_pcm_prepare,
2140 .cleanup = alc880_capture_pcm_cleanup
2141 },
2142};
2143
2144static struct hda_pcm_stream alc880_pcm_digital_playback = {
2145 .substreams = 1,
2146 .channels_min = 2,
2147 .channels_max = 2,
2148 /* NID is set in alc_build_pcms */
2149 .ops = {
2150 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002151 .close = alc880_dig_playback_pcm_close,
2152 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153 },
2154};
2155
2156static struct hda_pcm_stream alc880_pcm_digital_capture = {
2157 .substreams = 1,
2158 .channels_min = 2,
2159 .channels_max = 2,
2160 /* NID is set in alc_build_pcms */
2161};
2162
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002163/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2164static struct hda_pcm_stream alc_pcm_null_playback = {
2165 .substreams = 0,
2166 .channels_min = 0,
2167 .channels_max = 0,
2168};
2169
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170static int alc_build_pcms(struct hda_codec *codec)
2171{
2172 struct alc_spec *spec = codec->spec;
2173 struct hda_pcm *info = spec->pcm_rec;
2174 int i;
2175
2176 codec->num_pcms = 1;
2177 codec->pcm_info = info;
2178
2179 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002180 if (spec->stream_analog_playback) {
2181 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2182 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2183 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2184 }
2185 if (spec->stream_analog_capture) {
2186 snd_assert(spec->adc_nids, return -EINVAL);
2187 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2188 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2189 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190
Takashi Iwai4a471b72005-12-07 13:56:29 +01002191 if (spec->channel_mode) {
2192 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2193 for (i = 0; i < spec->num_channel_mode; i++) {
2194 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2195 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2196 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197 }
2198 }
2199
Takashi Iwaie08a0072006-09-07 17:52:14 +02002200 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002202 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002203 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002205 if (spec->multiout.dig_out_nid &&
2206 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2208 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2209 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002210 if (spec->dig_in_nid &&
2211 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002212 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2213 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2214 }
2215 }
2216
Takashi Iwaie08a0072006-09-07 17:52:14 +02002217 /* If the use of more than one ADC is requested for the current
2218 * model, configure a second analog capture-only PCM.
2219 */
2220 /* Additional Analaog capture for index #2 */
2221 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2222 spec->adc_nids) {
2223 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002224 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002225 info->name = spec->stream_name_analog;
2226 /* No playback stream for second PCM */
2227 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2228 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2229 if (spec->stream_analog_capture) {
2230 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2231 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2232 }
2233 }
2234
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235 return 0;
2236}
2237
2238static void alc_free(struct hda_codec *codec)
2239{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002240 struct alc_spec *spec = codec->spec;
2241 unsigned int i;
2242
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002243 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002244 return;
2245
2246 if (spec->kctl_alloc) {
2247 for (i = 0; i < spec->num_kctl_used; i++)
2248 kfree(spec->kctl_alloc[i].name);
2249 kfree(spec->kctl_alloc);
2250 }
2251 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252}
2253
2254/*
2255 */
2256static struct hda_codec_ops alc_patch_ops = {
2257 .build_controls = alc_build_controls,
2258 .build_pcms = alc_build_pcms,
2259 .init = alc_init,
2260 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002261 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262#ifdef CONFIG_PM
2263 .resume = alc_resume,
2264#endif
2265};
2266
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002267
2268/*
2269 * Test configuration for debugging
2270 *
2271 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2272 * enum controls.
2273 */
2274#ifdef CONFIG_SND_DEBUG
2275static hda_nid_t alc880_test_dac_nids[4] = {
2276 0x02, 0x03, 0x04, 0x05
2277};
2278
2279static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002280 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002281 .items = {
2282 { "In-1", 0x0 },
2283 { "In-2", 0x1 },
2284 { "In-3", 0x2 },
2285 { "In-4", 0x3 },
2286 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002287 { "Front", 0x5 },
2288 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002289 },
2290};
2291
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002292static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002293 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002294 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002295 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002296 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002297};
2298
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002299static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2300 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002301{
2302 static char *texts[] = {
2303 "N/A", "Line Out", "HP Out",
2304 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2305 };
2306 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2307 uinfo->count = 1;
2308 uinfo->value.enumerated.items = 8;
2309 if (uinfo->value.enumerated.item >= 8)
2310 uinfo->value.enumerated.item = 7;
2311 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2312 return 0;
2313}
2314
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002315static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2316 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002317{
2318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2319 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2320 unsigned int pin_ctl, item = 0;
2321
2322 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2323 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2324 if (pin_ctl & AC_PINCTL_OUT_EN) {
2325 if (pin_ctl & AC_PINCTL_HP_EN)
2326 item = 2;
2327 else
2328 item = 1;
2329 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2330 switch (pin_ctl & AC_PINCTL_VREFEN) {
2331 case AC_PINCTL_VREF_HIZ: item = 3; break;
2332 case AC_PINCTL_VREF_50: item = 4; break;
2333 case AC_PINCTL_VREF_GRD: item = 5; break;
2334 case AC_PINCTL_VREF_80: item = 6; break;
2335 case AC_PINCTL_VREF_100: item = 7; break;
2336 }
2337 }
2338 ucontrol->value.enumerated.item[0] = item;
2339 return 0;
2340}
2341
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002342static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2343 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002344{
2345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2346 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2347 static unsigned int ctls[] = {
2348 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2349 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2350 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2351 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2352 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2353 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2354 };
2355 unsigned int old_ctl, new_ctl;
2356
2357 old_ctl = snd_hda_codec_read(codec, nid, 0,
2358 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2359 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2360 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002361 snd_hda_codec_write(codec, nid, 0,
2362 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002363 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002364 (ucontrol->value.enumerated.item[0] >= 3 ?
2365 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002366 return 1;
2367 }
2368 return 0;
2369}
2370
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002371static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2372 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002373{
2374 static char *texts[] = {
2375 "Front", "Surround", "CLFE", "Side"
2376 };
2377 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2378 uinfo->count = 1;
2379 uinfo->value.enumerated.items = 4;
2380 if (uinfo->value.enumerated.item >= 4)
2381 uinfo->value.enumerated.item = 3;
2382 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2383 return 0;
2384}
2385
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002386static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2387 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002388{
2389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2390 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2391 unsigned int sel;
2392
2393 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2394 ucontrol->value.enumerated.item[0] = sel & 3;
2395 return 0;
2396}
2397
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002398static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2399 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002400{
2401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2402 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2403 unsigned int sel;
2404
2405 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2406 if (ucontrol->value.enumerated.item[0] != sel) {
2407 sel = ucontrol->value.enumerated.item[0] & 3;
2408 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2409 return 1;
2410 }
2411 return 0;
2412}
2413
2414#define PIN_CTL_TEST(xname,nid) { \
2415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2416 .name = xname, \
2417 .info = alc_test_pin_ctl_info, \
2418 .get = alc_test_pin_ctl_get, \
2419 .put = alc_test_pin_ctl_put, \
2420 .private_value = nid \
2421 }
2422
2423#define PIN_SRC_TEST(xname,nid) { \
2424 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2425 .name = xname, \
2426 .info = alc_test_pin_src_info, \
2427 .get = alc_test_pin_src_get, \
2428 .put = alc_test_pin_src_put, \
2429 .private_value = nid \
2430 }
2431
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002432static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002433 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2434 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2435 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2436 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002437 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2438 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2439 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2440 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002441 PIN_CTL_TEST("Front Pin Mode", 0x14),
2442 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2443 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2444 PIN_CTL_TEST("Side Pin Mode", 0x17),
2445 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2446 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2447 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2448 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2449 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2450 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2451 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2452 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2453 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2454 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2455 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2456 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2457 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2458 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2459 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2460 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2461 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2462 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002463 {
2464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2465 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002466 .info = alc_ch_mode_info,
2467 .get = alc_ch_mode_get,
2468 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002469 },
2470 { } /* end */
2471};
2472
2473static struct hda_verb alc880_test_init_verbs[] = {
2474 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2478 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2479 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2480 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2481 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2482 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002483 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2487 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002488 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002489 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2490 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2491 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002493 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2496 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002498 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2500 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002501 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2503 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002504 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2506 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002509 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002511 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002513 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002516 /* Analog input/passthru */
2517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002522 { }
2523};
2524#endif
2525
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526/*
2527 */
2528
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002529static const char *alc880_models[ALC880_MODEL_LAST] = {
2530 [ALC880_3ST] = "3stack",
2531 [ALC880_TCL_S700] = "tcl",
2532 [ALC880_3ST_DIG] = "3stack-digout",
2533 [ALC880_CLEVO] = "clevo",
2534 [ALC880_5ST] = "5stack",
2535 [ALC880_5ST_DIG] = "5stack-digout",
2536 [ALC880_W810] = "w810",
2537 [ALC880_Z71V] = "z71v",
2538 [ALC880_6ST] = "6stack",
2539 [ALC880_6ST_DIG] = "6stack-digout",
2540 [ALC880_ASUS] = "asus",
2541 [ALC880_ASUS_W1V] = "asus-w1v",
2542 [ALC880_ASUS_DIG] = "asus-dig",
2543 [ALC880_ASUS_DIG2] = "asus-dig2",
2544 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002545 [ALC880_UNIWILL_P53] = "uniwill-p53",
2546 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002547 [ALC880_F1734] = "F1734",
2548 [ALC880_LG] = "lg",
2549 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002550#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002551 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002552#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002553 [ALC880_AUTO] = "auto",
2554};
2555
2556static struct snd_pci_quirk alc880_cfg_tbl[] = {
2557 /* Broken BIOS configuration */
2558 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2559 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2560
2561 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2562 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002563 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002564 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2565 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2566 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2567 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2568 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2569 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2570
2571 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2572 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2573
2574 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2575 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2576 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2577 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2578 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2579 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2580 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2581 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2582 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2583 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002584 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002585 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2586 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2587 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2588 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2589
2590 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2591 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2592 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2593 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2594 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2595 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2596 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2597 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2598 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2599 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2600 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2601 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2602 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2603 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2604 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2605 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2606 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2607 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2608
2609 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2610 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2611 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2612 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2613
2614 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2615 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2616 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002617 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002618
2619 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2620 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2621 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2622 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2623
2624 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2625 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2626 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2627 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2628 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2629 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2630 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2631 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2632 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2633 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2634 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002635
Linus Torvalds1da177e2005-04-16 15:20:36 -07002636 {}
2637};
2638
Takashi Iwai16ded522005-06-10 19:58:24 +02002639/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002640 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002641 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002642static struct alc_config_preset alc880_presets[] = {
2643 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002645 .init_verbs = { alc880_volume_init_verbs,
2646 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002647 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002648 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002649 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2650 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002651 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002652 .input_mux = &alc880_capture_source,
2653 },
2654 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002656 .init_verbs = { alc880_volume_init_verbs,
2657 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002659 .dac_nids = alc880_dac_nids,
2660 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002661 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2662 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002663 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002664 .input_mux = &alc880_capture_source,
2665 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002666 [ALC880_TCL_S700] = {
2667 .mixers = { alc880_tcl_s700_mixer },
2668 .init_verbs = { alc880_volume_init_verbs,
2669 alc880_pin_tcl_S700_init_verbs,
2670 alc880_gpio2_init_verbs },
2671 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2672 .dac_nids = alc880_dac_nids,
2673 .hp_nid = 0x03,
2674 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2675 .channel_mode = alc880_2_jack_modes,
2676 .input_mux = &alc880_capture_source,
2677 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002678 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002679 .mixers = { alc880_three_stack_mixer,
2680 alc880_five_stack_mixer},
2681 .init_verbs = { alc880_volume_init_verbs,
2682 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2684 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002685 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2686 .channel_mode = alc880_fivestack_modes,
2687 .input_mux = &alc880_capture_source,
2688 },
2689 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002690 .mixers = { alc880_three_stack_mixer,
2691 alc880_five_stack_mixer },
2692 .init_verbs = { alc880_volume_init_verbs,
2693 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002694 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2695 .dac_nids = alc880_dac_nids,
2696 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002697 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2698 .channel_mode = alc880_fivestack_modes,
2699 .input_mux = &alc880_capture_source,
2700 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002701 [ALC880_6ST] = {
2702 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002703 .init_verbs = { alc880_volume_init_verbs,
2704 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002705 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2706 .dac_nids = alc880_6st_dac_nids,
2707 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2708 .channel_mode = alc880_sixstack_modes,
2709 .input_mux = &alc880_6stack_capture_source,
2710 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002711 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002713 .init_verbs = { alc880_volume_init_verbs,
2714 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002715 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2716 .dac_nids = alc880_6st_dac_nids,
2717 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002718 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2719 .channel_mode = alc880_sixstack_modes,
2720 .input_mux = &alc880_6stack_capture_source,
2721 },
2722 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002723 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002724 .init_verbs = { alc880_volume_init_verbs,
2725 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002726 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002727 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2728 .dac_nids = alc880_w810_dac_nids,
2729 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002730 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2731 .channel_mode = alc880_w810_modes,
2732 .input_mux = &alc880_capture_source,
2733 },
2734 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002735 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002736 .init_verbs = { alc880_volume_init_verbs,
2737 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002738 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2739 .dac_nids = alc880_z71v_dac_nids,
2740 .dig_out_nid = ALC880_DIGOUT_NID,
2741 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002742 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2743 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002744 .input_mux = &alc880_capture_source,
2745 },
2746 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002748 .init_verbs = { alc880_volume_init_verbs,
2749 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2751 .dac_nids = alc880_f1734_dac_nids,
2752 .hp_nid = 0x02,
2753 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2754 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002755 .input_mux = &alc880_capture_source,
2756 },
2757 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002758 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002759 .init_verbs = { alc880_volume_init_verbs,
2760 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002761 alc880_gpio1_init_verbs },
2762 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2763 .dac_nids = alc880_asus_dac_nids,
2764 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2765 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002766 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002767 .input_mux = &alc880_capture_source,
2768 },
2769 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002770 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002771 .init_verbs = { alc880_volume_init_verbs,
2772 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002773 alc880_gpio1_init_verbs },
2774 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2775 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002776 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002777 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2778 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002779 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002780 .input_mux = &alc880_capture_source,
2781 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002782 [ALC880_ASUS_DIG2] = {
2783 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002784 .init_verbs = { alc880_volume_init_verbs,
2785 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002786 alc880_gpio2_init_verbs }, /* use GPIO2 */
2787 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2788 .dac_nids = alc880_asus_dac_nids,
2789 .dig_out_nid = ALC880_DIGOUT_NID,
2790 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2791 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002792 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002793 .input_mux = &alc880_capture_source,
2794 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002795 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002797 .init_verbs = { alc880_volume_init_verbs,
2798 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002799 alc880_gpio1_init_verbs },
2800 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2801 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002802 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002803 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2804 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002805 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002806 .input_mux = &alc880_capture_source,
2807 },
2808 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002809 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002810 .init_verbs = { alc880_volume_init_verbs,
2811 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2813 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002814 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002815 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2816 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002817 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002818 .input_mux = &alc880_capture_source,
2819 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002820 [ALC880_UNIWILL] = {
2821 .mixers = { alc880_uniwill_mixer },
2822 .init_verbs = { alc880_volume_init_verbs,
2823 alc880_uniwill_init_verbs },
2824 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2825 .dac_nids = alc880_asus_dac_nids,
2826 .dig_out_nid = ALC880_DIGOUT_NID,
2827 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2828 .channel_mode = alc880_threestack_modes,
2829 .need_dac_fix = 1,
2830 .input_mux = &alc880_capture_source,
2831 .unsol_event = alc880_uniwill_unsol_event,
2832 .init_hook = alc880_uniwill_automute,
2833 },
2834 [ALC880_UNIWILL_P53] = {
2835 .mixers = { alc880_uniwill_p53_mixer },
2836 .init_verbs = { alc880_volume_init_verbs,
2837 alc880_uniwill_p53_init_verbs },
2838 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2839 .dac_nids = alc880_asus_dac_nids,
2840 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002841 .channel_mode = alc880_threestack_modes,
2842 .input_mux = &alc880_capture_source,
2843 .unsol_event = alc880_uniwill_p53_unsol_event,
2844 .init_hook = alc880_uniwill_p53_hp_automute,
2845 },
2846 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002847 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002848 alc880_pcbeep_mixer, },
2849 .init_verbs = { alc880_volume_init_verbs,
2850 alc880_uniwill_p53_init_verbs,
2851 alc880_beep_init_verbs },
2852 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2853 .dac_nids = alc880_dac_nids,
2854 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2855 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002856 .input_mux = &alc880_capture_source,
2857 .unsol_event = alc880_uniwill_p53_unsol_event,
2858 .init_hook = alc880_uniwill_p53_hp_automute,
2859 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002860 [ALC880_CLEVO] = {
2861 .mixers = { alc880_three_stack_mixer },
2862 .init_verbs = { alc880_volume_init_verbs,
2863 alc880_pin_clevo_init_verbs },
2864 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2865 .dac_nids = alc880_dac_nids,
2866 .hp_nid = 0x03,
2867 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2868 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002869 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002870 .input_mux = &alc880_capture_source,
2871 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002872 [ALC880_LG] = {
2873 .mixers = { alc880_lg_mixer },
2874 .init_verbs = { alc880_volume_init_verbs,
2875 alc880_lg_init_verbs },
2876 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2877 .dac_nids = alc880_lg_dac_nids,
2878 .dig_out_nid = ALC880_DIGOUT_NID,
2879 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2880 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002881 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002882 .input_mux = &alc880_lg_capture_source,
2883 .unsol_event = alc880_lg_unsol_event,
2884 .init_hook = alc880_lg_automute,
2885 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002886 [ALC880_LG_LW] = {
2887 .mixers = { alc880_lg_lw_mixer },
2888 .init_verbs = { alc880_volume_init_verbs,
2889 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002890 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002891 .dac_nids = alc880_dac_nids,
2892 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002893 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2894 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002895 .input_mux = &alc880_lg_lw_capture_source,
2896 .unsol_event = alc880_lg_lw_unsol_event,
2897 .init_hook = alc880_lg_lw_automute,
2898 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002899#ifdef CONFIG_SND_DEBUG
2900 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002901 .mixers = { alc880_test_mixer },
2902 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002903 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2904 .dac_nids = alc880_test_dac_nids,
2905 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002906 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2907 .channel_mode = alc880_test_modes,
2908 .input_mux = &alc880_test_capture_source,
2909 },
2910#endif
2911};
2912
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913/*
2914 * Automatic parse of I/O pins from the BIOS configuration
2915 */
2916
2917#define NUM_CONTROL_ALLOC 32
2918#define NUM_VERB_ALLOC 32
2919
2920enum {
2921 ALC_CTL_WIDGET_VOL,
2922 ALC_CTL_WIDGET_MUTE,
2923 ALC_CTL_BIND_MUTE,
2924};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002925static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002926 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2927 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002928 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002929};
2930
2931/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002932static int add_control(struct alc_spec *spec, int type, const char *name,
2933 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002934{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002935 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002936
2937 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2938 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2939
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002940 /* array + terminator */
2941 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2942 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002943 return -ENOMEM;
2944 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002945 memcpy(knew, spec->kctl_alloc,
2946 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002947 kfree(spec->kctl_alloc);
2948 }
2949 spec->kctl_alloc = knew;
2950 spec->num_kctl_alloc = num;
2951 }
2952
2953 knew = &spec->kctl_alloc[spec->num_kctl_used];
2954 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002955 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002956 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002957 return -ENOMEM;
2958 knew->private_value = val;
2959 spec->num_kctl_used++;
2960 return 0;
2961}
2962
2963#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2964#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2965#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2966#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2967#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2968#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2969#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2970#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2971#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2972#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2973#define ALC880_PIN_CD_NID 0x1c
2974
2975/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002976static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2977 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002978{
2979 hda_nid_t nid;
2980 int assigned[4];
2981 int i, j;
2982
2983 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002984 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002985
2986 /* check the pins hardwired to audio widget */
2987 for (i = 0; i < cfg->line_outs; i++) {
2988 nid = cfg->line_out_pins[i];
2989 if (alc880_is_fixed_pin(nid)) {
2990 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002991 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002992 assigned[idx] = 1;
2993 }
2994 }
2995 /* left pins can be connect to any audio widget */
2996 for (i = 0; i < cfg->line_outs; i++) {
2997 nid = cfg->line_out_pins[i];
2998 if (alc880_is_fixed_pin(nid))
2999 continue;
3000 /* search for an empty channel */
3001 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003002 if (!assigned[j]) {
3003 spec->multiout.dac_nids[i] =
3004 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003005 assigned[j] = 1;
3006 break;
3007 }
3008 }
3009 }
3010 spec->multiout.num_dacs = cfg->line_outs;
3011 return 0;
3012}
3013
3014/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003015static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3016 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017{
3018 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003019 static const char *chname[4] = {
3020 "Front", "Surround", NULL /*CLFE*/, "Side"
3021 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003022 hda_nid_t nid;
3023 int i, err;
3024
3025 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003026 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003027 continue;
3028 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3029 if (i == 2) {
3030 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003031 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3032 "Center Playback Volume",
3033 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3034 HDA_OUTPUT));
3035 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003036 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003037 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3038 "LFE Playback Volume",
3039 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3040 HDA_OUTPUT));
3041 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003042 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003043 err = add_control(spec, ALC_CTL_BIND_MUTE,
3044 "Center Playback Switch",
3045 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3046 HDA_INPUT));
3047 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003048 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003049 err = add_control(spec, ALC_CTL_BIND_MUTE,
3050 "LFE Playback Switch",
3051 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3052 HDA_INPUT));
3053 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003054 return err;
3055 } else {
3056 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003057 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3058 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3059 HDA_OUTPUT));
3060 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003061 return err;
3062 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003063 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3064 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3065 HDA_INPUT));
3066 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003067 return err;
3068 }
3069 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003070 return 0;
3071}
3072
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003073/* add playback controls for speaker and HP outputs */
3074static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3075 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076{
3077 hda_nid_t nid;
3078 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003079 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003080
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003081 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003082 return 0;
3083
3084 if (alc880_is_fixed_pin(pin)) {
3085 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003086 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003087 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003089 else
3090 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091 /* control HP volume/switch on the output mixer amp */
3092 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003093 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003094 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3095 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3096 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003098 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003099 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3100 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3101 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003102 return err;
3103 } else if (alc880_is_multi_pin(pin)) {
3104 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003106 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003107 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3108 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3109 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110 return err;
3111 }
3112 return 0;
3113}
3114
3115/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003116static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3117 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003118 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003119{
3120 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003121 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122
3123 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003124 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3125 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3126 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127 return err;
3128 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003129 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3130 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3131 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132 return err;
3133 return 0;
3134}
3135
3136/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003137static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3138 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003140 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003141 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003142
3143 for (i = 0; i < AUTO_PIN_LAST; i++) {
3144 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003145 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003146 err = new_analog_input(spec, cfg->input_pins[i],
3147 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003148 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003149 if (err < 0)
3150 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003151 imux->items[imux->num_items].label =
3152 auto_pin_cfg_labels[i];
3153 imux->items[imux->num_items].index =
3154 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003155 imux->num_items++;
3156 }
3157 }
3158 return 0;
3159}
3160
Kailang Yangdf694da2005-12-05 19:42:22 +01003161static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3162 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003163 int dac_idx)
3164{
3165 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003166 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3167 pin_type);
3168 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3169 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003170 /* need the manual connection? */
3171 if (alc880_is_multi_pin(nid)) {
3172 struct alc_spec *spec = codec->spec;
3173 int idx = alc880_multi_pin_idx(nid);
3174 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3175 AC_VERB_SET_CONNECT_SEL,
3176 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3177 }
3178}
3179
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003180static int get_pin_type(int line_out_type)
3181{
3182 if (line_out_type == AUTO_PIN_HP_OUT)
3183 return PIN_HP;
3184 else
3185 return PIN_OUT;
3186}
3187
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003188static void alc880_auto_init_multi_out(struct hda_codec *codec)
3189{
3190 struct alc_spec *spec = codec->spec;
3191 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003192
3193 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003194 for (i = 0; i < spec->autocfg.line_outs; i++) {
3195 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003196 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3197 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 }
3199}
3200
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003201static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003202{
3203 struct alc_spec *spec = codec->spec;
3204 hda_nid_t pin;
3205
Takashi Iwai82bc9552006-03-21 11:24:42 +01003206 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003207 if (pin) /* connect to front */
3208 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003209 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210 if (pin) /* connect to front */
3211 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3212}
3213
3214static void alc880_auto_init_analog_input(struct hda_codec *codec)
3215{
3216 struct alc_spec *spec = codec->spec;
3217 int i;
3218
3219 for (i = 0; i < AUTO_PIN_LAST; i++) {
3220 hda_nid_t nid = spec->autocfg.input_pins[i];
3221 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003222 snd_hda_codec_write(codec, nid, 0,
3223 AC_VERB_SET_PIN_WIDGET_CONTROL,
3224 i <= AUTO_PIN_FRONT_MIC ?
3225 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003226 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003227 snd_hda_codec_write(codec, nid, 0,
3228 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229 AMP_OUT_MUTE);
3230 }
3231 }
3232}
3233
3234/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003235/* return 1 if successful, 0 if the proper config is not found,
3236 * or a negative error code
3237 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238static int alc880_parse_auto_config(struct hda_codec *codec)
3239{
3240 struct alc_spec *spec = codec->spec;
3241 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003242 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003244 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3245 alc880_ignore);
3246 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003248 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003249 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003250
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003251 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3252 if (err < 0)
3253 return err;
3254 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3255 if (err < 0)
3256 return err;
3257 err = alc880_auto_create_extra_out(spec,
3258 spec->autocfg.speaker_pins[0],
3259 "Speaker");
3260 if (err < 0)
3261 return err;
3262 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3263 "Headphone");
3264 if (err < 0)
3265 return err;
3266 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3267 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 return err;
3269
3270 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3271
3272 if (spec->autocfg.dig_out_pin)
3273 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3274 if (spec->autocfg.dig_in_pin)
3275 spec->dig_in_nid = ALC880_DIGIN_NID;
3276
3277 if (spec->kctl_alloc)
3278 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3279
3280 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3281
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003282 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 spec->input_mux = &spec->private_imux;
3284
3285 return 1;
3286}
3287
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003288/* additional initialization for auto-configuration model */
3289static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003290{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003291 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003292 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294}
3295
3296/*
3297 * OK, here we have finally the patch for ALC880
3298 */
3299
Linus Torvalds1da177e2005-04-16 15:20:36 -07003300static int patch_alc880(struct hda_codec *codec)
3301{
3302 struct alc_spec *spec;
3303 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003304 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003305
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003306 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003307 if (spec == NULL)
3308 return -ENOMEM;
3309
3310 codec->spec = spec;
3311
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003312 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3313 alc880_models,
3314 alc880_cfg_tbl);
3315 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003316 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3317 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003319 }
3320
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003321 if (board_config == ALC880_AUTO) {
3322 /* automatic parse from the BIOS config */
3323 err = alc880_parse_auto_config(codec);
3324 if (err < 0) {
3325 alc_free(codec);
3326 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003327 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003328 printk(KERN_INFO
3329 "hda_codec: Cannot set up configuration "
3330 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003331 board_config = ALC880_3ST;
3332 }
3333 }
3334
Kailang Yangdf694da2005-12-05 19:42:22 +01003335 if (board_config != ALC880_AUTO)
3336 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003337
3338 spec->stream_name_analog = "ALC880 Analog";
3339 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3340 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3341
3342 spec->stream_name_digital = "ALC880 Digital";
3343 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3344 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3345
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003346 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003347 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003348 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003349 /* get type */
3350 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003351 if (wcap != AC_WID_AUD_IN) {
3352 spec->adc_nids = alc880_adc_nids_alt;
3353 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003354 spec->mixers[spec->num_mixers] =
3355 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003356 spec->num_mixers++;
3357 } else {
3358 spec->adc_nids = alc880_adc_nids;
3359 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3360 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3361 spec->num_mixers++;
3362 }
3363 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364
3365 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003366 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003367 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003368
3369 return 0;
3370}
3371
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003372
Linus Torvalds1da177e2005-04-16 15:20:36 -07003373/*
3374 * ALC260 support
3375 */
3376
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003377static hda_nid_t alc260_dac_nids[1] = {
3378 /* front */
3379 0x02,
3380};
3381
3382static hda_nid_t alc260_adc_nids[1] = {
3383 /* ADC0 */
3384 0x04,
3385};
3386
Kailang Yangdf694da2005-12-05 19:42:22 +01003387static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003388 /* ADC1 */
3389 0x05,
3390};
3391
Kailang Yangdf694da2005-12-05 19:42:22 +01003392static hda_nid_t alc260_hp_adc_nids[2] = {
3393 /* ADC1, 0 */
3394 0x05, 0x04
3395};
3396
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003397/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3398 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3399 */
3400static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003401 /* ADC0, ADC1 */
3402 0x04, 0x05
3403};
3404
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003405#define ALC260_DIGOUT_NID 0x03
3406#define ALC260_DIGIN_NID 0x06
3407
3408static struct hda_input_mux alc260_capture_source = {
3409 .num_items = 4,
3410 .items = {
3411 { "Mic", 0x0 },
3412 { "Front Mic", 0x1 },
3413 { "Line", 0x2 },
3414 { "CD", 0x4 },
3415 },
3416};
3417
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003418/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003419 * headphone jack and the internal CD lines since these are the only pins at
3420 * which audio can appear. For flexibility, also allow the option of
3421 * recording the mixer output on the second ADC (ADC0 doesn't have a
3422 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003423 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003424static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3425 {
3426 .num_items = 3,
3427 .items = {
3428 { "Mic/Line", 0x0 },
3429 { "CD", 0x4 },
3430 { "Headphone", 0x2 },
3431 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003432 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003433 {
3434 .num_items = 4,
3435 .items = {
3436 { "Mic/Line", 0x0 },
3437 { "CD", 0x4 },
3438 { "Headphone", 0x2 },
3439 { "Mixer", 0x5 },
3440 },
3441 },
3442
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003443};
3444
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003445/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3446 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003447 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003448static struct hda_input_mux alc260_acer_capture_sources[2] = {
3449 {
3450 .num_items = 4,
3451 .items = {
3452 { "Mic", 0x0 },
3453 { "Line", 0x2 },
3454 { "CD", 0x4 },
3455 { "Headphone", 0x5 },
3456 },
3457 },
3458 {
3459 .num_items = 5,
3460 .items = {
3461 { "Mic", 0x0 },
3462 { "Line", 0x2 },
3463 { "CD", 0x4 },
3464 { "Headphone", 0x6 },
3465 { "Mixer", 0x5 },
3466 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003467 },
3468};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003469/*
3470 * This is just place-holder, so there's something for alc_build_pcms to look
3471 * at when it calculates the maximum number of channels. ALC260 has no mixer
3472 * element which allows changing the channel mode, so the verb list is
3473 * never used.
3474 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003475static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003476 { 2, NULL },
3477};
3478
Kailang Yangdf694da2005-12-05 19:42:22 +01003479
3480/* Mixer combinations
3481 *
3482 * basic: base_output + input + pc_beep + capture
3483 * HP: base_output + input + capture_alt
3484 * HP_3013: hp_3013 + input + capture
3485 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003486 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003487 */
3488
3489static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003490 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003491 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003492 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3493 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3494 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3495 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3496 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003497};
Kailang Yangdf694da2005-12-05 19:42:22 +01003498
3499static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003500 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3501 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3502 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3503 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3505 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3506 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3507 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 { } /* end */
3509};
3510
Kailang Yangdf694da2005-12-05 19:42:22 +01003511static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3512 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3513 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3514 { } /* end */
3515};
3516
3517static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3518 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3519 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3520 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3521 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3522 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3523 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3524 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3525 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003526 { } /* end */
3527};
3528
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003529/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3530 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3531 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003532static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003533 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003534 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003535 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003536 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3537 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3538 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3539 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003540 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003541 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3542 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3543 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003544 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003545 { } /* end */
3546};
3547
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003548/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3549 * versions of the ALC260 don't act on requests to enable mic bias from NID
3550 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3551 * datasheet doesn't mention this restriction. At this stage it's not clear
3552 * whether this behaviour is intentional or is a hardware bug in chip
3553 * revisions available in early 2006. Therefore for now allow the
3554 * "Headphone Jack Mode" control to span all choices, but if it turns out
3555 * that the lack of mic bias for this NID is intentional we could change the
3556 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3557 *
3558 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3559 * don't appear to make the mic bias available from the "line" jack, even
3560 * though the NID used for this jack (0x14) can supply it. The theory is
3561 * that perhaps Acer have included blocking capacitors between the ALC260
3562 * and the output jack. If this turns out to be the case for all such
3563 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3564 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003565 *
3566 * The C20x Tablet series have a mono internal speaker which is controlled
3567 * via the chip's Mono sum widget and pin complex, so include the necessary
3568 * controls for such models. On models without a "mono speaker" the control
3569 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003570 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003571static struct snd_kcontrol_new alc260_acer_mixer[] = {
3572 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3573 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003574 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003575 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3576 HDA_OUTPUT),
3577 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3578 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003579 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3580 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3582 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3583 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3584 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3585 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3586 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3587 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3588 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3589 { } /* end */
3590};
3591
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003592/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3593 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3594 */
3595static struct snd_kcontrol_new alc260_will_mixer[] = {
3596 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3597 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3599 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3600 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3601 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3602 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3603 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3604 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3605 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3606 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3607 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3608 { } /* end */
3609};
3610
3611/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3612 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3613 */
3614static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3615 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3616 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3618 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3619 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3620 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3621 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3622 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3623 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3624 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3625 { } /* end */
3626};
3627
Kailang Yangdf694da2005-12-05 19:42:22 +01003628/* capture mixer elements */
3629static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003630 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3631 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003632 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3633 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003634 {
3635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003636 /* The multiple "Capture Source" controls confuse alsamixer
3637 * So call somewhat different..
3638 * FIXME: the controls appear in the "playback" view!
3639 */
3640 /* .name = "Capture Source", */
3641 .name = "Input Source",
3642 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003643 .info = alc_mux_enum_info,
3644 .get = alc_mux_enum_get,
3645 .put = alc_mux_enum_put,
3646 },
3647 { } /* end */
3648};
3649
Kailang Yangdf694da2005-12-05 19:42:22 +01003650static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3651 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3652 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3653 {
3654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3655 /* The multiple "Capture Source" controls confuse alsamixer
3656 * So call somewhat different..
3657 * FIXME: the controls appear in the "playback" view!
3658 */
3659 /* .name = "Capture Source", */
3660 .name = "Input Source",
3661 .count = 1,
3662 .info = alc_mux_enum_info,
3663 .get = alc_mux_enum_get,
3664 .put = alc_mux_enum_put,
3665 },
3666 { } /* end */
3667};
3668
3669/*
3670 * initialization verbs
3671 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003672static struct hda_verb alc260_init_verbs[] = {
3673 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003674 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003675 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003676 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003677 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003678 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003679 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003680 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003681 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003683 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003684 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003685 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003686 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003687 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003688 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003689 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003690 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3691 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003692 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003693 /* set connection select to line in (default select for this ADC) */
3694 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003695 /* mute capture amp left and right */
3696 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3697 /* set connection select to line in (default select for this ADC) */
3698 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003699 /* set vol=0 Line-Out mixer amp left and right */
3700 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3701 /* unmute pin widget amp left and right (no gain on this amp) */
3702 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3703 /* set vol=0 HP mixer amp left and right */
3704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3705 /* unmute pin widget amp left and right (no gain on this amp) */
3706 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3707 /* set vol=0 Mono mixer amp left and right */
3708 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3709 /* unmute pin widget amp left and right (no gain on this amp) */
3710 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3711 /* unmute LINE-2 out pin */
3712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003713 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3714 * Line In 2 = 0x03
3715 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003716 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003718 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003720 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003722 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003723 /* mute Front out path */
3724 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3725 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3726 /* mute Headphone out path */
3727 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3728 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3729 /* mute Mono out path */
3730 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3731 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003732 { }
3733};
3734
Takashi Iwai474167d2006-05-17 17:17:43 +02003735#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003736static struct hda_verb alc260_hp_init_verbs[] = {
3737 /* Headphone and output */
3738 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3739 /* mono output */
3740 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3741 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3742 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3743 /* Mic2 (front panel) pin widget for input and vref at 80% */
3744 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3745 /* Line In pin widget for input */
3746 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3747 /* Line-2 pin widget for output */
3748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3749 /* CD pin widget for input */
3750 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3751 /* unmute amp left and right */
3752 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3753 /* set connection select to line in (default select for this ADC) */
3754 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3755 /* unmute Line-Out mixer amp left and right (volume = 0) */
3756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3757 /* mute pin widget amp left and right (no gain on this amp) */
3758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3759 /* unmute HP mixer amp left and right (volume = 0) */
3760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3761 /* mute pin widget amp left and right (no gain on this amp) */
3762 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003763 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3764 * Line In 2 = 0x03
3765 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003766 /* unmute CD */
3767 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3768 /* unmute Line In */
3769 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3770 /* unmute Mic */
3771 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3772 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3773 /* Unmute Front out path */
3774 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3776 /* Unmute Headphone out path */
3777 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3778 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3779 /* Unmute Mono out path */
3780 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3781 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3782 { }
3783};
Takashi Iwai474167d2006-05-17 17:17:43 +02003784#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003785
3786static struct hda_verb alc260_hp_3013_init_verbs[] = {
3787 /* Line out and output */
3788 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3789 /* mono output */
3790 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3791 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3792 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3793 /* Mic2 (front panel) pin widget for input and vref at 80% */
3794 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3795 /* Line In pin widget for input */
3796 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3797 /* Headphone pin widget for output */
3798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3799 /* CD pin widget for input */
3800 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3801 /* unmute amp left and right */
3802 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3803 /* set connection select to line in (default select for this ADC) */
3804 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3805 /* unmute Line-Out mixer amp left and right (volume = 0) */
3806 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3807 /* mute pin widget amp left and right (no gain on this amp) */
3808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3809 /* unmute HP mixer amp left and right (volume = 0) */
3810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3811 /* mute pin widget amp left and right (no gain on this amp) */
3812 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003813 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3814 * Line In 2 = 0x03
3815 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003816 /* unmute CD */
3817 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3818 /* unmute Line In */
3819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3820 /* unmute Mic */
3821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3822 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3823 /* Unmute Front out path */
3824 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3825 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3826 /* Unmute Headphone out path */
3827 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3828 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3829 /* Unmute Mono out path */
3830 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3831 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3832 { }
3833};
3834
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003835/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003836 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3837 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003838 */
3839static struct hda_verb alc260_fujitsu_init_verbs[] = {
3840 /* Disable all GPIOs */
3841 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3842 /* Internal speaker is connected to headphone pin */
3843 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3844 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003846 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3847 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3848 /* Ensure all other unused pins are disabled and muted. */
3849 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003851 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003852 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003853 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003854 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003857
Jonathan Woithef7ace402006-02-28 11:46:14 +01003858 /* Disable digital (SPDIF) pins */
3859 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3860 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003861
Jonathan Woithef7ace402006-02-28 11:46:14 +01003862 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3863 * when acting as an output.
3864 */
3865 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3866
3867 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3870 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3871 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3872 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3874 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3875 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3876 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003877
Jonathan Woithef7ace402006-02-28 11:46:14 +01003878 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3879 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3880 /* Unmute Line1 pin widget output buffer since it starts as an output.
3881 * If the pin mode is changed by the user the pin mode control will
3882 * take care of enabling the pin's input/output buffers as needed.
3883 * Therefore there's no need to enable the input buffer at this
3884 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003885 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003886 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003887 /* Unmute input buffer of pin widget used for Line-in (no equiv
3888 * mixer ctrl)
3889 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003890 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003891
Jonathan Woithef7ace402006-02-28 11:46:14 +01003892 /* Mute capture amp left and right */
3893 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3894 /* Set ADC connection select to match default mixer setting - line
3895 * in (on mic1 pin)
3896 */
3897 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003898
Jonathan Woithef7ace402006-02-28 11:46:14 +01003899 /* Do the same for the second ADC: mute capture input amp and
3900 * set ADC connection to line in (on mic1 pin)
3901 */
3902 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3903 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003904
Jonathan Woithef7ace402006-02-28 11:46:14 +01003905 /* Mute all inputs to mixer widget (even unconnected ones) */
3906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003914
3915 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003916};
3917
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003918/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3919 * similar laptops (adapted from Fujitsu init verbs).
3920 */
3921static struct hda_verb alc260_acer_init_verbs[] = {
3922 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3923 * the headphone jack. Turn this on and rely on the standard mute
3924 * methods whenever the user wants to turn these outputs off.
3925 */
3926 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3927 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3928 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3929 /* Internal speaker/Headphone jack is connected to Line-out pin */
3930 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3931 /* Internal microphone/Mic jack is connected to Mic1 pin */
3932 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3933 /* Line In jack is connected to Line1 pin */
3934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003935 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3936 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003937 /* Ensure all other unused pins are disabled and muted. */
3938 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3939 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003940 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3941 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3942 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3944 /* Disable digital (SPDIF) pins */
3945 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3946 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3947
3948 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3949 * bus when acting as outputs.
3950 */
3951 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3952 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3953
3954 /* Start with output sum widgets muted and their output gains at min */
3955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3956 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3957 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3958 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3960 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3961 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3962 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3963 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3964
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003965 /* Unmute Line-out pin widget amp left and right
3966 * (no equiv mixer ctrl)
3967 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003968 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003969 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3970 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003971 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3972 * inputs. If the pin mode is changed by the user the pin mode control
3973 * will take care of enabling the pin's input/output buffers as needed.
3974 * Therefore there's no need to enable the input buffer at this
3975 * stage.
3976 */
3977 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3979
3980 /* Mute capture amp left and right */
3981 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3982 /* Set ADC connection select to match default mixer setting - mic
3983 * (on mic1 pin)
3984 */
3985 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3986
3987 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003988 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003989 */
3990 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003991 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003992
3993 /* Mute all inputs to mixer widget (even unconnected ones) */
3994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3999 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4002
4003 { }
4004};
4005
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004006static struct hda_verb alc260_will_verbs[] = {
4007 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4008 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4009 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4010 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4011 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4012 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4013 {}
4014};
4015
4016static struct hda_verb alc260_replacer_672v_verbs[] = {
4017 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4018 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4019 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4020
4021 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4022 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4023 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4024
4025 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4026 {}
4027};
4028
4029/* toggle speaker-output according to the hp-jack state */
4030static void alc260_replacer_672v_automute(struct hda_codec *codec)
4031{
4032 unsigned int present;
4033
4034 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4035 present = snd_hda_codec_read(codec, 0x0f, 0,
4036 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4037 if (present) {
4038 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4039 snd_hda_codec_write(codec, 0x0f, 0,
4040 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4041 } else {
4042 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4043 snd_hda_codec_write(codec, 0x0f, 0,
4044 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4045 }
4046}
4047
4048static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4049 unsigned int res)
4050{
4051 if ((res >> 26) == ALC880_HP_EVENT)
4052 alc260_replacer_672v_automute(codec);
4053}
4054
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004055/* Test configuration for debugging, modelled after the ALC880 test
4056 * configuration.
4057 */
4058#ifdef CONFIG_SND_DEBUG
4059static hda_nid_t alc260_test_dac_nids[1] = {
4060 0x02,
4061};
4062static hda_nid_t alc260_test_adc_nids[2] = {
4063 0x04, 0x05,
4064};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004065/* For testing the ALC260, each input MUX needs its own definition since
4066 * the signal assignments are different. This assumes that the first ADC
4067 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004068 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004069static struct hda_input_mux alc260_test_capture_sources[2] = {
4070 {
4071 .num_items = 7,
4072 .items = {
4073 { "MIC1 pin", 0x0 },
4074 { "MIC2 pin", 0x1 },
4075 { "LINE1 pin", 0x2 },
4076 { "LINE2 pin", 0x3 },
4077 { "CD pin", 0x4 },
4078 { "LINE-OUT pin", 0x5 },
4079 { "HP-OUT pin", 0x6 },
4080 },
4081 },
4082 {
4083 .num_items = 8,
4084 .items = {
4085 { "MIC1 pin", 0x0 },
4086 { "MIC2 pin", 0x1 },
4087 { "LINE1 pin", 0x2 },
4088 { "LINE2 pin", 0x3 },
4089 { "CD pin", 0x4 },
4090 { "Mixer", 0x5 },
4091 { "LINE-OUT pin", 0x6 },
4092 { "HP-OUT pin", 0x7 },
4093 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004094 },
4095};
4096static struct snd_kcontrol_new alc260_test_mixer[] = {
4097 /* Output driver widgets */
4098 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4099 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4100 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4101 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4102 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4103 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4104
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004105 /* Modes for retasking pin widgets
4106 * Note: the ALC260 doesn't seem to act on requests to enable mic
4107 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4108 * mention this restriction. At this stage it's not clear whether
4109 * this behaviour is intentional or is a hardware bug in chip
4110 * revisions available at least up until early 2006. Therefore for
4111 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4112 * choices, but if it turns out that the lack of mic bias for these
4113 * NIDs is intentional we could change their modes from
4114 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4115 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004116 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4117 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4118 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4119 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4120 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4121 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4122
4123 /* Loopback mixer controls */
4124 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4125 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4126 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4127 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4128 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4129 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4130 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4131 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4132 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4133 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4134 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4135 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4136 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4137 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4138 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4139 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004140
4141 /* Controls for GPIO pins, assuming they are configured as outputs */
4142 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4143 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4144 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4145 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4146
Jonathan Woithe92621f12006-02-28 11:47:47 +01004147 /* Switches to allow the digital IO pins to be enabled. The datasheet
4148 * is ambigious as to which NID is which; testing on laptops which
4149 * make this output available should provide clarification.
4150 */
4151 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4152 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4153
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004154 { } /* end */
4155};
4156static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004157 /* Enable all GPIOs as outputs with an initial value of 0 */
4158 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4159 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4160 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4161
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004162 /* Enable retasking pins as output, initially without power amp */
4163 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4164 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4166 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4167 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4168 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4169
Jonathan Woithe92621f12006-02-28 11:47:47 +01004170 /* Disable digital (SPDIF) pins initially, but users can enable
4171 * them via a mixer switch. In the case of SPDIF-out, this initverb
4172 * payload also sets the generation to 0, output to be in "consumer"
4173 * PCM format, copyright asserted, no pre-emphasis and no validity
4174 * control.
4175 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004176 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4177 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4178
Jonathan Woithef7ace402006-02-28 11:46:14 +01004179 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004180 * OUT1 sum bus when acting as an output.
4181 */
4182 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4183 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4184 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4185 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4186
4187 /* Start with output sum widgets muted and their output gains at min */
4188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4190 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4194 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4195 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4196 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4197
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004198 /* Unmute retasking pin widget output buffers since the default
4199 * state appears to be output. As the pin mode is changed by the
4200 * user the pin mode control will take care of enabling the pin's
4201 * input/output buffers as needed.
4202 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004203 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4207 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4208 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4209 /* Also unmute the mono-out pin widget */
4210 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4211
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004212 /* Mute capture amp left and right */
4213 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004214 /* Set ADC connection select to match default mixer setting (mic1
4215 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004216 */
4217 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4218
4219 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004220 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004221 */
4222 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4223 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4224
4225 /* Mute all inputs to mixer widget (even unconnected ones) */
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4234
4235 { }
4236};
4237#endif
4238
Linus Torvalds1da177e2005-04-16 15:20:36 -07004239static struct hda_pcm_stream alc260_pcm_analog_playback = {
4240 .substreams = 1,
4241 .channels_min = 2,
4242 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004243};
4244
4245static struct hda_pcm_stream alc260_pcm_analog_capture = {
4246 .substreams = 1,
4247 .channels_min = 2,
4248 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004249};
4250
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004251#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4252#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4253
Kailang Yangdf694da2005-12-05 19:42:22 +01004254/*
4255 * for BIOS auto-configuration
4256 */
4257
4258static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4259 const char *pfx)
4260{
4261 hda_nid_t nid_vol;
4262 unsigned long vol_val, sw_val;
4263 char name[32];
4264 int err;
4265
4266 if (nid >= 0x0f && nid < 0x11) {
4267 nid_vol = nid - 0x7;
4268 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4269 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4270 } else if (nid == 0x11) {
4271 nid_vol = nid - 0x7;
4272 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4273 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4274 } else if (nid >= 0x12 && nid <= 0x15) {
4275 nid_vol = 0x08;
4276 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4277 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4278 } else
4279 return 0; /* N/A */
4280
4281 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4283 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004284 return err;
4285 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004286 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4287 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004288 return err;
4289 return 1;
4290}
4291
4292/* add playback controls from the parsed DAC table */
4293static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4294 const struct auto_pin_cfg *cfg)
4295{
4296 hda_nid_t nid;
4297 int err;
4298
4299 spec->multiout.num_dacs = 1;
4300 spec->multiout.dac_nids = spec->private_dac_nids;
4301 spec->multiout.dac_nids[0] = 0x02;
4302
4303 nid = cfg->line_out_pins[0];
4304 if (nid) {
4305 err = alc260_add_playback_controls(spec, nid, "Front");
4306 if (err < 0)
4307 return err;
4308 }
4309
Takashi Iwai82bc9552006-03-21 11:24:42 +01004310 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004311 if (nid) {
4312 err = alc260_add_playback_controls(spec, nid, "Speaker");
4313 if (err < 0)
4314 return err;
4315 }
4316
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004317 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004318 if (nid) {
4319 err = alc260_add_playback_controls(spec, nid, "Headphone");
4320 if (err < 0)
4321 return err;
4322 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004323 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004324}
4325
4326/* create playback/capture controls for input pins */
4327static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4328 const struct auto_pin_cfg *cfg)
4329{
Kailang Yangdf694da2005-12-05 19:42:22 +01004330 struct hda_input_mux *imux = &spec->private_imux;
4331 int i, err, idx;
4332
4333 for (i = 0; i < AUTO_PIN_LAST; i++) {
4334 if (cfg->input_pins[i] >= 0x12) {
4335 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004336 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004337 auto_pin_cfg_labels[i], idx,
4338 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004339 if (err < 0)
4340 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004341 imux->items[imux->num_items].label =
4342 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004343 imux->items[imux->num_items].index = idx;
4344 imux->num_items++;
4345 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004346 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004347 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004348 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004349 auto_pin_cfg_labels[i], idx,
4350 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004351 if (err < 0)
4352 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004353 imux->items[imux->num_items].label =
4354 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004355 imux->items[imux->num_items].index = idx;
4356 imux->num_items++;
4357 }
4358 }
4359 return 0;
4360}
4361
4362static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4363 hda_nid_t nid, int pin_type,
4364 int sel_idx)
4365{
4366 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004367 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4368 pin_type);
4369 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4370 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004371 /* need the manual connection? */
4372 if (nid >= 0x12) {
4373 int idx = nid - 0x12;
4374 snd_hda_codec_write(codec, idx + 0x0b, 0,
4375 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004376 }
4377}
4378
4379static void alc260_auto_init_multi_out(struct hda_codec *codec)
4380{
4381 struct alc_spec *spec = codec->spec;
4382 hda_nid_t nid;
4383
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004384 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004385 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004386 if (nid) {
4387 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4388 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4389 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004390
Takashi Iwai82bc9552006-03-21 11:24:42 +01004391 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004392 if (nid)
4393 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4394
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004395 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004396 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004397 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004398}
Kailang Yangdf694da2005-12-05 19:42:22 +01004399
4400#define ALC260_PIN_CD_NID 0x16
4401static void alc260_auto_init_analog_input(struct hda_codec *codec)
4402{
4403 struct alc_spec *spec = codec->spec;
4404 int i;
4405
4406 for (i = 0; i < AUTO_PIN_LAST; i++) {
4407 hda_nid_t nid = spec->autocfg.input_pins[i];
4408 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004409 snd_hda_codec_write(codec, nid, 0,
4410 AC_VERB_SET_PIN_WIDGET_CONTROL,
4411 i <= AUTO_PIN_FRONT_MIC ?
4412 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004413 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004414 snd_hda_codec_write(codec, nid, 0,
4415 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004416 AMP_OUT_MUTE);
4417 }
4418 }
4419}
4420
4421/*
4422 * generic initialization of ADC, input mixers and output mixers
4423 */
4424static struct hda_verb alc260_volume_init_verbs[] = {
4425 /*
4426 * Unmute ADC0-1 and set the default input to mic-in
4427 */
4428 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4429 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4430 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4431 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4432
4433 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4434 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004435 * Note: PASD motherboards uses the Line In 2 as the input for
4436 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004437 */
4438 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4441 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4444
4445 /*
4446 * Set up output mixers (0x08 - 0x0a)
4447 */
4448 /* set vol=0 to output mixers */
4449 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4451 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4452 /* set up input amps for analog loopback */
4453 /* Amp Indices: DAC = 0, mixer = 1 */
4454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4455 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4457 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4458 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4459 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4460
4461 { }
4462};
4463
4464static int alc260_parse_auto_config(struct hda_codec *codec)
4465{
4466 struct alc_spec *spec = codec->spec;
4467 unsigned int wcap;
4468 int err;
4469 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4470
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004471 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4472 alc260_ignore);
4473 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004474 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004475 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4476 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004477 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004478 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004479 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004480 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4481 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004482 return err;
4483
4484 spec->multiout.max_channels = 2;
4485
4486 if (spec->autocfg.dig_out_pin)
4487 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4488 if (spec->kctl_alloc)
4489 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4490
4491 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4492
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004493 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004494 spec->input_mux = &spec->private_imux;
4495
4496 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004497 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004498 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4499 if (wcap != AC_WID_AUD_IN) {
4500 spec->adc_nids = alc260_adc_nids_alt;
4501 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4502 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004503 } else {
4504 spec->adc_nids = alc260_adc_nids;
4505 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4506 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004507 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004508 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004509
4510 return 1;
4511}
4512
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004513/* additional initialization for auto-configuration model */
4514static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004515{
Kailang Yangdf694da2005-12-05 19:42:22 +01004516 alc260_auto_init_multi_out(codec);
4517 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004518}
4519
4520/*
4521 * ALC260 configurations
4522 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004523static const char *alc260_models[ALC260_MODEL_LAST] = {
4524 [ALC260_BASIC] = "basic",
4525 [ALC260_HP] = "hp",
4526 [ALC260_HP_3013] = "hp-3013",
4527 [ALC260_FUJITSU_S702X] = "fujitsu",
4528 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004529 [ALC260_WILL] = "will",
4530 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004531#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004532 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004533#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004534 [ALC260_AUTO] = "auto",
4535};
4536
4537static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004538 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004539 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004540 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004541 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004542 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4543 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4544 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4545 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4546 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4547 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4548 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4549 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4550 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4551 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4552 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4553 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004554 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4555 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004556 {}
4557};
4558
Kailang Yangdf694da2005-12-05 19:42:22 +01004559static struct alc_config_preset alc260_presets[] = {
4560 [ALC260_BASIC] = {
4561 .mixers = { alc260_base_output_mixer,
4562 alc260_input_mixer,
4563 alc260_pc_beep_mixer,
4564 alc260_capture_mixer },
4565 .init_verbs = { alc260_init_verbs },
4566 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4567 .dac_nids = alc260_dac_nids,
4568 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4569 .adc_nids = alc260_adc_nids,
4570 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4571 .channel_mode = alc260_modes,
4572 .input_mux = &alc260_capture_source,
4573 },
4574 [ALC260_HP] = {
4575 .mixers = { alc260_base_output_mixer,
4576 alc260_input_mixer,
4577 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004578 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004579 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4580 .dac_nids = alc260_dac_nids,
4581 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4582 .adc_nids = alc260_hp_adc_nids,
4583 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4584 .channel_mode = alc260_modes,
4585 .input_mux = &alc260_capture_source,
4586 },
4587 [ALC260_HP_3013] = {
4588 .mixers = { alc260_hp_3013_mixer,
4589 alc260_input_mixer,
4590 alc260_capture_alt_mixer },
4591 .init_verbs = { alc260_hp_3013_init_verbs },
4592 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4593 .dac_nids = alc260_dac_nids,
4594 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4595 .adc_nids = alc260_hp_adc_nids,
4596 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4597 .channel_mode = alc260_modes,
4598 .input_mux = &alc260_capture_source,
4599 },
4600 [ALC260_FUJITSU_S702X] = {
4601 .mixers = { alc260_fujitsu_mixer,
4602 alc260_capture_mixer },
4603 .init_verbs = { alc260_fujitsu_init_verbs },
4604 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4605 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004606 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4607 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004608 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4609 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004610 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4611 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004612 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004613 [ALC260_ACER] = {
4614 .mixers = { alc260_acer_mixer,
4615 alc260_capture_mixer },
4616 .init_verbs = { alc260_acer_init_verbs },
4617 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4618 .dac_nids = alc260_dac_nids,
4619 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4620 .adc_nids = alc260_dual_adc_nids,
4621 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4622 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004623 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4624 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004625 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004626 [ALC260_WILL] = {
4627 .mixers = { alc260_will_mixer,
4628 alc260_capture_mixer },
4629 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4630 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4631 .dac_nids = alc260_dac_nids,
4632 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4633 .adc_nids = alc260_adc_nids,
4634 .dig_out_nid = ALC260_DIGOUT_NID,
4635 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4636 .channel_mode = alc260_modes,
4637 .input_mux = &alc260_capture_source,
4638 },
4639 [ALC260_REPLACER_672V] = {
4640 .mixers = { alc260_replacer_672v_mixer,
4641 alc260_capture_mixer },
4642 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4643 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4644 .dac_nids = alc260_dac_nids,
4645 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4646 .adc_nids = alc260_adc_nids,
4647 .dig_out_nid = ALC260_DIGOUT_NID,
4648 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4649 .channel_mode = alc260_modes,
4650 .input_mux = &alc260_capture_source,
4651 .unsol_event = alc260_replacer_672v_unsol_event,
4652 .init_hook = alc260_replacer_672v_automute,
4653 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004654#ifdef CONFIG_SND_DEBUG
4655 [ALC260_TEST] = {
4656 .mixers = { alc260_test_mixer,
4657 alc260_capture_mixer },
4658 .init_verbs = { alc260_test_init_verbs },
4659 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4660 .dac_nids = alc260_test_dac_nids,
4661 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4662 .adc_nids = alc260_test_adc_nids,
4663 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4664 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004665 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4666 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004667 },
4668#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004669};
4670
Linus Torvalds1da177e2005-04-16 15:20:36 -07004671static int patch_alc260(struct hda_codec *codec)
4672{
4673 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004674 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004675
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004676 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004677 if (spec == NULL)
4678 return -ENOMEM;
4679
4680 codec->spec = spec;
4681
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004682 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4683 alc260_models,
4684 alc260_cfg_tbl);
4685 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004686 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4687 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004688 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004689 }
4690
Kailang Yangdf694da2005-12-05 19:42:22 +01004691 if (board_config == ALC260_AUTO) {
4692 /* automatic parse from the BIOS config */
4693 err = alc260_parse_auto_config(codec);
4694 if (err < 0) {
4695 alc_free(codec);
4696 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004697 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004698 printk(KERN_INFO
4699 "hda_codec: Cannot set up configuration "
4700 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004701 board_config = ALC260_BASIC;
4702 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004703 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004704
Kailang Yangdf694da2005-12-05 19:42:22 +01004705 if (board_config != ALC260_AUTO)
4706 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004707
4708 spec->stream_name_analog = "ALC260 Analog";
4709 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4710 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4711
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004712 spec->stream_name_digital = "ALC260 Digital";
4713 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4714 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4715
Linus Torvalds1da177e2005-04-16 15:20:36 -07004716 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004717 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004718 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004719
4720 return 0;
4721}
4722
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004723
Linus Torvalds1da177e2005-04-16 15:20:36 -07004724/*
4725 * ALC882 support
4726 *
4727 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4728 * configuration. Each pin widget can choose any input DACs and a mixer.
4729 * Each ADC is connected from a mixer of all inputs. This makes possible
4730 * 6-channel independent captures.
4731 *
4732 * In addition, an independent DAC for the multi-playback (not used in this
4733 * driver yet).
4734 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004735#define ALC882_DIGOUT_NID 0x06
4736#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004737
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004738static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004739 { 8, NULL }
4740};
4741
4742static hda_nid_t alc882_dac_nids[4] = {
4743 /* front, rear, clfe, rear_surr */
4744 0x02, 0x03, 0x04, 0x05
4745};
4746
Kailang Yangdf694da2005-12-05 19:42:22 +01004747/* identical with ALC880 */
4748#define alc882_adc_nids alc880_adc_nids
4749#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004750
4751/* input MUX */
4752/* FIXME: should be a matrix-type input source selection */
4753
4754static struct hda_input_mux alc882_capture_source = {
4755 .num_items = 4,
4756 .items = {
4757 { "Mic", 0x0 },
4758 { "Front Mic", 0x1 },
4759 { "Line", 0x2 },
4760 { "CD", 0x4 },
4761 },
4762};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004763#define alc882_mux_enum_info alc_mux_enum_info
4764#define alc882_mux_enum_get alc_mux_enum_get
4765
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004766static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4767 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004768{
4769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4770 struct alc_spec *spec = codec->spec;
4771 const struct hda_input_mux *imux = spec->input_mux;
4772 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4773 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4774 hda_nid_t nid = capture_mixers[adc_idx];
4775 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4776 unsigned int i, idx;
4777
4778 idx = ucontrol->value.enumerated.item[0];
4779 if (idx >= imux->num_items)
4780 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004781 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004782 return 0;
4783 for (i = 0; i < imux->num_items; i++) {
4784 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4785 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4786 v | (imux->items[i].index << 8));
4787 }
4788 *cur_val = idx;
4789 return 1;
4790}
4791
Kailang Yangdf694da2005-12-05 19:42:22 +01004792/*
Kailang Yang272a5272007-05-14 11:00:38 +02004793 * 2ch mode
4794 */
4795static struct hda_verb alc882_3ST_ch2_init[] = {
4796 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4797 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4798 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4799 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4800 { } /* end */
4801};
4802
4803/*
4804 * 6ch mode
4805 */
4806static struct hda_verb alc882_3ST_ch6_init[] = {
4807 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4808 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4809 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4810 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4811 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4812 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4813 { } /* end */
4814};
4815
4816static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4817 { 2, alc882_3ST_ch2_init },
4818 { 6, alc882_3ST_ch6_init },
4819};
4820
4821/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004822 * 6ch mode
4823 */
4824static struct hda_verb alc882_sixstack_ch6_init[] = {
4825 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4826 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4827 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4828 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4829 { } /* end */
4830};
4831
4832/*
4833 * 8ch mode
4834 */
4835static struct hda_verb alc882_sixstack_ch8_init[] = {
4836 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4837 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4838 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4839 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4840 { } /* end */
4841};
4842
4843static struct hda_channel_mode alc882_sixstack_modes[2] = {
4844 { 6, alc882_sixstack_ch6_init },
4845 { 8, alc882_sixstack_ch8_init },
4846};
4847
Linus Torvalds1da177e2005-04-16 15:20:36 -07004848/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4849 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4850 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004851static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004852 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004853 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004854 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004855 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004856 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4857 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004858 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4859 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004860 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004861 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004862 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4863 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4864 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4865 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4866 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004868 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004869 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4870 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004871 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004872 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4873 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4874 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004875 { } /* end */
4876};
4877
Kailang Yangbdd148a2007-05-08 15:19:08 +02004878static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4881 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4882 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4883 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4884 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4886 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4887 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4888 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4889 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4890 { } /* end */
4891};
4892
Kailang Yang272a5272007-05-14 11:00:38 +02004893static struct snd_kcontrol_new alc882_targa_mixer[] = {
4894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4895 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4898 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4899 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4900 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4903 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4904 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4905 { } /* end */
4906};
4907
4908/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4909 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4910 */
4911static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4913 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4915 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4921 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4924 { } /* end */
4925};
4926
Kailang Yangdf694da2005-12-05 19:42:22 +01004927static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4928 {
4929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4930 .name = "Channel Mode",
4931 .info = alc_ch_mode_info,
4932 .get = alc_ch_mode_get,
4933 .put = alc_ch_mode_put,
4934 },
4935 { } /* end */
4936};
4937
Linus Torvalds1da177e2005-04-16 15:20:36 -07004938static struct hda_verb alc882_init_verbs[] = {
4939 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004943 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4945 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4946 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004947 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004948 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4949 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4950 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004951 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004952 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4953 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4954 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004955
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004956 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004959 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004960 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004963 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004964 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004965 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004966 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004967 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004968 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004969 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004970 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004971 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004972 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004973 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004974 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4975 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004976 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004977 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4978 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004979 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004980 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4981 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4982 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4983 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4984 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004985 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004986 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004987
4988 /* FIXME: use matrix-type input source selection */
4989 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4990 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4994 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004995 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4998 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005000 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5005 /* ADC1: mute amp left and right */
5006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005007 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005008 /* ADC2: mute amp left and right */
5009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005010 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005011 /* ADC3: mute amp left and right */
5012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005013 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005014
5015 { }
5016};
5017
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005018static struct hda_verb alc882_eapd_verbs[] = {
5019 /* change to EAPD mode */
5020 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005021 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005022 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005023};
5024
Tobin Davis9102cd12006-12-15 10:02:12 +01005025/* Mac Pro test */
5026static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5028 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5030 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5031 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5032 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5033 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5034 { } /* end */
5035};
5036
5037static struct hda_verb alc882_macpro_init_verbs[] = {
5038 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5041 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5042 /* Front Pin: output 0 (0x0c) */
5043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5046 /* Front Mic pin: input vref at 80% */
5047 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5048 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5049 /* Speaker: output */
5050 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5051 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5052 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5053 /* Headphone output (output 0 - 0x0c) */
5054 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5055 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5056 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5057
5058 /* FIXME: use matrix-type input source selection */
5059 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5060 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5065 /* Input mixer2 */
5066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5070 /* Input mixer3 */
5071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5075 /* ADC1: mute amp left and right */
5076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5077 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5078 /* ADC2: mute amp left and right */
5079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5080 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5081 /* ADC3: mute amp left and right */
5082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5083 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5084
5085 { }
5086};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005087
Kailang Yang272a5272007-05-14 11:00:38 +02005088static struct hda_verb alc882_targa_verbs[] = {
5089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5091
5092 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5094
5095 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5096 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5097 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5098
5099 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5100 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5101 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5102 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5103 { } /* end */
5104};
5105
5106/* toggle speaker-output according to the hp-jack state */
5107static void alc882_targa_automute(struct hda_codec *codec)
5108{
5109 unsigned int present;
5110
5111 present = snd_hda_codec_read(codec, 0x14, 0,
5112 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5113 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5114 0x80, present ? 0x80 : 0);
5115 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5116 0x80, present ? 0x80 : 0);
5117 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5118}
5119
5120static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5121{
5122 /* Looks like the unsol event is incompatible with the standard
5123 * definition. 4bit tag is placed at 26 bit!
5124 */
5125 if (((res >> 26) == ALC880_HP_EVENT)) {
5126 alc882_targa_automute(codec);
5127 }
5128}
5129
5130static struct hda_verb alc882_asus_a7j_verbs[] = {
5131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5133
5134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5136 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5137
5138 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5139 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5140 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5141
5142 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5143 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5144 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5145 { } /* end */
5146};
5147
Tobin Davis9102cd12006-12-15 10:02:12 +01005148static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5149{
5150 unsigned int gpiostate, gpiomask, gpiodir;
5151
5152 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5153 AC_VERB_GET_GPIO_DATA, 0);
5154
5155 if (!muted)
5156 gpiostate |= (1 << pin);
5157 else
5158 gpiostate &= ~(1 << pin);
5159
5160 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5161 AC_VERB_GET_GPIO_MASK, 0);
5162 gpiomask |= (1 << pin);
5163
5164 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5165 AC_VERB_GET_GPIO_DIRECTION, 0);
5166 gpiodir |= (1 << pin);
5167
5168
5169 snd_hda_codec_write(codec, codec->afg, 0,
5170 AC_VERB_SET_GPIO_MASK, gpiomask);
5171 snd_hda_codec_write(codec, codec->afg, 0,
5172 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5173
5174 msleep(1);
5175
5176 snd_hda_codec_write(codec, codec->afg, 0,
5177 AC_VERB_SET_GPIO_DATA, gpiostate);
5178}
5179
Kailang Yangdf694da2005-12-05 19:42:22 +01005180/*
5181 * generic initialization of ADC, input mixers and output mixers
5182 */
5183static struct hda_verb alc882_auto_init_verbs[] = {
5184 /*
5185 * Unmute ADC0-2 and set the default input to mic-in
5186 */
5187 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5189 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5190 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5191 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5193
5194 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5195 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005196 * Note: PASD motherboards uses the Line In 2 as the input for
5197 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005198 */
5199 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5205
5206 /*
5207 * Set up output mixers (0x0c - 0x0f)
5208 */
5209 /* set vol=0 to output mixers */
5210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5211 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5213 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5214 /* set up input amps for analog loopback */
5215 /* Amp Indices: DAC = 0, mixer = 1 */
5216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5219 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5221 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5222 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5223 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5224 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5225 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5226
5227 /* FIXME: use matrix-type input source selection */
5228 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5229 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5233 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5234 /* Input mixer2 */
5235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5237 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5238 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5239 /* Input mixer3 */
5240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5242 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5244
5245 { }
5246};
5247
5248/* capture mixer elements */
5249static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5250 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5251 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5252 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5253 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5254 {
5255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5256 /* The multiple "Capture Source" controls confuse alsamixer
5257 * So call somewhat different..
5258 * FIXME: the controls appear in the "playback" view!
5259 */
5260 /* .name = "Capture Source", */
5261 .name = "Input Source",
5262 .count = 2,
5263 .info = alc882_mux_enum_info,
5264 .get = alc882_mux_enum_get,
5265 .put = alc882_mux_enum_put,
5266 },
5267 { } /* end */
5268};
5269
5270static struct snd_kcontrol_new alc882_capture_mixer[] = {
5271 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5272 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5273 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5274 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5275 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5276 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5277 {
5278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5279 /* The multiple "Capture Source" controls confuse alsamixer
5280 * So call somewhat different..
5281 * FIXME: the controls appear in the "playback" view!
5282 */
5283 /* .name = "Capture Source", */
5284 .name = "Input Source",
5285 .count = 3,
5286 .info = alc882_mux_enum_info,
5287 .get = alc882_mux_enum_get,
5288 .put = alc882_mux_enum_put,
5289 },
5290 { } /* end */
5291};
5292
5293/* pcm configuration: identiacal with ALC880 */
5294#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5295#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5296#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5297#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5298
5299/*
5300 * configuration and preset
5301 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005302static const char *alc882_models[ALC882_MODEL_LAST] = {
5303 [ALC882_3ST_DIG] = "3stack-dig",
5304 [ALC882_6ST_DIG] = "6stack-dig",
5305 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005306 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005307 [ALC885_MACPRO] = "macpro",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005308 [ALC882_AUTO] = "auto",
5309};
5310
5311static struct snd_pci_quirk alc882_cfg_tbl[] = {
5312 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5313 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5314 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005315 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005316 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005317 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005318 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005319 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005320 {}
5321};
5322
5323static struct alc_config_preset alc882_presets[] = {
5324 [ALC882_3ST_DIG] = {
5325 .mixers = { alc882_base_mixer },
5326 .init_verbs = { alc882_init_verbs },
5327 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5328 .dac_nids = alc882_dac_nids,
5329 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005330 .dig_in_nid = ALC882_DIGIN_NID,
5331 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5332 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005333 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005334 .input_mux = &alc882_capture_source,
5335 },
5336 [ALC882_6ST_DIG] = {
5337 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5338 .init_verbs = { alc882_init_verbs },
5339 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5340 .dac_nids = alc882_dac_nids,
5341 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005342 .dig_in_nid = ALC882_DIGIN_NID,
5343 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5344 .channel_mode = alc882_sixstack_modes,
5345 .input_mux = &alc882_capture_source,
5346 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005347 [ALC882_ARIMA] = {
5348 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5349 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5350 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5351 .dac_nids = alc882_dac_nids,
5352 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5353 .channel_mode = alc882_sixstack_modes,
5354 .input_mux = &alc882_capture_source,
5355 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005356 [ALC882_W2JC] = {
5357 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5358 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5359 alc880_gpio1_init_verbs },
5360 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5361 .dac_nids = alc882_dac_nids,
5362 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5363 .channel_mode = alc880_threestack_modes,
5364 .need_dac_fix = 1,
5365 .input_mux = &alc882_capture_source,
5366 .dig_out_nid = ALC882_DIGOUT_NID,
5367 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005368 [ALC885_MACPRO] = {
5369 .mixers = { alc882_macpro_mixer },
5370 .init_verbs = { alc882_macpro_init_verbs },
5371 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5372 .dac_nids = alc882_dac_nids,
5373 .dig_out_nid = ALC882_DIGOUT_NID,
5374 .dig_in_nid = ALC882_DIGIN_NID,
5375 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5376 .channel_mode = alc882_ch_modes,
5377 .input_mux = &alc882_capture_source,
5378 },
Kailang Yang272a5272007-05-14 11:00:38 +02005379 [ALC882_TARGA] = {
5380 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5381 alc882_capture_mixer },
5382 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5383 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5384 .dac_nids = alc882_dac_nids,
5385 .dig_out_nid = ALC882_DIGOUT_NID,
5386 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5387 .adc_nids = alc882_adc_nids,
5388 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5389 .channel_mode = alc882_3ST_6ch_modes,
5390 .need_dac_fix = 1,
5391 .input_mux = &alc882_capture_source,
5392 .unsol_event = alc882_targa_unsol_event,
5393 .init_hook = alc882_targa_automute,
5394 },
5395 [ALC882_ASUS_A7J] = {
5396 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5397 alc882_capture_mixer },
5398 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5399 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5400 .dac_nids = alc882_dac_nids,
5401 .dig_out_nid = ALC882_DIGOUT_NID,
5402 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5403 .adc_nids = alc882_adc_nids,
5404 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5405 .channel_mode = alc882_3ST_6ch_modes,
5406 .need_dac_fix = 1,
5407 .input_mux = &alc882_capture_source,
5408 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005409};
5410
5411
5412/*
5413 * BIOS auto configuration
5414 */
5415static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5416 hda_nid_t nid, int pin_type,
5417 int dac_idx)
5418{
5419 /* set as output */
5420 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005421 int idx;
5422
Kailang Yangdf694da2005-12-05 19:42:22 +01005423 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5424 idx = 4;
5425 else
5426 idx = spec->multiout.dac_nids[dac_idx] - 2;
5427
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005428 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5429 pin_type);
5430 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5431 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005432 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5433
5434}
5435
5436static void alc882_auto_init_multi_out(struct hda_codec *codec)
5437{
5438 struct alc_spec *spec = codec->spec;
5439 int i;
5440
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005441 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005442 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005443 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005444 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005445 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005446 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005447 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005448 }
5449}
5450
5451static void alc882_auto_init_hp_out(struct hda_codec *codec)
5452{
5453 struct alc_spec *spec = codec->spec;
5454 hda_nid_t pin;
5455
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005456 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005457 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005458 /* use dac 0 */
5459 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005460}
5461
5462#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5463#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5464
5465static void alc882_auto_init_analog_input(struct hda_codec *codec)
5466{
5467 struct alc_spec *spec = codec->spec;
5468 int i;
5469
5470 for (i = 0; i < AUTO_PIN_LAST; i++) {
5471 hda_nid_t nid = spec->autocfg.input_pins[i];
5472 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005473 snd_hda_codec_write(codec, nid, 0,
5474 AC_VERB_SET_PIN_WIDGET_CONTROL,
5475 i <= AUTO_PIN_FRONT_MIC ?
5476 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005477 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005478 snd_hda_codec_write(codec, nid, 0,
5479 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005480 AMP_OUT_MUTE);
5481 }
5482 }
5483}
5484
5485/* almost identical with ALC880 parser... */
5486static int alc882_parse_auto_config(struct hda_codec *codec)
5487{
5488 struct alc_spec *spec = codec->spec;
5489 int err = alc880_parse_auto_config(codec);
5490
5491 if (err < 0)
5492 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005493 else if (err > 0)
5494 /* hack - override the init verbs */
5495 spec->init_verbs[0] = alc882_auto_init_verbs;
5496 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005497}
5498
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005499/* additional initialization for auto-configuration model */
5500static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005501{
Kailang Yangdf694da2005-12-05 19:42:22 +01005502 alc882_auto_init_multi_out(codec);
5503 alc882_auto_init_hp_out(codec);
5504 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005505}
5506
Linus Torvalds1da177e2005-04-16 15:20:36 -07005507static int patch_alc882(struct hda_codec *codec)
5508{
5509 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005510 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005511
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005512 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005513 if (spec == NULL)
5514 return -ENOMEM;
5515
Linus Torvalds1da177e2005-04-16 15:20:36 -07005516 codec->spec = spec;
5517
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005518 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5519 alc882_models,
5520 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005521
Kailang Yangdf694da2005-12-05 19:42:22 +01005522 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005523 /* Pick up systems that don't supply PCI SSID */
5524 switch (codec->subsystem_id) {
5525 case 0x106b0c00: /* Mac Pro */
5526 board_config = ALC885_MACPRO;
5527 break;
5528 default:
5529 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5530 "trying auto-probe from BIOS...\n");
5531 board_config = ALC882_AUTO;
5532 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005533 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005534
Kailang Yangdf694da2005-12-05 19:42:22 +01005535 if (board_config == ALC882_AUTO) {
5536 /* automatic parse from the BIOS config */
5537 err = alc882_parse_auto_config(codec);
5538 if (err < 0) {
5539 alc_free(codec);
5540 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005541 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005542 printk(KERN_INFO
5543 "hda_codec: Cannot set up configuration "
5544 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005545 board_config = ALC882_3ST_DIG;
5546 }
5547 }
5548
5549 if (board_config != ALC882_AUTO)
5550 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005551
Tobin Davis9102cd12006-12-15 10:02:12 +01005552 if (board_config == ALC885_MACPRO) {
5553 alc882_gpio_mute(codec, 0, 0);
5554 alc882_gpio_mute(codec, 1, 0);
5555 }
5556
Linus Torvalds1da177e2005-04-16 15:20:36 -07005557 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005558 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5559 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005560
5561 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005562 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5563 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005564
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005565 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005566 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005567 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005568 /* get type */
5569 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005570 if (wcap != AC_WID_AUD_IN) {
5571 spec->adc_nids = alc882_adc_nids_alt;
5572 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005573 spec->mixers[spec->num_mixers] =
5574 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005575 spec->num_mixers++;
5576 } else {
5577 spec->adc_nids = alc882_adc_nids;
5578 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5579 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5580 spec->num_mixers++;
5581 }
5582 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005583
5584 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005585 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005586 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005587
5588 return 0;
5589}
5590
5591/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005592 * ALC883 support
5593 *
5594 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5595 * configuration. Each pin widget can choose any input DACs and a mixer.
5596 * Each ADC is connected from a mixer of all inputs. This makes possible
5597 * 6-channel independent captures.
5598 *
5599 * In addition, an independent DAC for the multi-playback (not used in this
5600 * driver yet).
5601 */
5602#define ALC883_DIGOUT_NID 0x06
5603#define ALC883_DIGIN_NID 0x0a
5604
5605static hda_nid_t alc883_dac_nids[4] = {
5606 /* front, rear, clfe, rear_surr */
5607 0x02, 0x04, 0x03, 0x05
5608};
5609
5610static hda_nid_t alc883_adc_nids[2] = {
5611 /* ADC1-2 */
5612 0x08, 0x09,
5613};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005614
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005615/* input MUX */
5616/* FIXME: should be a matrix-type input source selection */
5617
5618static struct hda_input_mux alc883_capture_source = {
5619 .num_items = 4,
5620 .items = {
5621 { "Mic", 0x0 },
5622 { "Front Mic", 0x1 },
5623 { "Line", 0x2 },
5624 { "CD", 0x4 },
5625 },
5626};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005627
5628static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5629 .num_items = 2,
5630 .items = {
5631 { "Mic", 0x1 },
5632 { "Line", 0x2 },
5633 },
5634};
5635
Kailang Yang272a5272007-05-14 11:00:38 +02005636static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5637 .num_items = 4,
5638 .items = {
5639 { "Mic", 0x0 },
5640 { "iMic", 0x1 },
5641 { "Line", 0x2 },
5642 { "CD", 0x4 },
5643 },
5644};
5645
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005646#define alc883_mux_enum_info alc_mux_enum_info
5647#define alc883_mux_enum_get alc_mux_enum_get
5648
5649static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5650 struct snd_ctl_elem_value *ucontrol)
5651{
5652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5653 struct alc_spec *spec = codec->spec;
5654 const struct hda_input_mux *imux = spec->input_mux;
5655 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5656 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5657 hda_nid_t nid = capture_mixers[adc_idx];
5658 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5659 unsigned int i, idx;
5660
5661 idx = ucontrol->value.enumerated.item[0];
5662 if (idx >= imux->num_items)
5663 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005664 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005665 return 0;
5666 for (i = 0; i < imux->num_items; i++) {
5667 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5668 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5669 v | (imux->items[i].index << 8));
5670 }
5671 *cur_val = idx;
5672 return 1;
5673}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005674
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005675/*
5676 * 2ch mode
5677 */
5678static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5679 { 2, NULL }
5680};
5681
5682/*
5683 * 2ch mode
5684 */
5685static struct hda_verb alc883_3ST_ch2_init[] = {
5686 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5687 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5688 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5689 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5690 { } /* end */
5691};
5692
5693/*
5694 * 6ch mode
5695 */
5696static struct hda_verb alc883_3ST_ch6_init[] = {
5697 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5698 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5699 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5700 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5701 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5702 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5703 { } /* end */
5704};
5705
5706static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5707 { 2, alc883_3ST_ch2_init },
5708 { 6, alc883_3ST_ch6_init },
5709};
5710
5711/*
5712 * 6ch mode
5713 */
5714static struct hda_verb alc883_sixstack_ch6_init[] = {
5715 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5716 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5717 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5718 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5719 { } /* end */
5720};
5721
5722/*
5723 * 8ch mode
5724 */
5725static struct hda_verb alc883_sixstack_ch8_init[] = {
5726 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5727 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5728 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5729 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5730 { } /* end */
5731};
5732
5733static struct hda_channel_mode alc883_sixstack_modes[2] = {
5734 { 6, alc883_sixstack_ch6_init },
5735 { 8, alc883_sixstack_ch8_init },
5736};
5737
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005738static struct hda_verb alc883_medion_eapd_verbs[] = {
5739 /* eanable EAPD on medion laptop */
5740 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5741 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5742 { }
5743};
5744
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005745/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5746 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5747 */
5748
5749static struct snd_kcontrol_new alc883_base_mixer[] = {
5750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5751 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5752 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5754 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5755 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5756 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5757 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5758 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5759 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5760 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5761 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5762 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5763 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5764 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005766 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5768 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005769 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005770 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5771 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5772 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5773 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5774 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5775 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5776 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5777 {
5778 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5779 /* .name = "Capture Source", */
5780 .name = "Input Source",
5781 .count = 2,
5782 .info = alc883_mux_enum_info,
5783 .get = alc883_mux_enum_get,
5784 .put = alc883_mux_enum_put,
5785 },
5786 { } /* end */
5787};
5788
5789static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5791 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5792 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5803 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5804 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5805 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5806 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5807 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5808 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5809 {
5810 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5811 /* .name = "Capture Source", */
5812 .name = "Input Source",
5813 .count = 2,
5814 .info = alc883_mux_enum_info,
5815 .get = alc883_mux_enum_get,
5816 .put = alc883_mux_enum_put,
5817 },
5818 { } /* end */
5819};
5820
5821static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5822 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5823 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5824 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5825 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5826 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5827 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5828 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5829 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5833 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5834 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005836 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5838 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005839 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005840 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5841 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5842 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5843 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5844 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5845 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5846 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5847 {
5848 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5849 /* .name = "Capture Source", */
5850 .name = "Input Source",
5851 .count = 2,
5852 .info = alc883_mux_enum_info,
5853 .get = alc883_mux_enum_get,
5854 .put = alc883_mux_enum_put,
5855 },
5856 { } /* end */
5857};
5858
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005859static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5861 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5862 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5863 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5864 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5865 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5866 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5867 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5871 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5872 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005874 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5876 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005877 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005878 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5879 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5880 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5883
5884 {
5885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5886 /* .name = "Capture Source", */
5887 .name = "Input Source",
5888 .count = 1,
5889 .info = alc883_mux_enum_info,
5890 .get = alc883_mux_enum_get,
5891 .put = alc883_mux_enum_put,
5892 },
5893 { } /* end */
5894};
5895
Kailang Yangccc656c2006-10-17 12:32:26 +02005896static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5897 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5899 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5900 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5901 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5902 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5903 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5904 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5905 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5906 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5907 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5908 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5909 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005911 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005912 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5913 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5914 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5915 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5916 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5917 {
5918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5919 /* .name = "Capture Source", */
5920 .name = "Input Source",
5921 .count = 2,
5922 .info = alc883_mux_enum_info,
5923 .get = alc883_mux_enum_get,
5924 .put = alc883_mux_enum_put,
5925 },
5926 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005927};
Kailang Yangccc656c2006-10-17 12:32:26 +02005928
5929static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5930 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5932 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5933 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5934 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5938 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5939 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5940 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5941 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5942 {
5943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5944 /* .name = "Capture Source", */
5945 .name = "Input Source",
5946 .count = 2,
5947 .info = alc883_mux_enum_info,
5948 .get = alc883_mux_enum_get,
5949 .put = alc883_mux_enum_put,
5950 },
5951 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005952};
Kailang Yangccc656c2006-10-17 12:32:26 +02005953
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005954static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5955 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5956 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5957 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5958 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5963 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5964 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5965 {
5966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5967 /* .name = "Capture Source", */
5968 .name = "Input Source",
5969 .count = 1,
5970 .info = alc883_mux_enum_info,
5971 .get = alc883_mux_enum_get,
5972 .put = alc883_mux_enum_put,
5973 },
5974 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005975};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005976
Kailang Yang272a5272007-05-14 11:00:38 +02005977static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
5978 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5979 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
5980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5981 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5982 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5985 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5986 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5987 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5988 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5989 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5990 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5991 {
5992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5993 /* .name = "Capture Source", */
5994 .name = "Input Source",
5995 .count = 2,
5996 .info = alc883_mux_enum_info,
5997 .get = alc883_mux_enum_get,
5998 .put = alc883_mux_enum_put,
5999 },
6000 { } /* end */
6001};
6002
6003static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6006 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6011 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6012 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6013 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6014 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6015 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6016 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6017 {
6018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6019 /* .name = "Capture Source", */
6020 .name = "Input Source",
6021 .count = 2,
6022 .info = alc883_mux_enum_info,
6023 .get = alc883_mux_enum_get,
6024 .put = alc883_mux_enum_put,
6025 },
6026 { } /* end */
6027};
6028
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006029static struct snd_kcontrol_new alc888_hp_nettle_mixer[] = {
6030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6032 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6033 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6034 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6035 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6036 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6037 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6038 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6039 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6040 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6044 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6046 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6048 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6049 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6050 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6051 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6052 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6053 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6054 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6055 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6056 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6057 {
6058 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6059 /* .name = "Capture Source", */
6060 .name = "Input Source",
6061 .count = 2,
6062 .info = alc883_mux_enum_info,
6063 .get = alc883_mux_enum_get,
6064 .put = alc883_mux_enum_put,
6065 },
6066 { } /* end */
6067};
6068
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006069static struct snd_kcontrol_new alc888_hp_lucknow_mixer[] = {
6070 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6071 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6072 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6073 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6074 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6075 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6076 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6077 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6079 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6080 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6081 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6082 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6084 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6086 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6087 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6088 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6089 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6090 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6091 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6092 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6093 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6094 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6095 {
6096 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6097 /* .name = "Capture Source", */
6098 .name = "Input Source",
6099 .count = 2,
6100 .info = alc883_mux_enum_info,
6101 .get = alc883_mux_enum_get,
6102 .put = alc883_mux_enum_put,
6103 },
6104 { } /* end */
6105};
6106
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006107static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6108 {
6109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6110 .name = "Channel Mode",
6111 .info = alc_ch_mode_info,
6112 .get = alc_ch_mode_get,
6113 .put = alc_ch_mode_put,
6114 },
6115 { } /* end */
6116};
6117
6118static struct hda_verb alc883_init_verbs[] = {
6119 /* ADC1: mute amp left and right */
6120 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6121 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6122 /* ADC2: mute amp left and right */
6123 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6124 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6125 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6126 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6129 /* Rear mixer */
6130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6131 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6132 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6133 /* CLFE mixer */
6134 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6135 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6137 /* Side mixer */
6138 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6139 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6140 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6141
6142 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6143 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6147
6148 /* Front Pin: output 0 (0x0c) */
6149 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6150 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6151 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6152 /* Rear Pin: output 1 (0x0d) */
6153 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6156 /* CLFE Pin: output 2 (0x0e) */
6157 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6158 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6159 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6160 /* Side Pin: output 3 (0x0f) */
6161 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6162 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6163 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6164 /* Mic (rear) pin: input vref at 80% */
6165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6166 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6167 /* Front Mic pin: input vref at 80% */
6168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6169 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6170 /* Line In pin: input */
6171 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6173 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6174 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6175 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6176 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6177 /* CD pin widget for input */
6178 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6179
6180 /* FIXME: use matrix-type input source selection */
6181 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6182 /* Input mixer2 */
6183 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6184 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6185 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6186 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6187 /* Input mixer3 */
6188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6192 { }
6193};
6194
Kailang Yangccc656c2006-10-17 12:32:26 +02006195static struct hda_verb alc883_tagra_verbs[] = {
6196 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6198
6199 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6200 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6201
6202 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6203 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6204 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6205
6206 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006207 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6208 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6209 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006210
6211 { } /* end */
6212};
6213
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006214static struct hda_verb alc883_lenovo_101e_verbs[] = {
6215 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6216 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6217 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6218 { } /* end */
6219};
6220
Kailang Yang272a5272007-05-14 11:00:38 +02006221static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6222 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6224 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6226 { } /* end */
6227};
6228
6229static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6232 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6233 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6234 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6235 { } /* end */
6236};
6237
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006238static struct hda_verb alc888_hp_nettle_verbs[] = {
6239 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6240 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6241 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6242 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6243 { }
6244};
6245
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006246static struct hda_verb alc888_hp_lucknow_verbs[] = {
6247 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6248 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6249 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6250 { }
6251};
6252
6253static struct hda_verb alc888_hp_lucknow_2ch_init[] = {
6254 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6255 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6256 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6257 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6258 { }
6259};
6260
6261static struct hda_verb alc888_hp_lucknow_6ch_init[] = {
6262 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6263 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6264 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6265 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6266 { }
6267};
6268
6269static struct hda_channel_mode alc888_hp_lucknow_modes[2] = {
6270 { 2, alc888_hp_lucknow_2ch_init },
6271 { 6, alc888_hp_lucknow_6ch_init },
6272};
6273
Kailang Yang272a5272007-05-14 11:00:38 +02006274/* toggle front-jack and RCA according to the hp-jack state */
6275static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6276{
6277 unsigned int present;
6278
6279 present = snd_hda_codec_read(codec, 0x1b, 0,
6280 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6281 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6282 0x80, present ? 0x80 : 0);
6283 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6284 0x80, present ? 0x80 : 0);
6285 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6286 0x80, present ? 0x80 : 0);
6287 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6288 0x80, present ? 0x80 : 0);
6289
6290}
6291
6292/* toggle RCA according to the front-jack state */
6293static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6294{
6295 unsigned int present;
6296
6297 present = snd_hda_codec_read(codec, 0x14, 0,
6298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6299 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6300 0x80, present ? 0x80 : 0);
6301 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6302 0x80, present ? 0x80 : 0);
6303
6304}
6305static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6306 unsigned int res)
6307{
6308 if ((res >> 26) == ALC880_HP_EVENT)
6309 alc888_lenovo_ms7195_front_automute(codec);
6310 if ((res >> 26) == ALC880_FRONT_EVENT)
6311 alc888_lenovo_ms7195_rca_automute(codec);
6312}
6313
6314static struct hda_verb alc883_medion_md2_verbs[] = {
6315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6317
6318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6319
6320 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6321 { } /* end */
6322};
6323
6324/* toggle speaker-output according to the hp-jack state */
6325static void alc883_medion_md2_automute(struct hda_codec *codec)
6326{
6327 unsigned int present;
6328
6329 present = snd_hda_codec_read(codec, 0x14, 0,
6330 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6331 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6332 0x80, present ? 0x80 : 0);
6333 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6334 0x80, present ? 0x80 : 0);
6335}
6336
6337static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6338 unsigned int res)
6339{
6340 if ((res >> 26) == ALC880_HP_EVENT)
6341 alc883_medion_md2_automute(codec);
6342}
6343
Kailang Yangccc656c2006-10-17 12:32:26 +02006344/* toggle speaker-output according to the hp-jack state */
6345static void alc883_tagra_automute(struct hda_codec *codec)
6346{
6347 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006348 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006349
6350 present = snd_hda_codec_read(codec, 0x14, 0,
6351 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006352 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006353 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006354 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006355 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006356 0x80, bits);
6357 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6358 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006359}
6360
6361static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6362{
6363 if ((res >> 26) == ALC880_HP_EVENT)
6364 alc883_tagra_automute(codec);
6365}
6366
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006367static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6368{
6369 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006370 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006371
6372 present = snd_hda_codec_read(codec, 0x14, 0,
6373 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006374 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006375 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006376 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006377 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006378 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006379}
6380
6381static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6382{
6383 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006384 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006385
6386 present = snd_hda_codec_read(codec, 0x1b, 0,
6387 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006388 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006389 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006390 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006391 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006392 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006393 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006394 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006395 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006396 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006397}
6398
6399static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6400 unsigned int res)
6401{
6402 if ((res >> 26) == ALC880_HP_EVENT)
6403 alc883_lenovo_101e_all_automute(codec);
6404 if ((res >> 26) == ALC880_FRONT_EVENT)
6405 alc883_lenovo_101e_ispeaker_automute(codec);
6406}
6407
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006408/*
6409 * generic initialization of ADC, input mixers and output mixers
6410 */
6411static struct hda_verb alc883_auto_init_verbs[] = {
6412 /*
6413 * Unmute ADC0-2 and set the default input to mic-in
6414 */
6415 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6416 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6417 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6419
6420 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6421 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006422 * Note: PASD motherboards uses the Line In 2 as the input for
6423 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006424 */
6425 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6427 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6428 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6429 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6430 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6431
6432 /*
6433 * Set up output mixers (0x0c - 0x0f)
6434 */
6435 /* set vol=0 to output mixers */
6436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6439 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6440 /* set up input amps for analog loopback */
6441 /* Amp Indices: DAC = 0, mixer = 1 */
6442 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6443 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6444 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6445 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6446 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6447 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6448 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6449 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6450 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6451 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6452
6453 /* FIXME: use matrix-type input source selection */
6454 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6455 /* Input mixer1 */
6456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6458 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006459 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006460 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6461 /* Input mixer2 */
6462 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6463 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6464 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006465 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6467
6468 { }
6469};
6470
6471/* capture mixer elements */
6472static struct snd_kcontrol_new alc883_capture_mixer[] = {
6473 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6474 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6475 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6476 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6477 {
6478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6479 /* The multiple "Capture Source" controls confuse alsamixer
6480 * So call somewhat different..
6481 * FIXME: the controls appear in the "playback" view!
6482 */
6483 /* .name = "Capture Source", */
6484 .name = "Input Source",
6485 .count = 2,
6486 .info = alc882_mux_enum_info,
6487 .get = alc882_mux_enum_get,
6488 .put = alc882_mux_enum_put,
6489 },
6490 { } /* end */
6491};
6492
6493/* pcm configuration: identiacal with ALC880 */
6494#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6495#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6496#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6497#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6498
6499/*
6500 * configuration and preset
6501 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006502static const char *alc883_models[ALC883_MODEL_LAST] = {
6503 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6504 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6505 [ALC883_3ST_6ch] = "3stack-6ch",
6506 [ALC883_6ST_DIG] = "6stack-dig",
6507 [ALC883_TARGA_DIG] = "targa-dig",
6508 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006509 [ALC883_ACER] = "acer",
6510 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006511 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006512 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006513 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006514 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6515 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006516 [ALC888_HP_NETTLE] = "hp-nettle",
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006517 [ALC888_HP_LUCKNOW] = "hp-lucknow",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006518 [ALC883_AUTO] = "auto",
6519};
6520
6521static struct snd_pci_quirk alc883_cfg_tbl[] = {
6522 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006523 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006524 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6525 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6526 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006527 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006528 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6529 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006530 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006531 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006532 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006533 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006534 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006535 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6536 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6537 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6538 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6539 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6540 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6541 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6542 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6543 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6544 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006545 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006546 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6547 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6548 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006549 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6550 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6551 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006552 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_HP_NETTLE),
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006553 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_HP_LUCKNOW),
Kailang Yang272a5272007-05-14 11:00:38 +02006554 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006555 {}
6556};
6557
6558static struct alc_config_preset alc883_presets[] = {
6559 [ALC883_3ST_2ch_DIG] = {
6560 .mixers = { alc883_3ST_2ch_mixer },
6561 .init_verbs = { alc883_init_verbs },
6562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6563 .dac_nids = alc883_dac_nids,
6564 .dig_out_nid = ALC883_DIGOUT_NID,
6565 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6566 .adc_nids = alc883_adc_nids,
6567 .dig_in_nid = ALC883_DIGIN_NID,
6568 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6569 .channel_mode = alc883_3ST_2ch_modes,
6570 .input_mux = &alc883_capture_source,
6571 },
6572 [ALC883_3ST_6ch_DIG] = {
6573 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6574 .init_verbs = { alc883_init_verbs },
6575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6576 .dac_nids = alc883_dac_nids,
6577 .dig_out_nid = ALC883_DIGOUT_NID,
6578 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6579 .adc_nids = alc883_adc_nids,
6580 .dig_in_nid = ALC883_DIGIN_NID,
6581 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6582 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006583 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006584 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006585 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006586 [ALC883_3ST_6ch] = {
6587 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6588 .init_verbs = { alc883_init_verbs },
6589 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6590 .dac_nids = alc883_dac_nids,
6591 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6592 .adc_nids = alc883_adc_nids,
6593 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6594 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006595 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006596 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006597 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006598 [ALC883_6ST_DIG] = {
6599 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6600 .init_verbs = { alc883_init_verbs },
6601 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6602 .dac_nids = alc883_dac_nids,
6603 .dig_out_nid = ALC883_DIGOUT_NID,
6604 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6605 .adc_nids = alc883_adc_nids,
6606 .dig_in_nid = ALC883_DIGIN_NID,
6607 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6608 .channel_mode = alc883_sixstack_modes,
6609 .input_mux = &alc883_capture_source,
6610 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006611 [ALC883_TARGA_DIG] = {
6612 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6613 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6614 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6615 .dac_nids = alc883_dac_nids,
6616 .dig_out_nid = ALC883_DIGOUT_NID,
6617 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6618 .adc_nids = alc883_adc_nids,
6619 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6620 .channel_mode = alc883_3ST_6ch_modes,
6621 .need_dac_fix = 1,
6622 .input_mux = &alc883_capture_source,
6623 .unsol_event = alc883_tagra_unsol_event,
6624 .init_hook = alc883_tagra_automute,
6625 },
6626 [ALC883_TARGA_2ch_DIG] = {
6627 .mixers = { alc883_tagra_2ch_mixer},
6628 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6629 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6630 .dac_nids = alc883_dac_nids,
6631 .dig_out_nid = ALC883_DIGOUT_NID,
6632 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6633 .adc_nids = alc883_adc_nids,
6634 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6635 .channel_mode = alc883_3ST_2ch_modes,
6636 .input_mux = &alc883_capture_source,
6637 .unsol_event = alc883_tagra_unsol_event,
6638 .init_hook = alc883_tagra_automute,
6639 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02006640 [ALC883_ACER] = {
6641 .mixers = { alc883_base_mixer,
6642 alc883_chmode_mixer },
6643 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6644 * and the headphone jack. Turn this on and rely on the
6645 * standard mute methods whenever the user wants to turn
6646 * these outputs off.
6647 */
6648 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6649 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6650 .dac_nids = alc883_dac_nids,
6651 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6652 .adc_nids = alc883_adc_nids,
6653 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6654 .channel_mode = alc883_3ST_2ch_modes,
6655 .input_mux = &alc883_capture_source,
6656 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006657 [ALC883_MEDION] = {
6658 .mixers = { alc883_fivestack_mixer,
6659 alc883_chmode_mixer },
6660 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006661 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006662 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6663 .dac_nids = alc883_dac_nids,
6664 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6665 .adc_nids = alc883_adc_nids,
6666 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6667 .channel_mode = alc883_sixstack_modes,
6668 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006669 },
Kailang Yang272a5272007-05-14 11:00:38 +02006670 [ALC883_MEDION_MD2] = {
6671 .mixers = { alc883_medion_md2_mixer},
6672 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6673 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6674 .dac_nids = alc883_dac_nids,
6675 .dig_out_nid = ALC883_DIGOUT_NID,
6676 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6677 .adc_nids = alc883_adc_nids,
6678 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6679 .channel_mode = alc883_3ST_2ch_modes,
6680 .input_mux = &alc883_capture_source,
6681 .unsol_event = alc883_medion_md2_unsol_event,
6682 .init_hook = alc883_medion_md2_automute,
6683 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006684 [ALC883_LAPTOP_EAPD] = {
6685 .mixers = { alc883_base_mixer,
6686 alc883_chmode_mixer },
6687 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6688 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6689 .dac_nids = alc883_dac_nids,
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 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006696 [ALC883_LENOVO_101E_2ch] = {
6697 .mixers = { alc883_lenovo_101e_2ch_mixer},
6698 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6699 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6700 .dac_nids = alc883_dac_nids,
6701 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6702 .adc_nids = alc883_adc_nids,
6703 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6704 .channel_mode = alc883_3ST_2ch_modes,
6705 .input_mux = &alc883_lenovo_101e_capture_source,
6706 .unsol_event = alc883_lenovo_101e_unsol_event,
6707 .init_hook = alc883_lenovo_101e_all_automute,
6708 },
Kailang Yang272a5272007-05-14 11:00:38 +02006709 [ALC883_LENOVO_NB0763] = {
6710 .mixers = { alc883_lenovo_nb0763_mixer },
6711 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6712 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6713 .dac_nids = alc883_dac_nids,
6714 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6715 .adc_nids = alc883_adc_nids,
6716 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6717 .channel_mode = alc883_3ST_2ch_modes,
6718 .need_dac_fix = 1,
6719 .input_mux = &alc883_lenovo_nb0763_capture_source,
6720 .unsol_event = alc883_medion_md2_unsol_event,
6721 .init_hook = alc883_medion_md2_automute,
6722 },
6723 [ALC888_LENOVO_MS7195_DIG] = {
6724 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6725 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6726 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6727 .dac_nids = alc883_dac_nids,
6728 .dig_out_nid = ALC883_DIGOUT_NID,
6729 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6730 .adc_nids = alc883_adc_nids,
6731 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6732 .channel_mode = alc883_3ST_6ch_modes,
6733 .need_dac_fix = 1,
6734 .input_mux = &alc883_capture_source,
6735 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6736 .init_hook = alc888_lenovo_ms7195_front_automute,
6737 },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006738 [ALC888_HP_NETTLE] = {
6739 .mixers = { alc888_hp_nettle_mixer, alc883_chmode_mixer },
6740 .init_verbs = { alc883_init_verbs, alc888_hp_nettle_verbs },
6741 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6742 .dac_nids = alc883_dac_nids,
6743 .dig_out_nid = ALC883_DIGOUT_NID,
6744 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6745 .adc_nids = alc883_adc_nids,
6746 .dig_in_nid = ALC883_DIGIN_NID,
6747 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6748 .channel_mode = alc883_sixstack_modes,
6749 .input_mux = &alc883_capture_source,
6750 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006751 [ALC888_HP_LUCKNOW] = {
6752 .mixers = { alc888_hp_lucknow_mixer, alc883_chmode_mixer },
6753 .init_verbs = { alc883_init_verbs, alc888_hp_lucknow_verbs },
6754 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6755 .dac_nids = alc883_dac_nids,
6756 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6757 .adc_nids = alc883_adc_nids,
6758 .num_channel_mode = ARRAY_SIZE(alc888_hp_lucknow_modes),
6759 .channel_mode = alc888_hp_lucknow_modes,
6760 .need_dac_fix = 1,
6761 .input_mux = &alc883_capture_source,
6762 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006763};
6764
6765
6766/*
6767 * BIOS auto configuration
6768 */
6769static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6770 hda_nid_t nid, int pin_type,
6771 int dac_idx)
6772{
6773 /* set as output */
6774 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006775 int idx;
6776
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006777 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6778 idx = 4;
6779 else
6780 idx = spec->multiout.dac_nids[dac_idx] - 2;
6781
6782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6783 pin_type);
6784 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6785 AMP_OUT_UNMUTE);
6786 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6787
6788}
6789
6790static void alc883_auto_init_multi_out(struct hda_codec *codec)
6791{
6792 struct alc_spec *spec = codec->spec;
6793 int i;
6794
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006795 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006796 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006797 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006798 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006799 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006800 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006801 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006802 }
6803}
6804
6805static void alc883_auto_init_hp_out(struct hda_codec *codec)
6806{
6807 struct alc_spec *spec = codec->spec;
6808 hda_nid_t pin;
6809
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006810 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006811 if (pin) /* connect to front */
6812 /* use dac 0 */
6813 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6814}
6815
6816#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6817#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6818
6819static void alc883_auto_init_analog_input(struct hda_codec *codec)
6820{
6821 struct alc_spec *spec = codec->spec;
6822 int i;
6823
6824 for (i = 0; i < AUTO_PIN_LAST; i++) {
6825 hda_nid_t nid = spec->autocfg.input_pins[i];
6826 if (alc883_is_input_pin(nid)) {
6827 snd_hda_codec_write(codec, nid, 0,
6828 AC_VERB_SET_PIN_WIDGET_CONTROL,
6829 (i <= AUTO_PIN_FRONT_MIC ?
6830 PIN_VREF80 : PIN_IN));
6831 if (nid != ALC883_PIN_CD_NID)
6832 snd_hda_codec_write(codec, nid, 0,
6833 AC_VERB_SET_AMP_GAIN_MUTE,
6834 AMP_OUT_MUTE);
6835 }
6836 }
6837}
6838
6839/* almost identical with ALC880 parser... */
6840static int alc883_parse_auto_config(struct hda_codec *codec)
6841{
6842 struct alc_spec *spec = codec->spec;
6843 int err = alc880_parse_auto_config(codec);
6844
6845 if (err < 0)
6846 return err;
6847 else if (err > 0)
6848 /* hack - override the init verbs */
6849 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006850 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6851 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006852 return err;
6853}
6854
6855/* additional initialization for auto-configuration model */
6856static void alc883_auto_init(struct hda_codec *codec)
6857{
6858 alc883_auto_init_multi_out(codec);
6859 alc883_auto_init_hp_out(codec);
6860 alc883_auto_init_analog_input(codec);
6861}
6862
6863static int patch_alc883(struct hda_codec *codec)
6864{
6865 struct alc_spec *spec;
6866 int err, board_config;
6867
6868 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6869 if (spec == NULL)
6870 return -ENOMEM;
6871
6872 codec->spec = spec;
6873
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006874 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6875 alc883_models,
6876 alc883_cfg_tbl);
6877 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006878 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6879 "trying auto-probe from BIOS...\n");
6880 board_config = ALC883_AUTO;
6881 }
6882
6883 if (board_config == ALC883_AUTO) {
6884 /* automatic parse from the BIOS config */
6885 err = alc883_parse_auto_config(codec);
6886 if (err < 0) {
6887 alc_free(codec);
6888 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006889 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006890 printk(KERN_INFO
6891 "hda_codec: Cannot set up configuration "
6892 "from BIOS. Using base mode...\n");
6893 board_config = ALC883_3ST_2ch_DIG;
6894 }
6895 }
6896
6897 if (board_config != ALC883_AUTO)
6898 setup_preset(spec, &alc883_presets[board_config]);
6899
6900 spec->stream_name_analog = "ALC883 Analog";
6901 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6902 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6903
6904 spec->stream_name_digital = "ALC883 Digital";
6905 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6906 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6907
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006908 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006909 spec->adc_nids = alc883_adc_nids;
6910 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6911 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006912
6913 codec->patch_ops = alc_patch_ops;
6914 if (board_config == ALC883_AUTO)
6915 spec->init_hook = alc883_auto_init;
6916
6917 return 0;
6918}
6919
6920/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006921 * ALC262 support
6922 */
6923
6924#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6925#define ALC262_DIGIN_NID ALC880_DIGIN_NID
6926
6927#define alc262_dac_nids alc260_dac_nids
6928#define alc262_adc_nids alc882_adc_nids
6929#define alc262_adc_nids_alt alc882_adc_nids_alt
6930
6931#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01006932#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01006933
6934static struct snd_kcontrol_new alc262_base_mixer[] = {
6935 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6936 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6937 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6938 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6940 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006944 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6945 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006946 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006947 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6948 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6949 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6950 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6951 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6952 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006953 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01006954};
6955
Kailang Yangccc656c2006-10-17 12:32:26 +02006956static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
6957 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6958 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6959 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6960 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6961 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6962 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6964 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006965 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006966 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6967 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006968 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006969 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6970 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6971 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
6972 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6973 { } /* end */
6974};
6975
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006976static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6978 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6980 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6981 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6982
6983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006988 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006989 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6990 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6993 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6994 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6995 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6996 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6997 { } /* end */
6998};
6999
Kailang Yangcd7509a2007-01-26 18:33:17 +01007000static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7001 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7002 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7003 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7005 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7006 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7007 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7008 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007009 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7012 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7013 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7014 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7015 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7016 { } /* end */
7017};
7018
7019static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7020 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7021 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007022 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007023 { } /* end */
7024};
7025
Kailang Yang272a5272007-05-14 11:00:38 +02007026static struct snd_kcontrol_new alc262_sony_mixer[] = {
7027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7028 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7030 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7031 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7032 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7033 { } /* end */
7034};
7035
Kailang Yang83c34212007-07-05 11:43:05 +02007036static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7038 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7040 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7041 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7042 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7043 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7044 { } /* end */
7045};
Kailang Yang272a5272007-05-14 11:00:38 +02007046
Kailang Yangdf694da2005-12-05 19:42:22 +01007047#define alc262_capture_mixer alc882_capture_mixer
7048#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7049
7050/*
7051 * generic initialization of ADC, input mixers and output mixers
7052 */
7053static struct hda_verb alc262_init_verbs[] = {
7054 /*
7055 * Unmute ADC0-2 and set the default input to mic-in
7056 */
7057 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7059 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7061 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7063
7064 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7065 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007066 * Note: PASD motherboards uses the Line In 2 as the input for
7067 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007068 */
7069 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7075
7076 /*
7077 * Set up output mixers (0x0c - 0x0e)
7078 */
7079 /* set vol=0 to output mixers */
7080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7083 /* set up input amps for analog loopback */
7084 /* Amp Indices: DAC = 0, mixer = 1 */
7085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7091
7092 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7094 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7095 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7097 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7098
7099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7100 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7101 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7102 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7103 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7104
7105 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7106 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7107
7108 /* FIXME: use matrix-type input source selection */
7109 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7110 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7111 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7115 /* Input mixer2 */
7116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7120 /* Input mixer3 */
7121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007125
7126 { }
7127};
7128
Kailang Yangccc656c2006-10-17 12:32:26 +02007129static struct hda_verb alc262_hippo_unsol_verbs[] = {
7130 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7132 {}
7133};
7134
7135static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7136 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7137 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7138 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7139
7140 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7141 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7142 {}
7143};
7144
Kailang Yang272a5272007-05-14 11:00:38 +02007145static struct hda_verb alc262_sony_unsol_verbs[] = {
7146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7147 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7148 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7149
7150 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7151 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7152};
7153
Kailang Yangccc656c2006-10-17 12:32:26 +02007154/* mute/unmute internal speaker according to the hp jack and mute state */
7155static void alc262_hippo_automute(struct hda_codec *codec, int force)
7156{
7157 struct alc_spec *spec = codec->spec;
7158 unsigned int mute;
7159
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007160 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007161 unsigned int present;
7162 /* need to execute and sync at first */
7163 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7164 present = snd_hda_codec_read(codec, 0x15, 0,
7165 AC_VERB_GET_PIN_SENSE, 0);
7166 spec->jack_present = (present & 0x80000000) != 0;
7167 spec->sense_updated = 1;
7168 }
7169 if (spec->jack_present) {
7170 /* mute internal speaker */
7171 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7172 0x80, 0x80);
7173 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7174 0x80, 0x80);
7175 } else {
7176 /* unmute internal speaker if necessary */
7177 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7178 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7179 0x80, mute & 0x80);
7180 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7181 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7182 0x80, mute & 0x80);
7183 }
7184}
7185
7186/* unsolicited event for HP jack sensing */
7187static void alc262_hippo_unsol_event(struct hda_codec *codec,
7188 unsigned int res)
7189{
7190 if ((res >> 26) != ALC880_HP_EVENT)
7191 return;
7192 alc262_hippo_automute(codec, 1);
7193}
7194
7195static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7196{
7197 struct alc_spec *spec = codec->spec;
7198 unsigned int mute;
7199
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007200 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007201 unsigned int present;
7202 /* need to execute and sync at first */
7203 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7204 present = snd_hda_codec_read(codec, 0x1b, 0,
7205 AC_VERB_GET_PIN_SENSE, 0);
7206 spec->jack_present = (present & 0x80000000) != 0;
7207 spec->sense_updated = 1;
7208 }
7209 if (spec->jack_present) {
7210 /* mute internal speaker */
7211 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7212 0x80, 0x80);
7213 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7214 0x80, 0x80);
7215 } else {
7216 /* unmute internal speaker if necessary */
7217 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7218 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7219 0x80, mute & 0x80);
7220 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7221 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7222 0x80, mute & 0x80);
7223 }
7224}
7225
7226/* unsolicited event for HP jack sensing */
7227static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7228 unsigned int res)
7229{
7230 if ((res >> 26) != ALC880_HP_EVENT)
7231 return;
7232 alc262_hippo1_automute(codec, 1);
7233}
7234
Takashi Iwai834be882006-03-01 14:16:17 +01007235/*
7236 * fujitsu model
7237 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7238 */
7239
7240#define ALC_HP_EVENT 0x37
7241
7242static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7243 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7245 {}
7246};
7247
7248static struct hda_input_mux alc262_fujitsu_capture_source = {
7249 .num_items = 2,
7250 .items = {
7251 { "Mic", 0x0 },
7252 { "CD", 0x4 },
7253 },
7254};
7255
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007256static struct hda_input_mux alc262_HP_capture_source = {
7257 .num_items = 5,
7258 .items = {
7259 { "Mic", 0x0 },
7260 { "Front Mic", 0x3 },
7261 { "Line", 0x2 },
7262 { "CD", 0x4 },
7263 { "AUX IN", 0x6 },
7264 },
7265};
7266
Takashi Iwai834be882006-03-01 14:16:17 +01007267/* mute/unmute internal speaker according to the hp jack and mute state */
7268static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7269{
7270 struct alc_spec *spec = codec->spec;
7271 unsigned int mute;
7272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007273 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007274 unsigned int present;
7275 /* need to execute and sync at first */
7276 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7277 present = snd_hda_codec_read(codec, 0x14, 0,
7278 AC_VERB_GET_PIN_SENSE, 0);
7279 spec->jack_present = (present & 0x80000000) != 0;
7280 spec->sense_updated = 1;
7281 }
7282 if (spec->jack_present) {
7283 /* mute internal speaker */
7284 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7285 0x80, 0x80);
7286 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7287 0x80, 0x80);
7288 } else {
7289 /* unmute internal speaker if necessary */
7290 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7291 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7292 0x80, mute & 0x80);
7293 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7294 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7295 0x80, mute & 0x80);
7296 }
7297}
7298
7299/* unsolicited event for HP jack sensing */
7300static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7301 unsigned int res)
7302{
7303 if ((res >> 26) != ALC_HP_EVENT)
7304 return;
7305 alc262_fujitsu_automute(codec, 1);
7306}
7307
7308/* bind volumes of both NID 0x0c and 0x0d */
7309static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7310 struct snd_ctl_elem_value *ucontrol)
7311{
7312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7313 long *valp = ucontrol->value.integer.value;
7314 int change;
7315
7316 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7317 0x7f, valp[0] & 0x7f);
7318 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7319 0x7f, valp[1] & 0x7f);
7320 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7321 0x7f, valp[0] & 0x7f);
7322 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7323 0x7f, valp[1] & 0x7f);
7324 return change;
7325}
7326
7327/* bind hp and internal speaker mute (with plug check) */
7328static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7329 struct snd_ctl_elem_value *ucontrol)
7330{
7331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7332 long *valp = ucontrol->value.integer.value;
7333 int change;
7334
7335 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7336 0x80, valp[0] ? 0 : 0x80);
7337 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7338 0x80, valp[1] ? 0 : 0x80);
7339 if (change || codec->in_resume)
7340 alc262_fujitsu_automute(codec, codec->in_resume);
7341 return change;
7342}
7343
7344static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7345 {
7346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7347 .name = "Master Playback Volume",
7348 .info = snd_hda_mixer_amp_volume_info,
7349 .get = snd_hda_mixer_amp_volume_get,
7350 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007351 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007352 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7353 },
7354 {
7355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7356 .name = "Master Playback Switch",
7357 .info = snd_hda_mixer_amp_switch_info,
7358 .get = snd_hda_mixer_amp_switch_get,
7359 .put = alc262_fujitsu_master_sw_put,
7360 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7361 },
7362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7364 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7367 { } /* end */
7368};
7369
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007370/* additional init verbs for Benq laptops */
7371static struct hda_verb alc262_EAPD_verbs[] = {
7372 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7373 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7374 {}
7375};
7376
Kailang Yang83c34212007-07-05 11:43:05 +02007377static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7378 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7379 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7380
7381 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7382 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7383 {}
7384};
7385
Kailang Yangdf694da2005-12-05 19:42:22 +01007386/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007387static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7388 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007389{
7390 hda_nid_t nid;
7391 int err;
7392
7393 spec->multiout.num_dacs = 1; /* only use one dac */
7394 spec->multiout.dac_nids = spec->private_dac_nids;
7395 spec->multiout.dac_nids[0] = 2;
7396
7397 nid = cfg->line_out_pins[0];
7398 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007399 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7400 "Front Playback Volume",
7401 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7402 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007403 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007404 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7405 "Front Playback Switch",
7406 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7407 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007408 return err;
7409 }
7410
Takashi Iwai82bc9552006-03-21 11:24:42 +01007411 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007412 if (nid) {
7413 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007414 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7415 "Speaker Playback Volume",
7416 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7417 HDA_OUTPUT));
7418 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007419 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007420 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7421 "Speaker Playback Switch",
7422 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7423 HDA_OUTPUT));
7424 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007425 return err;
7426 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007427 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7428 "Speaker Playback Switch",
7429 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7430 HDA_OUTPUT));
7431 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007432 return err;
7433 }
7434 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007435 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007436 if (nid) {
7437 /* spec->multiout.hp_nid = 2; */
7438 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007439 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7440 "Headphone Playback Volume",
7441 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7442 HDA_OUTPUT));
7443 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007444 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007445 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7446 "Headphone Playback Switch",
7447 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7448 HDA_OUTPUT));
7449 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007450 return err;
7451 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007452 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7453 "Headphone Playback Switch",
7454 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7455 HDA_OUTPUT));
7456 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007457 return err;
7458 }
7459 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007460 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007461}
7462
7463/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007464#define alc262_auto_create_analog_input_ctls \
7465 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007466
7467/*
7468 * generic initialization of ADC, input mixers and output mixers
7469 */
7470static struct hda_verb alc262_volume_init_verbs[] = {
7471 /*
7472 * Unmute ADC0-2 and set the default input to mic-in
7473 */
7474 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7476 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7477 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7478 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7479 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7480
7481 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7482 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007483 * Note: PASD motherboards uses the Line In 2 as the input for
7484 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007485 */
7486 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7487 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7490 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7491 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7492
7493 /*
7494 * Set up output mixers (0x0c - 0x0f)
7495 */
7496 /* set vol=0 to output mixers */
7497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7498 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7499 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7500
7501 /* set up input amps for analog loopback */
7502 /* Amp Indices: DAC = 0, mixer = 1 */
7503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7509
7510 /* FIXME: use matrix-type input source selection */
7511 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7512 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7513 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7514 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7517 /* Input mixer2 */
7518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7519 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7522 /* Input mixer3 */
7523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7527
7528 { }
7529};
7530
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007531static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7532 /*
7533 * Unmute ADC0-2 and set the default input to mic-in
7534 */
7535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7537 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7541
7542 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7543 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007544 * Note: PASD motherboards uses the Line In 2 as the input for
7545 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007546 */
7547 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7555
7556 /*
7557 * Set up output mixers (0x0c - 0x0e)
7558 */
7559 /* set vol=0 to output mixers */
7560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7562 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7563
7564 /* set up input amps for analog loopback */
7565 /* Amp Indices: DAC = 0, mixer = 1 */
7566 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7568 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7569 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7572
7573 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7575 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7576
7577 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7579
7580 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7581 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7582
7583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7584 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7585 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7586 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7587 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7588
7589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7590 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7591 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7592 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7593 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7594 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7595
7596
7597 /* FIXME: use matrix-type input source selection */
7598 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7599 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7600 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7601 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7602 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7604 /* Input mixer2 */
7605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7607 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7608 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7609 /* Input mixer3 */
7610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7614
7615 { }
7616};
7617
Kailang Yangcd7509a2007-01-26 18:33:17 +01007618static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7619 /*
7620 * Unmute ADC0-2 and set the default input to mic-in
7621 */
7622 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7624 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7626 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7627 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7628
7629 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7630 * mixer widget
7631 * Note: PASD motherboards uses the Line In 2 as the input for front
7632 * panel mic (mic 2)
7633 */
7634 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7643 /*
7644 * Set up output mixers (0x0c - 0x0e)
7645 */
7646 /* set vol=0 to output mixers */
7647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7649 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7650
7651 /* set up input amps for analog loopback */
7652 /* Amp Indices: DAC = 0, mixer = 1 */
7653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7658 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7659
7660
7661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7663 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7664 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7665 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7666 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7667 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7668
7669 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7671
7672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7674
7675 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7677 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7678 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7679 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7680 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7681
7682 /* FIXME: use matrix-type input source selection */
7683 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7684 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7685 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7686 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7687 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7690 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7692 /* Input mixer2 */
7693 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7694 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7695 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7696 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7698 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7700 /* Input mixer3 */
7701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7704 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7705 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7706 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7708
7709 { }
7710};
7711
Kailang Yangdf694da2005-12-05 19:42:22 +01007712/* pcm configuration: identiacal with ALC880 */
7713#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7714#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7715#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7716#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7717
7718/*
7719 * BIOS auto configuration
7720 */
7721static int alc262_parse_auto_config(struct hda_codec *codec)
7722{
7723 struct alc_spec *spec = codec->spec;
7724 int err;
7725 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7726
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007727 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7728 alc262_ignore);
7729 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007730 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007731 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007732 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007733 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7734 if (err < 0)
7735 return err;
7736 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7737 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007738 return err;
7739
7740 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7741
7742 if (spec->autocfg.dig_out_pin)
7743 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7744 if (spec->autocfg.dig_in_pin)
7745 spec->dig_in_nid = ALC262_DIGIN_NID;
7746
7747 if (spec->kctl_alloc)
7748 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7749
7750 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007751 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007752 spec->input_mux = &spec->private_imux;
7753
7754 return 1;
7755}
7756
7757#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7758#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7759#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7760
7761
7762/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007763static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007764{
Kailang Yangdf694da2005-12-05 19:42:22 +01007765 alc262_auto_init_multi_out(codec);
7766 alc262_auto_init_hp_out(codec);
7767 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007768}
7769
7770/*
7771 * configuration and preset
7772 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007773static const char *alc262_models[ALC262_MODEL_LAST] = {
7774 [ALC262_BASIC] = "basic",
7775 [ALC262_HIPPO] = "hippo",
7776 [ALC262_HIPPO_1] = "hippo_1",
7777 [ALC262_FUJITSU] = "fujitsu",
7778 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007779 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007780 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02007781 [ALC262_BENQ_T31] = "benq-t31",
7782 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007783 [ALC262_AUTO] = "auto",
7784};
7785
7786static struct snd_pci_quirk alc262_cfg_tbl[] = {
7787 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7788 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7789 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007790 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7791 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007792 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007793 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007794 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007795 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007796 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7797 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7798 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7799 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7800 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7801 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7802 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7803 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007804 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7805 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7806 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7807 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02007808 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Kailang Yang272a5272007-05-14 11:00:38 +02007809 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7810 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7811 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007812 {}
7813};
7814
7815static struct alc_config_preset alc262_presets[] = {
7816 [ALC262_BASIC] = {
7817 .mixers = { alc262_base_mixer },
7818 .init_verbs = { alc262_init_verbs },
7819 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7820 .dac_nids = alc262_dac_nids,
7821 .hp_nid = 0x03,
7822 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7823 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007824 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007825 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007826 [ALC262_HIPPO] = {
7827 .mixers = { alc262_base_mixer },
7828 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7829 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7830 .dac_nids = alc262_dac_nids,
7831 .hp_nid = 0x03,
7832 .dig_out_nid = ALC262_DIGOUT_NID,
7833 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7834 .channel_mode = alc262_modes,
7835 .input_mux = &alc262_capture_source,
7836 .unsol_event = alc262_hippo_unsol_event,
7837 },
7838 [ALC262_HIPPO_1] = {
7839 .mixers = { alc262_hippo1_mixer },
7840 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7841 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7842 .dac_nids = alc262_dac_nids,
7843 .hp_nid = 0x02,
7844 .dig_out_nid = ALC262_DIGOUT_NID,
7845 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7846 .channel_mode = alc262_modes,
7847 .input_mux = &alc262_capture_source,
7848 .unsol_event = alc262_hippo1_unsol_event,
7849 },
Takashi Iwai834be882006-03-01 14:16:17 +01007850 [ALC262_FUJITSU] = {
7851 .mixers = { alc262_fujitsu_mixer },
7852 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7853 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7854 .dac_nids = alc262_dac_nids,
7855 .hp_nid = 0x03,
7856 .dig_out_nid = ALC262_DIGOUT_NID,
7857 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7858 .channel_mode = alc262_modes,
7859 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007860 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007861 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007862 [ALC262_HP_BPC] = {
7863 .mixers = { alc262_HP_BPC_mixer },
7864 .init_verbs = { alc262_HP_BPC_init_verbs },
7865 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7866 .dac_nids = alc262_dac_nids,
7867 .hp_nid = 0x03,
7868 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7869 .channel_mode = alc262_modes,
7870 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007871 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007872 [ALC262_HP_BPC_D7000_WF] = {
7873 .mixers = { alc262_HP_BPC_WildWest_mixer },
7874 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7875 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7876 .dac_nids = alc262_dac_nids,
7877 .hp_nid = 0x03,
7878 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7879 .channel_mode = alc262_modes,
7880 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007881 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007882 [ALC262_HP_BPC_D7000_WL] = {
7883 .mixers = { alc262_HP_BPC_WildWest_mixer,
7884 alc262_HP_BPC_WildWest_option_mixer },
7885 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7886 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7887 .dac_nids = alc262_dac_nids,
7888 .hp_nid = 0x03,
7889 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7890 .channel_mode = alc262_modes,
7891 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007892 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007893 [ALC262_BENQ_ED8] = {
7894 .mixers = { alc262_base_mixer },
7895 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7896 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7897 .dac_nids = alc262_dac_nids,
7898 .hp_nid = 0x03,
7899 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7900 .channel_mode = alc262_modes,
7901 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007902 },
Kailang Yang272a5272007-05-14 11:00:38 +02007903 [ALC262_SONY_ASSAMD] = {
7904 .mixers = { alc262_sony_mixer },
7905 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7906 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7907 .dac_nids = alc262_dac_nids,
7908 .hp_nid = 0x02,
7909 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7910 .channel_mode = alc262_modes,
7911 .input_mux = &alc262_capture_source,
7912 .unsol_event = alc262_hippo_unsol_event,
Kailang Yang83c34212007-07-05 11:43:05 +02007913 },
7914 [ALC262_BENQ_T31] = {
7915 .mixers = { alc262_benq_t31_mixer },
7916 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
7917 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7918 .dac_nids = alc262_dac_nids,
7919 .hp_nid = 0x03,
7920 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7921 .channel_mode = alc262_modes,
7922 .input_mux = &alc262_capture_source,
7923 .unsol_event = alc262_hippo_unsol_event,
Kailang Yang272a5272007-05-14 11:00:38 +02007924 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007925};
7926
7927static int patch_alc262(struct hda_codec *codec)
7928{
7929 struct alc_spec *spec;
7930 int board_config;
7931 int err;
7932
Robert P. J. Daydc041e02006-12-19 14:44:15 +01007933 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01007934 if (spec == NULL)
7935 return -ENOMEM;
7936
7937 codec->spec = spec;
7938#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007939 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7940 * under-run
7941 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007942 {
7943 int tmp;
7944 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7945 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7946 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7947 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7948 }
7949#endif
7950
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007951 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7952 alc262_models,
7953 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01007954
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007955 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007956 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7957 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007958 board_config = ALC262_AUTO;
7959 }
7960
7961 if (board_config == ALC262_AUTO) {
7962 /* automatic parse from the BIOS config */
7963 err = alc262_parse_auto_config(codec);
7964 if (err < 0) {
7965 alc_free(codec);
7966 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007967 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007968 printk(KERN_INFO
7969 "hda_codec: Cannot set up configuration "
7970 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007971 board_config = ALC262_BASIC;
7972 }
7973 }
7974
7975 if (board_config != ALC262_AUTO)
7976 setup_preset(spec, &alc262_presets[board_config]);
7977
7978 spec->stream_name_analog = "ALC262 Analog";
7979 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7980 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7981
7982 spec->stream_name_digital = "ALC262 Digital";
7983 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7984 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7985
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007986 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007987 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007988 unsigned int wcap = get_wcaps(codec, 0x07);
7989
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007990 /* get type */
7991 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007992 if (wcap != AC_WID_AUD_IN) {
7993 spec->adc_nids = alc262_adc_nids_alt;
7994 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007995 spec->mixers[spec->num_mixers] =
7996 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01007997 spec->num_mixers++;
7998 } else {
7999 spec->adc_nids = alc262_adc_nids;
8000 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8001 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8002 spec->num_mixers++;
8003 }
8004 }
8005
8006 codec->patch_ops = alc_patch_ops;
8007 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008008 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01008009
Kailang Yangdf694da2005-12-05 19:42:22 +01008010 return 0;
8011}
8012
Kailang Yangdf694da2005-12-05 19:42:22 +01008013/*
Kailang Yanga361d842007-06-05 12:30:55 +02008014 * ALC268 channel source setting (2 channel)
8015 */
8016#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8017#define alc268_modes alc260_modes
8018
8019static hda_nid_t alc268_dac_nids[2] = {
8020 /* front, hp */
8021 0x02, 0x03
8022};
8023
8024static hda_nid_t alc268_adc_nids[2] = {
8025 /* ADC0-1 */
8026 0x08, 0x07
8027};
8028
8029static hda_nid_t alc268_adc_nids_alt[1] = {
8030 /* ADC0 */
8031 0x08
8032};
8033
8034static struct snd_kcontrol_new alc268_base_mixer[] = {
8035 /* output mixer control */
8036 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8037 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8038 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8040 { }
8041};
8042
8043/*
8044 * generic initialization of ADC, input mixers and output mixers
8045 */
8046static struct hda_verb alc268_base_init_verbs[] = {
8047 /* Unmute DAC0-1 and set vol = 0 */
8048 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8049 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8050 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8051 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8052 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8053 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8054
8055 /*
8056 * Set up output mixers (0x0c - 0x0e)
8057 */
8058 /* set vol=0 to output mixers */
8059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8060 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8061 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8062 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8063
8064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8065 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8066
8067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8069 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8070 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8071 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8072 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8073 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8074 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8075
8076 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8078 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8081 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8082 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8083 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8084
8085 /* FIXME: use matrix-type input source selection */
8086 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8087 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8088 /* Input mixer2 */
8089 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8090 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8091 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8093
8094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8098 { }
8099};
8100
8101/*
8102 * generic initialization of ADC, input mixers and output mixers
8103 */
8104static struct hda_verb alc268_volume_init_verbs[] = {
8105 /* set output DAC */
8106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8107 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8108 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8109 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8110
8111 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8112 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8113 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8114 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8115 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8116
8117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8120 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8121 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8122
8123 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8124 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8126 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8127
8128 /* set PCBEEP vol = 0 */
8129 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8130
8131 { }
8132};
8133
8134#define alc268_mux_enum_info alc_mux_enum_info
8135#define alc268_mux_enum_get alc_mux_enum_get
8136
8137static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8138 struct snd_ctl_elem_value *ucontrol)
8139{
8140 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8141 struct alc_spec *spec = codec->spec;
8142 const struct hda_input_mux *imux = spec->input_mux;
8143 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8144 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8145 hda_nid_t nid = capture_mixers[adc_idx];
8146 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8147 unsigned int i, idx;
8148
8149 idx = ucontrol->value.enumerated.item[0];
8150 if (idx >= imux->num_items)
8151 idx = imux->num_items - 1;
8152 if (*cur_val == idx && !codec->in_resume)
8153 return 0;
8154 for (i = 0; i < imux->num_items; i++) {
8155 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8156 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8157 v | (imux->items[i].index << 8));
8158 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8159 idx );
8160 }
8161 *cur_val = idx;
8162 return 1;
8163}
8164
8165static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8166 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8167 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8168 {
8169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8170 /* The multiple "Capture Source" controls confuse alsamixer
8171 * So call somewhat different..
8172 * FIXME: the controls appear in the "playback" view!
8173 */
8174 /* .name = "Capture Source", */
8175 .name = "Input Source",
8176 .count = 1,
8177 .info = alc268_mux_enum_info,
8178 .get = alc268_mux_enum_get,
8179 .put = alc268_mux_enum_put,
8180 },
8181 { } /* end */
8182};
8183
8184static struct snd_kcontrol_new alc268_capture_mixer[] = {
8185 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8186 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8187 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8188 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8189 {
8190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8191 /* The multiple "Capture Source" controls confuse alsamixer
8192 * So call somewhat different..
8193 * FIXME: the controls appear in the "playback" view!
8194 */
8195 /* .name = "Capture Source", */
8196 .name = "Input Source",
8197 .count = 2,
8198 .info = alc268_mux_enum_info,
8199 .get = alc268_mux_enum_get,
8200 .put = alc268_mux_enum_put,
8201 },
8202 { } /* end */
8203};
8204
8205static struct hda_input_mux alc268_capture_source = {
8206 .num_items = 4,
8207 .items = {
8208 { "Mic", 0x0 },
8209 { "Front Mic", 0x1 },
8210 { "Line", 0x2 },
8211 { "CD", 0x3 },
8212 },
8213};
8214
8215/* create input playback/capture controls for the given pin */
8216static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8217 const char *ctlname, int idx)
8218{
8219 char name[32];
8220 int err;
8221
8222 sprintf(name, "%s Playback Volume", ctlname);
8223 if (nid == 0x14) {
8224 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8225 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8226 HDA_OUTPUT));
8227 if (err < 0)
8228 return err;
8229 } else if (nid == 0x15) {
8230 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8231 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8232 HDA_OUTPUT));
8233 if (err < 0)
8234 return err;
8235 } else
8236 return -1;
8237 sprintf(name, "%s Playback Switch", ctlname);
8238 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8239 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8240 if (err < 0)
8241 return err;
8242 return 0;
8243}
8244
8245/* add playback controls from the parsed DAC table */
8246static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8247 const struct auto_pin_cfg *cfg)
8248{
8249 hda_nid_t nid;
8250 int err;
8251
8252 spec->multiout.num_dacs = 2; /* only use one dac */
8253 spec->multiout.dac_nids = spec->private_dac_nids;
8254 spec->multiout.dac_nids[0] = 2;
8255 spec->multiout.dac_nids[1] = 3;
8256
8257 nid = cfg->line_out_pins[0];
8258 if (nid)
8259 alc268_new_analog_output(spec, nid, "Front", 0);
8260
8261 nid = cfg->speaker_pins[0];
8262 if (nid == 0x1d) {
8263 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8264 "Speaker Playback Volume",
8265 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8266 if (err < 0)
8267 return err;
8268 }
8269 nid = cfg->hp_pins[0];
8270 if (nid)
8271 alc268_new_analog_output(spec, nid, "Headphone", 0);
8272
8273 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8274 if (nid == 0x16) {
8275 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8276 "Mono Playback Switch",
8277 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8278 if (err < 0)
8279 return err;
8280 }
8281 return 0;
8282}
8283
8284/* create playback/capture controls for input pins */
8285static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8286 const struct auto_pin_cfg *cfg)
8287{
8288 struct hda_input_mux *imux = &spec->private_imux;
8289 int i, idx1;
8290
8291 for (i = 0; i < AUTO_PIN_LAST; i++) {
8292 switch(cfg->input_pins[i]) {
8293 case 0x18:
8294 idx1 = 0; /* Mic 1 */
8295 break;
8296 case 0x19:
8297 idx1 = 1; /* Mic 2 */
8298 break;
8299 case 0x1a:
8300 idx1 = 2; /* Line In */
8301 break;
8302 case 0x1c:
8303 idx1 = 3; /* CD */
8304 break;
8305 default:
8306 continue;
8307 }
8308 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8309 imux->items[imux->num_items].index = idx1;
8310 imux->num_items++;
8311 }
8312 return 0;
8313}
8314
8315static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8316{
8317 struct alc_spec *spec = codec->spec;
8318 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8319 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8320 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8321 unsigned int dac_vol1, dac_vol2;
8322
8323 if (speaker_nid) {
8324 snd_hda_codec_write(codec, speaker_nid, 0,
8325 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8326 snd_hda_codec_write(codec, 0x0f, 0,
8327 AC_VERB_SET_AMP_GAIN_MUTE,
8328 AMP_IN_UNMUTE(1));
8329 snd_hda_codec_write(codec, 0x10, 0,
8330 AC_VERB_SET_AMP_GAIN_MUTE,
8331 AMP_IN_UNMUTE(1));
8332 } else {
8333 snd_hda_codec_write(codec, 0x0f, 0,
8334 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8335 snd_hda_codec_write(codec, 0x10, 0,
8336 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8337 }
8338
8339 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8340 if (line_nid == 0x14)
8341 dac_vol2 = AMP_OUT_ZERO;
8342 else if (line_nid == 0x15)
8343 dac_vol1 = AMP_OUT_ZERO;
8344 if (hp_nid == 0x14)
8345 dac_vol2 = AMP_OUT_ZERO;
8346 else if (hp_nid == 0x15)
8347 dac_vol1 = AMP_OUT_ZERO;
8348 if (line_nid != 0x16 || hp_nid != 0x16 ||
8349 spec->autocfg.line_out_pins[1] != 0x16 ||
8350 spec->autocfg.line_out_pins[2] != 0x16)
8351 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8352
8353 snd_hda_codec_write(codec, 0x02, 0,
8354 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8355 snd_hda_codec_write(codec, 0x03, 0,
8356 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8357}
8358
8359/* pcm configuration: identiacal with ALC880 */
8360#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8361#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8362#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8363
8364/*
8365 * BIOS auto configuration
8366 */
8367static int alc268_parse_auto_config(struct hda_codec *codec)
8368{
8369 struct alc_spec *spec = codec->spec;
8370 int err;
8371 static hda_nid_t alc268_ignore[] = { 0 };
8372
8373 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8374 alc268_ignore);
8375 if (err < 0)
8376 return err;
8377 if (!spec->autocfg.line_outs)
8378 return 0; /* can't find valid BIOS pin config */
8379
8380 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8381 if (err < 0)
8382 return err;
8383 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8384 if (err < 0)
8385 return err;
8386
8387 spec->multiout.max_channels = 2;
8388
8389 /* digital only support output */
8390 if (spec->autocfg.dig_out_pin)
8391 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8392
8393 if (spec->kctl_alloc)
8394 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8395
8396 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8397 spec->num_mux_defs = 1;
8398 spec->input_mux = &spec->private_imux;
8399
8400 return 1;
8401}
8402
8403#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8404#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8405#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8406
8407/* init callback for auto-configuration model -- overriding the default init */
8408static void alc268_auto_init(struct hda_codec *codec)
8409{
8410 alc268_auto_init_multi_out(codec);
8411 alc268_auto_init_hp_out(codec);
8412 alc268_auto_init_mono_speaker_out(codec);
8413 alc268_auto_init_analog_input(codec);
8414}
8415
8416/*
8417 * configuration and preset
8418 */
8419static const char *alc268_models[ALC268_MODEL_LAST] = {
8420 [ALC268_3ST] = "3stack",
8421 [ALC268_AUTO] = "auto",
8422};
8423
8424static struct snd_pci_quirk alc268_cfg_tbl[] = {
8425 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8426 {}
8427};
8428
8429static struct alc_config_preset alc268_presets[] = {
8430 [ALC268_3ST] = {
8431 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8432 .init_verbs = { alc268_base_init_verbs },
8433 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8434 .dac_nids = alc268_dac_nids,
8435 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8436 .adc_nids = alc268_adc_nids_alt,
8437 .hp_nid = 0x03,
8438 .dig_out_nid = ALC268_DIGOUT_NID,
8439 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8440 .channel_mode = alc268_modes,
8441 .input_mux = &alc268_capture_source,
8442 },
8443};
8444
8445static int patch_alc268(struct hda_codec *codec)
8446{
8447 struct alc_spec *spec;
8448 int board_config;
8449 int err;
8450
8451 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8452 if (spec == NULL)
8453 return -ENOMEM;
8454
8455 codec->spec = spec;
8456
8457 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8458 alc268_models,
8459 alc268_cfg_tbl);
8460
8461 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8462 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8463 "trying auto-probe from BIOS...\n");
8464 board_config = ALC268_AUTO;
8465 }
8466
8467 if (board_config == ALC268_AUTO) {
8468 /* automatic parse from the BIOS config */
8469 err = alc268_parse_auto_config(codec);
8470 if (err < 0) {
8471 alc_free(codec);
8472 return err;
8473 } else if (!err) {
8474 printk(KERN_INFO
8475 "hda_codec: Cannot set up configuration "
8476 "from BIOS. Using base mode...\n");
8477 board_config = ALC268_3ST;
8478 }
8479 }
8480
8481 if (board_config != ALC268_AUTO)
8482 setup_preset(spec, &alc268_presets[board_config]);
8483
8484 spec->stream_name_analog = "ALC268 Analog";
8485 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8486 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8487
8488 spec->stream_name_digital = "ALC268 Digital";
8489 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8490
8491 if (board_config == ALC268_AUTO) {
8492 if (!spec->adc_nids && spec->input_mux) {
8493 /* check whether NID 0x07 is valid */
8494 unsigned int wcap = get_wcaps(codec, 0x07);
8495
8496 /* get type */
8497 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8498 if (wcap != AC_WID_AUD_IN) {
8499 spec->adc_nids = alc268_adc_nids_alt;
8500 spec->num_adc_nids =
8501 ARRAY_SIZE(alc268_adc_nids_alt);
8502 spec->mixers[spec->num_mixers] =
8503 alc268_capture_alt_mixer;
8504 spec->num_mixers++;
8505 } else {
8506 spec->adc_nids = alc268_adc_nids;
8507 spec->num_adc_nids =
8508 ARRAY_SIZE(alc268_adc_nids);
8509 spec->mixers[spec->num_mixers] =
8510 alc268_capture_mixer;
8511 spec->num_mixers++;
8512 }
8513 }
8514 }
8515 codec->patch_ops = alc_patch_ops;
8516 if (board_config == ALC268_AUTO)
8517 spec->init_hook = alc268_auto_init;
8518
8519 return 0;
8520}
8521
8522/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008523 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8524 */
8525
8526/*
8527 * set the path ways for 2 channel output
8528 * need to set the codec line out and mic 1 pin widgets to inputs
8529 */
8530static struct hda_verb alc861_threestack_ch2_init[] = {
8531 /* set pin widget 1Ah (line in) for input */
8532 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008533 /* set pin widget 18h (mic1/2) for input, for mic also enable
8534 * the vref
8535 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008536 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8537
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008538 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8539#if 0
8540 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8541 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8542#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008543 { } /* end */
8544};
8545/*
8546 * 6ch mode
8547 * need to set the codec line out and mic 1 pin widgets to outputs
8548 */
8549static struct hda_verb alc861_threestack_ch6_init[] = {
8550 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8551 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8552 /* set pin widget 18h (mic1) for output (CLFE)*/
8553 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8554
8555 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008556 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008557
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008558 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8559#if 0
8560 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8561 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8562#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008563 { } /* end */
8564};
8565
8566static struct hda_channel_mode alc861_threestack_modes[2] = {
8567 { 2, alc861_threestack_ch2_init },
8568 { 6, alc861_threestack_ch6_init },
8569};
Takashi Iwai22309c32006-08-09 16:57:28 +02008570/* Set mic1 as input and unmute the mixer */
8571static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8572 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8573 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8574 { } /* end */
8575};
8576/* Set mic1 as output and mute mixer */
8577static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8578 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8579 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8580 { } /* end */
8581};
8582
8583static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8584 { 2, alc861_uniwill_m31_ch2_init },
8585 { 4, alc861_uniwill_m31_ch4_init },
8586};
Kailang Yangdf694da2005-12-05 19:42:22 +01008587
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008588/* Set mic1 and line-in as input and unmute the mixer */
8589static struct hda_verb alc861_asus_ch2_init[] = {
8590 /* set pin widget 1Ah (line in) for input */
8591 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008592 /* set pin widget 18h (mic1/2) for input, for mic also enable
8593 * the vref
8594 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008595 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8596
8597 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8598#if 0
8599 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8600 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8601#endif
8602 { } /* end */
8603};
8604/* Set mic1 nad line-in as output and mute mixer */
8605static struct hda_verb alc861_asus_ch6_init[] = {
8606 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8607 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8608 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8609 /* set pin widget 18h (mic1) for output (CLFE)*/
8610 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8611 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8612 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8613 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8614
8615 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8616#if 0
8617 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8618 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8619#endif
8620 { } /* end */
8621};
8622
8623static struct hda_channel_mode alc861_asus_modes[2] = {
8624 { 2, alc861_asus_ch2_init },
8625 { 6, alc861_asus_ch6_init },
8626};
8627
Kailang Yangdf694da2005-12-05 19:42:22 +01008628/* patch-ALC861 */
8629
8630static struct snd_kcontrol_new alc861_base_mixer[] = {
8631 /* output mixer control */
8632 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8633 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8634 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8635 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8636 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8637
8638 /*Input mixer control */
8639 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8640 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8641 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8642 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8643 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8644 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8646 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8647 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008649
Kailang Yangdf694da2005-12-05 19:42:22 +01008650 /* Capture mixer control */
8651 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8652 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8653 {
8654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8655 .name = "Capture Source",
8656 .count = 1,
8657 .info = alc_mux_enum_info,
8658 .get = alc_mux_enum_get,
8659 .put = alc_mux_enum_put,
8660 },
8661 { } /* end */
8662};
8663
8664static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8665 /* output mixer control */
8666 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8667 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8668 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8669 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8670 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8671
8672 /* Input mixer control */
8673 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8674 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8675 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8676 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8677 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8678 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8680 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8681 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008683
Kailang Yangdf694da2005-12-05 19:42:22 +01008684 /* Capture mixer control */
8685 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8686 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8687 {
8688 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8689 .name = "Capture Source",
8690 .count = 1,
8691 .info = alc_mux_enum_info,
8692 .get = alc_mux_enum_get,
8693 .put = alc_mux_enum_put,
8694 },
8695 {
8696 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8697 .name = "Channel Mode",
8698 .info = alc_ch_mode_info,
8699 .get = alc_ch_mode_get,
8700 .put = alc_ch_mode_put,
8701 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8702 },
8703 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008704};
8705
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008706static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008707 /* output mixer control */
8708 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8710 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8711
8712 /*Capture mixer control */
8713 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8714 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8715 {
8716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8717 .name = "Capture Source",
8718 .count = 1,
8719 .info = alc_mux_enum_info,
8720 .get = alc_mux_enum_get,
8721 .put = alc_mux_enum_put,
8722 },
8723
8724 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008725};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008726
Takashi Iwai22309c32006-08-09 16:57:28 +02008727static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8728 /* output mixer control */
8729 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8730 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8731 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8732 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8733 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8734
8735 /* Input mixer control */
8736 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8737 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8738 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8739 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8740 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8741 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8743 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8744 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8745 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008746
Takashi Iwai22309c32006-08-09 16:57:28 +02008747 /* Capture mixer control */
8748 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8749 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8750 {
8751 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8752 .name = "Capture Source",
8753 .count = 1,
8754 .info = alc_mux_enum_info,
8755 .get = alc_mux_enum_get,
8756 .put = alc_mux_enum_put,
8757 },
8758 {
8759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8760 .name = "Channel Mode",
8761 .info = alc_ch_mode_info,
8762 .get = alc_ch_mode_get,
8763 .put = alc_ch_mode_put,
8764 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8765 },
8766 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008767};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008768
8769static struct snd_kcontrol_new alc861_asus_mixer[] = {
8770 /* output mixer control */
8771 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8772 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8773 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8774 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8775 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8776
8777 /* Input mixer control */
8778 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8779 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8780 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8781 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8782 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8783 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8785 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8786 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008787 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8788
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008789 /* Capture mixer control */
8790 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8791 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8792 {
8793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8794 .name = "Capture Source",
8795 .count = 1,
8796 .info = alc_mux_enum_info,
8797 .get = alc_mux_enum_get,
8798 .put = alc_mux_enum_put,
8799 },
8800 {
8801 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8802 .name = "Channel Mode",
8803 .info = alc_ch_mode_info,
8804 .get = alc_ch_mode_get,
8805 .put = alc_ch_mode_put,
8806 .private_value = ARRAY_SIZE(alc861_asus_modes),
8807 },
8808 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008809};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008810
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008811/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008812static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008813 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8814 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8815 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8816 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8817 { }
8818};
8819
Kailang Yangdf694da2005-12-05 19:42:22 +01008820/*
8821 * generic initialization of ADC, input mixers and output mixers
8822 */
8823static struct hda_verb alc861_base_init_verbs[] = {
8824 /*
8825 * Unmute ADC0 and set the default input to mic-in
8826 */
8827 /* port-A for surround (rear panel) */
8828 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8829 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8830 /* port-B for mic-in (rear panel) with vref */
8831 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8832 /* port-C for line-in (rear panel) */
8833 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8834 /* port-D for Front */
8835 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8836 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8837 /* port-E for HP out (front panel) */
8838 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8839 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008840 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008841 /* port-F for mic-in (front panel) with vref */
8842 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8843 /* port-G for CLFE (rear panel) */
8844 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8845 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8846 /* port-H for side (rear panel) */
8847 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8848 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8849 /* CD-in */
8850 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8851 /* route front mic to ADC1*/
8852 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8854
8855 /* Unmute DAC0~3 & spdif out*/
8856 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8857 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8858 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8859 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8861
8862 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8863 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8864 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8865 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8866 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8867
8868 /* Unmute Stereo Mixer 15 */
8869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8870 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008872 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008873
8874 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8875 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8876 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8877 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8878 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8879 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8881 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008882 /* hp used DAC 3 (Front) */
8883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008884 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8885
8886 { }
8887};
8888
8889static struct hda_verb alc861_threestack_init_verbs[] = {
8890 /*
8891 * Unmute ADC0 and set the default input to mic-in
8892 */
8893 /* port-A for surround (rear panel) */
8894 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8895 /* port-B for mic-in (rear panel) with vref */
8896 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8897 /* port-C for line-in (rear panel) */
8898 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8899 /* port-D for Front */
8900 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8901 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8902 /* port-E for HP out (front panel) */
8903 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8904 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008905 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008906 /* port-F for mic-in (front panel) with vref */
8907 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8908 /* port-G for CLFE (rear panel) */
8909 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8910 /* port-H for side (rear panel) */
8911 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8912 /* CD-in */
8913 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8914 /* route front mic to ADC1*/
8915 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917 /* Unmute DAC0~3 & spdif out*/
8918 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8919 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8920 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8921 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8922 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8923
8924 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8925 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8926 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8927 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8928 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8929
8930 /* Unmute Stereo Mixer 15 */
8931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8933 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008935
8936 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8938 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8940 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8942 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8943 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008944 /* hp used DAC 3 (Front) */
8945 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8947 { }
8948};
Takashi Iwai22309c32006-08-09 16:57:28 +02008949
8950static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
8951 /*
8952 * Unmute ADC0 and set the default input to mic-in
8953 */
8954 /* port-A for surround (rear panel) */
8955 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8956 /* port-B for mic-in (rear panel) with vref */
8957 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8958 /* port-C for line-in (rear panel) */
8959 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8960 /* port-D for Front */
8961 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8962 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8963 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008964 /* this has to be set to VREF80 */
8965 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008966 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008967 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008968 /* port-F for mic-in (front panel) with vref */
8969 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8970 /* port-G for CLFE (rear panel) */
8971 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8972 /* port-H for side (rear panel) */
8973 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8974 /* CD-in */
8975 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8976 /* route front mic to ADC1*/
8977 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8978 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8979 /* Unmute DAC0~3 & spdif out*/
8980 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8981 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8982 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8983 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8984 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8985
8986 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8987 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8988 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8989 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8990 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8991
8992 /* Unmute Stereo Mixer 15 */
8993 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8994 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02008997
8998 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8999 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9000 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9001 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9002 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9003 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9004 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9005 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009006 /* hp used DAC 3 (Front) */
9007 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009008 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9009 { }
9010};
9011
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009012static struct hda_verb alc861_asus_init_verbs[] = {
9013 /*
9014 * Unmute ADC0 and set the default input to mic-in
9015 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009016 /* port-A for surround (rear panel)
9017 * according to codec#0 this is the HP jack
9018 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009019 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9020 /* route front PCM to HP */
9021 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9022 /* port-B for mic-in (rear panel) with vref */
9023 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9024 /* port-C for line-in (rear panel) */
9025 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9026 /* port-D for Front */
9027 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9028 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9029 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009030 /* this has to be set to VREF80 */
9031 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009032 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009033 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009034 /* port-F for mic-in (front panel) with vref */
9035 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9036 /* port-G for CLFE (rear panel) */
9037 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9038 /* port-H for side (rear panel) */
9039 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9040 /* CD-in */
9041 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9042 /* route front mic to ADC1*/
9043 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9044 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9045 /* Unmute DAC0~3 & spdif out*/
9046 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9047 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9048 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9049 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9051 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9052 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9053 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9054 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9055 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9056
9057 /* Unmute Stereo Mixer 15 */
9058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009061 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009062
9063 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9064 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9065 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9066 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9067 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9068 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9070 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009071 /* hp used DAC 3 (Front) */
9072 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009073 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9074 { }
9075};
9076
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009077/* additional init verbs for ASUS laptops */
9078static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9079 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9080 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9081 { }
9082};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009083
Kailang Yangdf694da2005-12-05 19:42:22 +01009084/*
9085 * generic initialization of ADC, input mixers and output mixers
9086 */
9087static struct hda_verb alc861_auto_init_verbs[] = {
9088 /*
9089 * Unmute ADC0 and set the default input to mic-in
9090 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009091 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009092 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9093
9094 /* Unmute DAC0~3 & spdif out*/
9095 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9096 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9097 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9098 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9099 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9100
9101 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9102 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9103 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9104 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9105 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9106
9107 /* Unmute Stereo Mixer 15 */
9108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9109 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9112
9113 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9114 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9115 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9116 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9117 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9118 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9119 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9120 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9121
9122 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9123 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009124 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009126 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9127 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009128 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9129 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009130
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009131 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009132
9133 { }
9134};
9135
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009136static struct hda_verb alc861_toshiba_init_verbs[] = {
9137 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009138
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009139 { }
9140};
9141
9142/* toggle speaker-output according to the hp-jack state */
9143static void alc861_toshiba_automute(struct hda_codec *codec)
9144{
9145 unsigned int present;
9146
9147 present = snd_hda_codec_read(codec, 0x0f, 0,
9148 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9149 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
9150 0x80, present ? 0x80 : 0);
9151 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
9152 0x80, present ? 0x80 : 0);
9153 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
9154 0x80, present ? 0 : 0x80);
9155 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
9156 0x80, present ? 0 : 0x80);
9157}
9158
9159static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9160 unsigned int res)
9161{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009162 if ((res >> 26) == ALC880_HP_EVENT)
9163 alc861_toshiba_automute(codec);
9164}
9165
Kailang Yangdf694da2005-12-05 19:42:22 +01009166/* pcm configuration: identiacal with ALC880 */
9167#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9168#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9169#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9170#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9171
9172
9173#define ALC861_DIGOUT_NID 0x07
9174
9175static struct hda_channel_mode alc861_8ch_modes[1] = {
9176 { 8, NULL }
9177};
9178
9179static hda_nid_t alc861_dac_nids[4] = {
9180 /* front, surround, clfe, side */
9181 0x03, 0x06, 0x05, 0x04
9182};
9183
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009184static hda_nid_t alc660_dac_nids[3] = {
9185 /* front, clfe, surround */
9186 0x03, 0x05, 0x06
9187};
9188
Kailang Yangdf694da2005-12-05 19:42:22 +01009189static hda_nid_t alc861_adc_nids[1] = {
9190 /* ADC0-2 */
9191 0x08,
9192};
9193
9194static struct hda_input_mux alc861_capture_source = {
9195 .num_items = 5,
9196 .items = {
9197 { "Mic", 0x0 },
9198 { "Front Mic", 0x3 },
9199 { "Line", 0x1 },
9200 { "CD", 0x4 },
9201 { "Mixer", 0x5 },
9202 },
9203};
9204
9205/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009206static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9207 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009208{
9209 int i;
9210 hda_nid_t nid;
9211
9212 spec->multiout.dac_nids = spec->private_dac_nids;
9213 for (i = 0; i < cfg->line_outs; i++) {
9214 nid = cfg->line_out_pins[i];
9215 if (nid) {
9216 if (i >= ARRAY_SIZE(alc861_dac_nids))
9217 continue;
9218 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9219 }
9220 }
9221 spec->multiout.num_dacs = cfg->line_outs;
9222 return 0;
9223}
9224
9225/* add playback controls from the parsed DAC table */
9226static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9227 const struct auto_pin_cfg *cfg)
9228{
9229 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009230 static const char *chname[4] = {
9231 "Front", "Surround", NULL /*CLFE*/, "Side"
9232 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009233 hda_nid_t nid;
9234 int i, idx, err;
9235
9236 for (i = 0; i < cfg->line_outs; i++) {
9237 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009238 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009239 continue;
9240 if (nid == 0x05) {
9241 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009242 err = add_control(spec, ALC_CTL_BIND_MUTE,
9243 "Center Playback Switch",
9244 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9245 HDA_OUTPUT));
9246 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009248 err = add_control(spec, ALC_CTL_BIND_MUTE,
9249 "LFE Playback Switch",
9250 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9251 HDA_OUTPUT));
9252 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009253 return err;
9254 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009255 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9256 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009257 if (nid == alc861_dac_nids[idx])
9258 break;
9259 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009260 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9261 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9262 HDA_OUTPUT));
9263 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009264 return err;
9265 }
9266 }
9267 return 0;
9268}
9269
9270static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9271{
9272 int err;
9273 hda_nid_t nid;
9274
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009275 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009276 return 0;
9277
9278 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9279 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009280 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9281 "Headphone Playback Switch",
9282 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9283 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009284 return err;
9285 spec->multiout.hp_nid = nid;
9286 }
9287 return 0;
9288}
9289
9290/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009291static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9292 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009293{
Kailang Yangdf694da2005-12-05 19:42:22 +01009294 struct hda_input_mux *imux = &spec->private_imux;
9295 int i, err, idx, idx1;
9296
9297 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009298 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009299 case 0x0c:
9300 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009301 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009302 break;
9303 case 0x0f:
9304 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009305 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009306 break;
9307 case 0x0d:
9308 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009309 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009310 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009311 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009312 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009313 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009314 break;
9315 case 0x11:
9316 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009317 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009318 break;
9319 default:
9320 continue;
9321 }
9322
Takashi Iwai4a471b72005-12-07 13:56:29 +01009323 err = new_analog_input(spec, cfg->input_pins[i],
9324 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009325 if (err < 0)
9326 return err;
9327
Takashi Iwai4a471b72005-12-07 13:56:29 +01009328 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009329 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009330 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009331 }
9332 return 0;
9333}
9334
9335static struct snd_kcontrol_new alc861_capture_mixer[] = {
9336 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9337 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9338
9339 {
9340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9341 /* The multiple "Capture Source" controls confuse alsamixer
9342 * So call somewhat different..
9343 *FIXME: the controls appear in the "playback" view!
9344 */
9345 /* .name = "Capture Source", */
9346 .name = "Input Source",
9347 .count = 1,
9348 .info = alc_mux_enum_info,
9349 .get = alc_mux_enum_get,
9350 .put = alc_mux_enum_put,
9351 },
9352 { } /* end */
9353};
9354
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009355static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9356 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009357 int pin_type, int dac_idx)
9358{
9359 /* set as output */
9360
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009361 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9362 pin_type);
9363 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9364 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009365
9366}
9367
9368static void alc861_auto_init_multi_out(struct hda_codec *codec)
9369{
9370 struct alc_spec *spec = codec->spec;
9371 int i;
9372
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009373 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009374 for (i = 0; i < spec->autocfg.line_outs; i++) {
9375 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009376 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009377 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009378 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009379 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009380 }
9381}
9382
9383static void alc861_auto_init_hp_out(struct hda_codec *codec)
9384{
9385 struct alc_spec *spec = codec->spec;
9386 hda_nid_t pin;
9387
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009388 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009389 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009390 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9391 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009392}
9393
9394static void alc861_auto_init_analog_input(struct hda_codec *codec)
9395{
9396 struct alc_spec *spec = codec->spec;
9397 int i;
9398
9399 for (i = 0; i < AUTO_PIN_LAST; i++) {
9400 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009401 if (nid >= 0x0c && nid <= 0x11) {
9402 snd_hda_codec_write(codec, nid, 0,
9403 AC_VERB_SET_PIN_WIDGET_CONTROL,
9404 i <= AUTO_PIN_FRONT_MIC ?
9405 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009406 }
9407 }
9408}
9409
9410/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009411/* return 1 if successful, 0 if the proper config is not found,
9412 * or a negative error code
9413 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009414static int alc861_parse_auto_config(struct hda_codec *codec)
9415{
9416 struct alc_spec *spec = codec->spec;
9417 int err;
9418 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9419
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009420 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9421 alc861_ignore);
9422 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009423 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009424 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009425 return 0; /* can't find valid BIOS pin config */
9426
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009427 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9428 if (err < 0)
9429 return err;
9430 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9431 if (err < 0)
9432 return err;
9433 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9434 if (err < 0)
9435 return err;
9436 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9437 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009438 return err;
9439
9440 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9441
9442 if (spec->autocfg.dig_out_pin)
9443 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9444
9445 if (spec->kctl_alloc)
9446 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9447
9448 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9449
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009450 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009451 spec->input_mux = &spec->private_imux;
9452
9453 spec->adc_nids = alc861_adc_nids;
9454 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9455 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9456 spec->num_mixers++;
9457
9458 return 1;
9459}
9460
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009461/* additional initialization for auto-configuration model */
9462static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009463{
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 alc861_auto_init_multi_out(codec);
9465 alc861_auto_init_hp_out(codec);
9466 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009467}
9468
9469
9470/*
9471 * configuration and preset
9472 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009473static const char *alc861_models[ALC861_MODEL_LAST] = {
9474 [ALC861_3ST] = "3stack",
9475 [ALC660_3ST] = "3stack-660",
9476 [ALC861_3ST_DIG] = "3stack-dig",
9477 [ALC861_6ST_DIG] = "6stack-dig",
9478 [ALC861_UNIWILL_M31] = "uniwill-m31",
9479 [ALC861_TOSHIBA] = "toshiba",
9480 [ALC861_ASUS] = "asus",
9481 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9482 [ALC861_AUTO] = "auto",
9483};
9484
9485static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009486 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009487 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9488 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009489 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +02009490 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009491 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +02009492 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +01009493 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +02009494 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9495 * Any other models that need this preset?
9496 */
9497 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009498 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009499 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009500 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009501 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009502 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009503 {}
9504};
9505
9506static struct alc_config_preset alc861_presets[] = {
9507 [ALC861_3ST] = {
9508 .mixers = { alc861_3ST_mixer },
9509 .init_verbs = { alc861_threestack_init_verbs },
9510 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9511 .dac_nids = alc861_dac_nids,
9512 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9513 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009514 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009515 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9516 .adc_nids = alc861_adc_nids,
9517 .input_mux = &alc861_capture_source,
9518 },
9519 [ALC861_3ST_DIG] = {
9520 .mixers = { alc861_base_mixer },
9521 .init_verbs = { alc861_threestack_init_verbs },
9522 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9523 .dac_nids = alc861_dac_nids,
9524 .dig_out_nid = ALC861_DIGOUT_NID,
9525 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9526 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009527 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009528 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9529 .adc_nids = alc861_adc_nids,
9530 .input_mux = &alc861_capture_source,
9531 },
9532 [ALC861_6ST_DIG] = {
9533 .mixers = { alc861_base_mixer },
9534 .init_verbs = { alc861_base_init_verbs },
9535 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9536 .dac_nids = alc861_dac_nids,
9537 .dig_out_nid = ALC861_DIGOUT_NID,
9538 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9539 .channel_mode = alc861_8ch_modes,
9540 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9541 .adc_nids = alc861_adc_nids,
9542 .input_mux = &alc861_capture_source,
9543 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009544 [ALC660_3ST] = {
9545 .mixers = { alc861_3ST_mixer },
9546 .init_verbs = { alc861_threestack_init_verbs },
9547 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9548 .dac_nids = alc660_dac_nids,
9549 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9550 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009551 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009552 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9553 .adc_nids = alc861_adc_nids,
9554 .input_mux = &alc861_capture_source,
9555 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009556 [ALC861_UNIWILL_M31] = {
9557 .mixers = { alc861_uniwill_m31_mixer },
9558 .init_verbs = { alc861_uniwill_m31_init_verbs },
9559 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9560 .dac_nids = alc861_dac_nids,
9561 .dig_out_nid = ALC861_DIGOUT_NID,
9562 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9563 .channel_mode = alc861_uniwill_m31_modes,
9564 .need_dac_fix = 1,
9565 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9566 .adc_nids = alc861_adc_nids,
9567 .input_mux = &alc861_capture_source,
9568 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009569 [ALC861_TOSHIBA] = {
9570 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009571 .init_verbs = { alc861_base_init_verbs,
9572 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009573 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9574 .dac_nids = alc861_dac_nids,
9575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9576 .channel_mode = alc883_3ST_2ch_modes,
9577 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9578 .adc_nids = alc861_adc_nids,
9579 .input_mux = &alc861_capture_source,
9580 .unsol_event = alc861_toshiba_unsol_event,
9581 .init_hook = alc861_toshiba_automute,
9582 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009583 [ALC861_ASUS] = {
9584 .mixers = { alc861_asus_mixer },
9585 .init_verbs = { alc861_asus_init_verbs },
9586 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9587 .dac_nids = alc861_dac_nids,
9588 .dig_out_nid = ALC861_DIGOUT_NID,
9589 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9590 .channel_mode = alc861_asus_modes,
9591 .need_dac_fix = 1,
9592 .hp_nid = 0x06,
9593 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9594 .adc_nids = alc861_adc_nids,
9595 .input_mux = &alc861_capture_source,
9596 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009597 [ALC861_ASUS_LAPTOP] = {
9598 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9599 .init_verbs = { alc861_asus_init_verbs,
9600 alc861_asus_laptop_init_verbs },
9601 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9602 .dac_nids = alc861_dac_nids,
9603 .dig_out_nid = ALC861_DIGOUT_NID,
9604 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9605 .channel_mode = alc883_3ST_2ch_modes,
9606 .need_dac_fix = 1,
9607 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9608 .adc_nids = alc861_adc_nids,
9609 .input_mux = &alc861_capture_source,
9610 },
9611};
Kailang Yangdf694da2005-12-05 19:42:22 +01009612
9613
9614static int patch_alc861(struct hda_codec *codec)
9615{
9616 struct alc_spec *spec;
9617 int board_config;
9618 int err;
9619
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009620 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009621 if (spec == NULL)
9622 return -ENOMEM;
9623
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009624 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009625
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009626 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9627 alc861_models,
9628 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009629
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009630 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009631 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9632 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009633 board_config = ALC861_AUTO;
9634 }
9635
9636 if (board_config == ALC861_AUTO) {
9637 /* automatic parse from the BIOS config */
9638 err = alc861_parse_auto_config(codec);
9639 if (err < 0) {
9640 alc_free(codec);
9641 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009642 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009643 printk(KERN_INFO
9644 "hda_codec: Cannot set up configuration "
9645 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009646 board_config = ALC861_3ST_DIG;
9647 }
9648 }
9649
9650 if (board_config != ALC861_AUTO)
9651 setup_preset(spec, &alc861_presets[board_config]);
9652
9653 spec->stream_name_analog = "ALC861 Analog";
9654 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9655 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9656
9657 spec->stream_name_digital = "ALC861 Digital";
9658 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9659 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9660
9661 codec->patch_ops = alc_patch_ops;
9662 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009663 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009664
9665 return 0;
9666}
9667
9668/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009669 * ALC861-VD support
9670 *
9671 * Based on ALC882
9672 *
9673 * In addition, an independent DAC
9674 */
9675#define ALC861VD_DIGOUT_NID 0x06
9676
9677static hda_nid_t alc861vd_dac_nids[4] = {
9678 /* front, surr, clfe, side surr */
9679 0x02, 0x03, 0x04, 0x05
9680};
9681
9682/* dac_nids for ALC660vd are in a different order - according to
9683 * Realtek's driver.
9684 * This should probably tesult in a different mixer for 6stack models
9685 * of ALC660vd codecs, but for now there is only 3stack mixer
9686 * - and it is the same as in 861vd.
9687 * adc_nids in ALC660vd are (is) the same as in 861vd
9688 */
9689static hda_nid_t alc660vd_dac_nids[3] = {
9690 /* front, rear, clfe, rear_surr */
9691 0x02, 0x04, 0x03
9692};
9693
9694static hda_nid_t alc861vd_adc_nids[1] = {
9695 /* ADC0 */
9696 0x09,
9697};
9698
9699/* input MUX */
9700/* FIXME: should be a matrix-type input source selection */
9701static struct hda_input_mux alc861vd_capture_source = {
9702 .num_items = 4,
9703 .items = {
9704 { "Mic", 0x0 },
9705 { "Front Mic", 0x1 },
9706 { "Line", 0x2 },
9707 { "CD", 0x4 },
9708 },
9709};
9710
Kailang Yang272a5272007-05-14 11:00:38 +02009711static struct hda_input_mux alc861vd_dallas_capture_source = {
9712 .num_items = 3,
9713 .items = {
9714 { "Front Mic", 0x0 },
9715 { "ATAPI Mic", 0x1 },
9716 { "Line In", 0x5 },
9717 },
9718};
9719
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009720#define alc861vd_mux_enum_info alc_mux_enum_info
9721#define alc861vd_mux_enum_get alc_mux_enum_get
9722
9723static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9724 struct snd_ctl_elem_value *ucontrol)
9725{
9726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9727 struct alc_spec *spec = codec->spec;
9728 const struct hda_input_mux *imux = spec->input_mux;
9729 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9730 static hda_nid_t capture_mixers[1] = { 0x22 };
9731 hda_nid_t nid = capture_mixers[adc_idx];
9732 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9733 unsigned int i, idx;
9734
9735 idx = ucontrol->value.enumerated.item[0];
9736 if (idx >= imux->num_items)
9737 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009738 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009739 return 0;
9740 for (i = 0; i < imux->num_items; i++) {
9741 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9742 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9743 v | (imux->items[i].index << 8));
9744 }
9745 *cur_val = idx;
9746 return 1;
9747}
9748
9749/*
9750 * 2ch mode
9751 */
9752static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9753 { 2, NULL }
9754};
9755
9756/*
9757 * 6ch mode
9758 */
9759static struct hda_verb alc861vd_6stack_ch6_init[] = {
9760 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9761 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9762 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9763 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9764 { } /* end */
9765};
9766
9767/*
9768 * 8ch mode
9769 */
9770static struct hda_verb alc861vd_6stack_ch8_init[] = {
9771 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9772 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9773 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9774 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9775 { } /* end */
9776};
9777
9778static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9779 { 6, alc861vd_6stack_ch6_init },
9780 { 8, alc861vd_6stack_ch8_init },
9781};
9782
9783static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9784 {
9785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9786 .name = "Channel Mode",
9787 .info = alc_ch_mode_info,
9788 .get = alc_ch_mode_get,
9789 .put = alc_ch_mode_put,
9790 },
9791 { } /* end */
9792};
9793
9794static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9795 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9796 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9797
9798 {
9799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9800 /* The multiple "Capture Source" controls confuse alsamixer
9801 * So call somewhat different..
9802 *FIXME: the controls appear in the "playback" view!
9803 */
9804 /* .name = "Capture Source", */
9805 .name = "Input Source",
9806 .count = 1,
9807 .info = alc861vd_mux_enum_info,
9808 .get = alc861vd_mux_enum_get,
9809 .put = alc861vd_mux_enum_put,
9810 },
9811 { } /* end */
9812};
9813
9814/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9815 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9816 */
9817static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9818 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9819 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9820
9821 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9822 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9823
9824 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9825 HDA_OUTPUT),
9826 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9827 HDA_OUTPUT),
9828 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9829 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9830
9831 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9832 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9833
9834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9835
9836 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9839
9840 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9843
9844 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9845 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9846
9847 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9848 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9849
9850 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9851 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9852
9853 { } /* end */
9854};
9855
9856static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9857 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9858 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9859
9860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9861
9862 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9865
9866 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9868 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9869
9870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9872
9873 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9874 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9875
9876 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9877 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9878
9879 { } /* end */
9880};
9881
Kailang Yangbdd148a2007-05-08 15:19:08 +02009882static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9883 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9884 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9885 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9886
9887 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9888
9889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9892
9893 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9896
9897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9898 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9899
9900 { } /* end */
9901};
9902
Kailang Yang272a5272007-05-14 11:00:38 +02009903/* Pin assignment: Front=0x14, HP = 0x15,
9904 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9905 */
9906static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9907 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9908 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9909 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9910 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9911 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9912 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9913 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9914 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9917 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9918 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9919 {
9920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9921 /* .name = "Capture Source", */
9922 .name = "Input Source",
9923 .count = 1,
9924 .info = alc882_mux_enum_info,
9925 .get = alc882_mux_enum_get,
9926 .put = alc882_mux_enum_put,
9927 },
9928 { } /* end */
9929};
9930
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009931/*
9932 * generic initialization of ADC, input mixers and output mixers
9933 */
9934static struct hda_verb alc861vd_volume_init_verbs[] = {
9935 /*
9936 * Unmute ADC0 and set the default input to mic-in
9937 */
9938 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9939 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9940
9941 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
9942 * the analog-loopback mixer widget
9943 */
9944 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9947 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9950
9951 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +02009952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009956
9957 /*
9958 * Set up output mixers (0x02 - 0x05)
9959 */
9960 /* set vol=0 to output mixers */
9961 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9962 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9963 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9964 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9965
9966 /* set up input amps for analog loopback */
9967 /* Amp Indices: DAC = 0, mixer = 1 */
9968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9970 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9971 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9972 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9973 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9974 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9975 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9976
9977 { }
9978};
9979
9980/*
9981 * 3-stack pin configuration:
9982 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
9983 */
9984static struct hda_verb alc861vd_3stack_init_verbs[] = {
9985 /*
9986 * Set pin mode and muting
9987 */
9988 /* set front pin widgets 0x14 for output */
9989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9990 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9991 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9992
9993 /* Mic (rear) pin: input vref at 80% */
9994 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9995 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9996 /* Front Mic pin: input vref at 80% */
9997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9999 /* Line In pin: input */
10000 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10001 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10002 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10003 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10004 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10005 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10006 /* CD pin widget for input */
10007 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10008
10009 { }
10010};
10011
10012/*
10013 * 6-stack pin configuration:
10014 */
10015static struct hda_verb alc861vd_6stack_init_verbs[] = {
10016 /*
10017 * Set pin mode and muting
10018 */
10019 /* set front pin widgets 0x14 for output */
10020 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10021 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10022 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10023
10024 /* Rear Pin: output 1 (0x0d) */
10025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10027 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10028 /* CLFE Pin: output 2 (0x0e) */
10029 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10030 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10031 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10032 /* Side Pin: output 3 (0x0f) */
10033 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10035 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10036
10037 /* Mic (rear) pin: input vref at 80% */
10038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10039 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10040 /* Front Mic pin: input vref at 80% */
10041 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10042 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10043 /* Line In pin: input */
10044 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10046 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10047 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10048 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10049 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10050 /* CD pin widget for input */
10051 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10052
10053 { }
10054};
10055
Kailang Yangbdd148a2007-05-08 15:19:08 +020010056static struct hda_verb alc861vd_eapd_verbs[] = {
10057 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10058 { }
10059};
10060
10061static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10066 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10067 {}
10068};
10069
10070/* toggle speaker-output according to the hp-jack state */
10071static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10072{
10073 unsigned int present;
10074 unsigned char bits;
10075
10076 present = snd_hda_codec_read(codec, 0x1b, 0,
10077 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10078 bits = present ? 0x80 : 0;
10079 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10080 0x80, bits);
10081 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10082 0x80, bits);
10083}
10084
10085static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10086{
10087 unsigned int present;
10088 unsigned char bits;
10089
10090 present = snd_hda_codec_read(codec, 0x18, 0,
10091 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10092 bits = present ? 0x80 : 0;
10093 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10094 0x80, bits);
10095 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10096 0x80, bits);
10097}
10098
10099static void alc861vd_lenovo_automute(struct hda_codec *codec)
10100{
10101 alc861vd_lenovo_hp_automute(codec);
10102 alc861vd_lenovo_mic_automute(codec);
10103}
10104
10105static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10106 unsigned int res)
10107{
10108 switch (res >> 26) {
10109 case ALC880_HP_EVENT:
10110 alc861vd_lenovo_hp_automute(codec);
10111 break;
10112 case ALC880_MIC_EVENT:
10113 alc861vd_lenovo_mic_automute(codec);
10114 break;
10115 }
10116}
10117
Kailang Yang272a5272007-05-14 11:00:38 +020010118static struct hda_verb alc861vd_dallas_verbs[] = {
10119 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10120 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10121 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10122 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10123
10124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10126 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10127 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10131 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10132
10133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10137 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10138 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10139 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10140 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10141
10142 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10143 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10144 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10145 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10146 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10147 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10148 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10149 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10150
10151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10152 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10155
10156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10157 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10159
10160 { } /* end */
10161};
10162
10163/* toggle speaker-output according to the hp-jack state */
10164static void alc861vd_dallas_automute(struct hda_codec *codec)
10165{
10166 unsigned int present;
10167
10168 present = snd_hda_codec_read(codec, 0x15, 0,
10169 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10170 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10171 0x80, present ? 0x80 : 0);
10172 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10173 0x80, present ? 0x80 : 0);
10174}
10175
10176static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10177{
10178 if ((res >> 26) == ALC880_HP_EVENT)
10179 alc861vd_dallas_automute(codec);
10180}
10181
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010182/* pcm configuration: identiacal with ALC880 */
10183#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10184#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10185#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10186#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10187
10188/*
10189 * configuration and preset
10190 */
10191static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10192 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +020010193 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010194 [ALC861VD_3ST] = "3stack",
10195 [ALC861VD_3ST_DIG] = "3stack-digout",
10196 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010197 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010198 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010199 [ALC861VD_AUTO] = "auto",
10200};
10201
10202static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010203 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010204 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010205 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010206 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10207 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10208
Kailang Yang272a5272007-05-14 11:00:38 +020010209 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10210 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010211 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10212 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010213 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010214 {}
10215};
10216
10217static struct alc_config_preset alc861vd_presets[] = {
10218 [ALC660VD_3ST] = {
10219 .mixers = { alc861vd_3st_mixer },
10220 .init_verbs = { alc861vd_volume_init_verbs,
10221 alc861vd_3stack_init_verbs },
10222 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10223 .dac_nids = alc660vd_dac_nids,
10224 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10225 .adc_nids = alc861vd_adc_nids,
10226 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10227 .channel_mode = alc861vd_3stack_2ch_modes,
10228 .input_mux = &alc861vd_capture_source,
10229 },
Mike Crash6963f842007-06-25 12:12:51 +020010230 [ALC660VD_3ST_DIG] = {
10231 .mixers = { alc861vd_3st_mixer },
10232 .init_verbs = { alc861vd_volume_init_verbs,
10233 alc861vd_3stack_init_verbs },
10234 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10235 .dac_nids = alc660vd_dac_nids,
10236 .dig_out_nid = ALC861VD_DIGOUT_NID,
10237 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10238 .adc_nids = alc861vd_adc_nids,
10239 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10240 .channel_mode = alc861vd_3stack_2ch_modes,
10241 .input_mux = &alc861vd_capture_source,
10242 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010243 [ALC861VD_3ST] = {
10244 .mixers = { alc861vd_3st_mixer },
10245 .init_verbs = { alc861vd_volume_init_verbs,
10246 alc861vd_3stack_init_verbs },
10247 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10248 .dac_nids = alc861vd_dac_nids,
10249 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10250 .channel_mode = alc861vd_3stack_2ch_modes,
10251 .input_mux = &alc861vd_capture_source,
10252 },
10253 [ALC861VD_3ST_DIG] = {
10254 .mixers = { alc861vd_3st_mixer },
10255 .init_verbs = { alc861vd_volume_init_verbs,
10256 alc861vd_3stack_init_verbs },
10257 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10258 .dac_nids = alc861vd_dac_nids,
10259 .dig_out_nid = ALC861VD_DIGOUT_NID,
10260 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10261 .channel_mode = alc861vd_3stack_2ch_modes,
10262 .input_mux = &alc861vd_capture_source,
10263 },
10264 [ALC861VD_6ST_DIG] = {
10265 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10266 .init_verbs = { alc861vd_volume_init_verbs,
10267 alc861vd_6stack_init_verbs },
10268 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10269 .dac_nids = alc861vd_dac_nids,
10270 .dig_out_nid = ALC861VD_DIGOUT_NID,
10271 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10272 .channel_mode = alc861vd_6stack_modes,
10273 .input_mux = &alc861vd_capture_source,
10274 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010275 [ALC861VD_LENOVO] = {
10276 .mixers = { alc861vd_lenovo_mixer },
10277 .init_verbs = { alc861vd_volume_init_verbs,
10278 alc861vd_3stack_init_verbs,
10279 alc861vd_eapd_verbs,
10280 alc861vd_lenovo_unsol_verbs },
10281 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10282 .dac_nids = alc660vd_dac_nids,
10283 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10284 .adc_nids = alc861vd_adc_nids,
10285 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10286 .channel_mode = alc861vd_3stack_2ch_modes,
10287 .input_mux = &alc861vd_capture_source,
10288 .unsol_event = alc861vd_lenovo_unsol_event,
10289 .init_hook = alc861vd_lenovo_automute,
10290 },
Kailang Yang272a5272007-05-14 11:00:38 +020010291 [ALC861VD_DALLAS] = {
10292 .mixers = { alc861vd_dallas_mixer },
10293 .init_verbs = { alc861vd_dallas_verbs },
10294 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10295 .dac_nids = alc861vd_dac_nids,
10296 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10297 .adc_nids = alc861vd_adc_nids,
10298 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10299 .channel_mode = alc861vd_3stack_2ch_modes,
10300 .input_mux = &alc861vd_dallas_capture_source,
10301 .unsol_event = alc861vd_dallas_unsol_event,
10302 .init_hook = alc861vd_dallas_automute,
10303 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010304};
10305
10306/*
10307 * BIOS auto configuration
10308 */
10309static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10310 hda_nid_t nid, int pin_type, int dac_idx)
10311{
10312 /* set as output */
10313 snd_hda_codec_write(codec, nid, 0,
10314 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10315 snd_hda_codec_write(codec, nid, 0,
10316 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10317}
10318
10319static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10320{
10321 struct alc_spec *spec = codec->spec;
10322 int i;
10323
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010324 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010325 for (i = 0; i <= HDA_SIDE; i++) {
10326 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010327 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010328 if (nid)
10329 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010330 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010331 }
10332}
10333
10334
10335static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10336{
10337 struct alc_spec *spec = codec->spec;
10338 hda_nid_t pin;
10339
10340 pin = spec->autocfg.hp_pins[0];
10341 if (pin) /* connect to front and use dac 0 */
10342 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10343}
10344
10345#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10346#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10347
10348static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10349{
10350 struct alc_spec *spec = codec->spec;
10351 int i;
10352
10353 for (i = 0; i < AUTO_PIN_LAST; i++) {
10354 hda_nid_t nid = spec->autocfg.input_pins[i];
10355 if (alc861vd_is_input_pin(nid)) {
10356 snd_hda_codec_write(codec, nid, 0,
10357 AC_VERB_SET_PIN_WIDGET_CONTROL,
10358 i <= AUTO_PIN_FRONT_MIC ?
10359 PIN_VREF80 : PIN_IN);
10360 if (nid != ALC861VD_PIN_CD_NID)
10361 snd_hda_codec_write(codec, nid, 0,
10362 AC_VERB_SET_AMP_GAIN_MUTE,
10363 AMP_OUT_MUTE);
10364 }
10365 }
10366}
10367
10368#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10369#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10370
10371/* add playback controls from the parsed DAC table */
10372/* Based on ALC880 version. But ALC861VD has separate,
10373 * different NIDs for mute/unmute switch and volume control */
10374static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10375 const struct auto_pin_cfg *cfg)
10376{
10377 char name[32];
10378 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10379 hda_nid_t nid_v, nid_s;
10380 int i, err;
10381
10382 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010383 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010384 continue;
10385 nid_v = alc861vd_idx_to_mixer_vol(
10386 alc880_dac_to_idx(
10387 spec->multiout.dac_nids[i]));
10388 nid_s = alc861vd_idx_to_mixer_switch(
10389 alc880_dac_to_idx(
10390 spec->multiout.dac_nids[i]));
10391
10392 if (i == 2) {
10393 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010394 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10395 "Center Playback Volume",
10396 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10397 HDA_OUTPUT));
10398 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010399 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010400 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10401 "LFE Playback Volume",
10402 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10403 HDA_OUTPUT));
10404 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010405 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010406 err = add_control(spec, ALC_CTL_BIND_MUTE,
10407 "Center Playback Switch",
10408 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10409 HDA_INPUT));
10410 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010411 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010412 err = add_control(spec, ALC_CTL_BIND_MUTE,
10413 "LFE Playback Switch",
10414 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10415 HDA_INPUT));
10416 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010417 return err;
10418 } else {
10419 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010420 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10421 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10422 HDA_OUTPUT));
10423 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010424 return err;
10425 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010426 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010427 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010428 HDA_INPUT));
10429 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010430 return err;
10431 }
10432 }
10433 return 0;
10434}
10435
10436/* add playback controls for speaker and HP outputs */
10437/* Based on ALC880 version. But ALC861VD has separate,
10438 * different NIDs for mute/unmute switch and volume control */
10439static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10440 hda_nid_t pin, const char *pfx)
10441{
10442 hda_nid_t nid_v, nid_s;
10443 int err;
10444 char name[32];
10445
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010446 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010447 return 0;
10448
10449 if (alc880_is_fixed_pin(pin)) {
10450 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10451 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010452 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010453 spec->multiout.hp_nid = nid_v;
10454 else
10455 spec->multiout.extra_out_nid[0] = nid_v;
10456 /* control HP volume/switch on the output mixer amp */
10457 nid_v = alc861vd_idx_to_mixer_vol(
10458 alc880_fixed_pin_idx(pin));
10459 nid_s = alc861vd_idx_to_mixer_switch(
10460 alc880_fixed_pin_idx(pin));
10461
10462 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010463 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10464 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10465 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010466 return err;
10467 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010468 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10469 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10470 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010471 return err;
10472 } else if (alc880_is_multi_pin(pin)) {
10473 /* set manual connection */
10474 /* we have only a switch on HP-out PIN */
10475 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010476 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10477 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10478 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010479 return err;
10480 }
10481 return 0;
10482}
10483
10484/* parse the BIOS configuration and set up the alc_spec
10485 * return 1 if successful, 0 if the proper config is not found,
10486 * or a negative error code
10487 * Based on ALC880 version - had to change it to override
10488 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10489static int alc861vd_parse_auto_config(struct hda_codec *codec)
10490{
10491 struct alc_spec *spec = codec->spec;
10492 int err;
10493 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10494
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010495 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10496 alc861vd_ignore);
10497 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010498 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010499 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010500 return 0; /* can't find valid BIOS pin config */
10501
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010502 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10503 if (err < 0)
10504 return err;
10505 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10506 if (err < 0)
10507 return err;
10508 err = alc861vd_auto_create_extra_out(spec,
10509 spec->autocfg.speaker_pins[0],
10510 "Speaker");
10511 if (err < 0)
10512 return err;
10513 err = alc861vd_auto_create_extra_out(spec,
10514 spec->autocfg.hp_pins[0],
10515 "Headphone");
10516 if (err < 0)
10517 return err;
10518 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10519 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010520 return err;
10521
10522 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10523
10524 if (spec->autocfg.dig_out_pin)
10525 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10526
10527 if (spec->kctl_alloc)
10528 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10529
10530 spec->init_verbs[spec->num_init_verbs++]
10531 = alc861vd_volume_init_verbs;
10532
10533 spec->num_mux_defs = 1;
10534 spec->input_mux = &spec->private_imux;
10535
10536 return 1;
10537}
10538
10539/* additional initialization for auto-configuration model */
10540static void alc861vd_auto_init(struct hda_codec *codec)
10541{
10542 alc861vd_auto_init_multi_out(codec);
10543 alc861vd_auto_init_hp_out(codec);
10544 alc861vd_auto_init_analog_input(codec);
10545}
10546
10547static int patch_alc861vd(struct hda_codec *codec)
10548{
10549 struct alc_spec *spec;
10550 int err, board_config;
10551
10552 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10553 if (spec == NULL)
10554 return -ENOMEM;
10555
10556 codec->spec = spec;
10557
10558 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10559 alc861vd_models,
10560 alc861vd_cfg_tbl);
10561
10562 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10563 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10564 "ALC861VD, trying auto-probe from BIOS...\n");
10565 board_config = ALC861VD_AUTO;
10566 }
10567
10568 if (board_config == ALC861VD_AUTO) {
10569 /* automatic parse from the BIOS config */
10570 err = alc861vd_parse_auto_config(codec);
10571 if (err < 0) {
10572 alc_free(codec);
10573 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010574 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010575 printk(KERN_INFO
10576 "hda_codec: Cannot set up configuration "
10577 "from BIOS. Using base mode...\n");
10578 board_config = ALC861VD_3ST;
10579 }
10580 }
10581
10582 if (board_config != ALC861VD_AUTO)
10583 setup_preset(spec, &alc861vd_presets[board_config]);
10584
10585 spec->stream_name_analog = "ALC861VD Analog";
10586 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10587 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10588
10589 spec->stream_name_digital = "ALC861VD Digital";
10590 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10591 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10592
10593 spec->adc_nids = alc861vd_adc_nids;
10594 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10595
10596 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10597 spec->num_mixers++;
10598
10599 codec->patch_ops = alc_patch_ops;
10600
10601 if (board_config == ALC861VD_AUTO)
10602 spec->init_hook = alc861vd_auto_init;
10603
10604 return 0;
10605}
10606
10607/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010608 * ALC662 support
10609 *
10610 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10611 * configuration. Each pin widget can choose any input DACs and a mixer.
10612 * Each ADC is connected from a mixer of all inputs. This makes possible
10613 * 6-channel independent captures.
10614 *
10615 * In addition, an independent DAC for the multi-playback (not used in this
10616 * driver yet).
10617 */
10618#define ALC662_DIGOUT_NID 0x06
10619#define ALC662_DIGIN_NID 0x0a
10620
10621static hda_nid_t alc662_dac_nids[4] = {
10622 /* front, rear, clfe, rear_surr */
10623 0x02, 0x03, 0x04
10624};
10625
10626static hda_nid_t alc662_adc_nids[1] = {
10627 /* ADC1-2 */
10628 0x09,
10629};
10630/* input MUX */
10631/* FIXME: should be a matrix-type input source selection */
10632
10633static struct hda_input_mux alc662_capture_source = {
10634 .num_items = 4,
10635 .items = {
10636 { "Mic", 0x0 },
10637 { "Front Mic", 0x1 },
10638 { "Line", 0x2 },
10639 { "CD", 0x4 },
10640 },
10641};
10642
10643static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10644 .num_items = 2,
10645 .items = {
10646 { "Mic", 0x1 },
10647 { "Line", 0x2 },
10648 },
10649};
10650#define alc662_mux_enum_info alc_mux_enum_info
10651#define alc662_mux_enum_get alc_mux_enum_get
10652
10653static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10654 struct snd_ctl_elem_value *ucontrol)
10655{
10656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10657 struct alc_spec *spec = codec->spec;
10658 const struct hda_input_mux *imux = spec->input_mux;
10659 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10660 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10661 hda_nid_t nid = capture_mixers[adc_idx];
10662 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10663 unsigned int i, idx;
10664
10665 idx = ucontrol->value.enumerated.item[0];
10666 if (idx >= imux->num_items)
10667 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010668 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010669 return 0;
10670 for (i = 0; i < imux->num_items; i++) {
10671 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10672 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10673 v | (imux->items[i].index << 8));
10674 }
10675 *cur_val = idx;
10676 return 1;
10677}
10678/*
10679 * 2ch mode
10680 */
10681static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10682 { 2, NULL }
10683};
10684
10685/*
10686 * 2ch mode
10687 */
10688static struct hda_verb alc662_3ST_ch2_init[] = {
10689 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10690 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10691 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10692 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10693 { } /* end */
10694};
10695
10696/*
10697 * 6ch mode
10698 */
10699static struct hda_verb alc662_3ST_ch6_init[] = {
10700 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10701 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10702 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10703 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10704 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10705 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10706 { } /* end */
10707};
10708
10709static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10710 { 2, alc662_3ST_ch2_init },
10711 { 6, alc662_3ST_ch6_init },
10712};
10713
10714/*
10715 * 2ch mode
10716 */
10717static struct hda_verb alc662_sixstack_ch6_init[] = {
10718 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10719 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10720 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10721 { } /* end */
10722};
10723
10724/*
10725 * 6ch mode
10726 */
10727static struct hda_verb alc662_sixstack_ch8_init[] = {
10728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10729 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10730 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10731 { } /* end */
10732};
10733
10734static struct hda_channel_mode alc662_5stack_modes[2] = {
10735 { 2, alc662_sixstack_ch6_init },
10736 { 6, alc662_sixstack_ch8_init },
10737};
10738
10739/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10740 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10741 */
10742
10743static struct snd_kcontrol_new alc662_base_mixer[] = {
10744 /* output mixer control */
10745 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10746 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10747 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10748 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10749 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10750 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10751 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10752 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10753 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10754
10755 /*Input mixer control */
10756 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10757 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10758 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10759 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10760 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10761 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10762 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10763 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10764
10765 /* Capture mixer control */
10766 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10767 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10768 {
10769 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10770 .name = "Capture Source",
10771 .count = 1,
10772 .info = alc_mux_enum_info,
10773 .get = alc_mux_enum_get,
10774 .put = alc_mux_enum_put,
10775 },
10776 { } /* end */
10777};
10778
10779static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10780 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10781 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10783 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10784 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10785 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10786 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10789 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10790 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10791 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10792 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10793 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10794 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10795 {
10796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10797 /* .name = "Capture Source", */
10798 .name = "Input Source",
10799 .count = 1,
10800 .info = alc662_mux_enum_info,
10801 .get = alc662_mux_enum_get,
10802 .put = alc662_mux_enum_put,
10803 },
10804 { } /* end */
10805};
10806
10807static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10808 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10809 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10810 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10811 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10812 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10813 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10814 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10815 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10816 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10817 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10818 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10819 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10820 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10825 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10826 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10827 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10828 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10829 {
10830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10831 /* .name = "Capture Source", */
10832 .name = "Input Source",
10833 .count = 1,
10834 .info = alc662_mux_enum_info,
10835 .get = alc662_mux_enum_get,
10836 .put = alc662_mux_enum_put,
10837 },
10838 { } /* end */
10839};
10840
10841static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10842 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10843 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10844 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10845 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, 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_chmode_mixer[] = {
10866 {
10867 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10868 .name = "Channel Mode",
10869 .info = alc_ch_mode_info,
10870 .get = alc_ch_mode_get,
10871 .put = alc_ch_mode_put,
10872 },
10873 { } /* end */
10874};
10875
10876static struct hda_verb alc662_init_verbs[] = {
10877 /* ADC: mute amp left and right */
10878 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10879 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10880 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10881
10882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10887
10888 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10889 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10890 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10891 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10892 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10893 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10894
10895 /* Front Pin: output 0 (0x0c) */
10896 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10898
10899 /* Rear Pin: output 1 (0x0d) */
10900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10902
10903 /* CLFE Pin: output 2 (0x0e) */
10904 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10905 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10906
10907 /* Mic (rear) pin: input vref at 80% */
10908 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10910 /* Front Mic pin: input vref at 80% */
10911 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10912 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10913 /* Line In pin: input */
10914 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10915 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10916 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10917 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10918 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10919 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10920 /* CD pin widget for input */
10921 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10922
10923 /* FIXME: use matrix-type input source selection */
10924 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10925 /* Input mixer */
10926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10930 { }
10931};
10932
10933static struct hda_verb alc662_sue_init_verbs[] = {
10934 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10935 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10936 {}
10937};
10938
10939/*
10940 * generic initialization of ADC, input mixers and output mixers
10941 */
10942static struct hda_verb alc662_auto_init_verbs[] = {
10943 /*
10944 * Unmute ADC and set the default input to mic-in
10945 */
10946 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10947 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10948
10949 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10950 * mixer widget
10951 * Note: PASD motherboards uses the Line In 2 as the input for front
10952 * panel mic (mic 2)
10953 */
10954 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10955 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10956 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10957 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10958 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10959 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10960
10961 /*
10962 * Set up output mixers (0x0c - 0x0f)
10963 */
10964 /* set vol=0 to output mixers */
10965 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10966 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10967 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10968
10969 /* set up input amps for analog loopback */
10970 /* Amp Indices: DAC = 0, mixer = 1 */
10971 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10972 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10973 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10974 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10975 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10976 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10977
10978
10979 /* FIXME: use matrix-type input source selection */
10980 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10981 /* Input mixer */
10982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10985 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
10986 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10987
10988 { }
10989};
10990
10991/* capture mixer elements */
10992static struct snd_kcontrol_new alc662_capture_mixer[] = {
10993 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10994 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10995 {
10996 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10997 /* The multiple "Capture Source" controls confuse alsamixer
10998 * So call somewhat different..
10999 * FIXME: the controls appear in the "playback" view!
11000 */
11001 /* .name = "Capture Source", */
11002 .name = "Input Source",
11003 .count = 1,
11004 .info = alc882_mux_enum_info,
11005 .get = alc882_mux_enum_get,
11006 .put = alc882_mux_enum_put,
11007 },
11008 { } /* end */
11009};
11010
11011static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11012{
11013 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011014 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011015
11016 present = snd_hda_codec_read(codec, 0x14, 0,
11017 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011018 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011019 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011020 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011021 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011022 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011023}
11024
11025static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11026{
11027 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011028 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011029
11030 present = snd_hda_codec_read(codec, 0x1b, 0,
11031 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011032 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011033 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011034 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011035 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011036 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011037 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011038 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011039 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011040 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011041}
11042
11043static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11044 unsigned int res)
11045{
11046 if ((res >> 26) == ALC880_HP_EVENT)
11047 alc662_lenovo_101e_all_automute(codec);
11048 if ((res >> 26) == ALC880_FRONT_EVENT)
11049 alc662_lenovo_101e_ispeaker_automute(codec);
11050}
11051
11052
11053/* pcm configuration: identiacal with ALC880 */
11054#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11055#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11056#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11057#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11058
11059/*
11060 * configuration and preset
11061 */
11062static const char *alc662_models[ALC662_MODEL_LAST] = {
11063 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11064 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11065 [ALC662_3ST_6ch] = "3stack-6ch",
11066 [ALC662_5ST_DIG] = "6stack-dig",
11067 [ALC662_LENOVO_101E] = "lenovo-101e",
11068 [ALC662_AUTO] = "auto",
11069};
11070
11071static struct snd_pci_quirk alc662_cfg_tbl[] = {
11072 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11073 {}
11074};
11075
11076static struct alc_config_preset alc662_presets[] = {
11077 [ALC662_3ST_2ch_DIG] = {
11078 .mixers = { alc662_3ST_2ch_mixer },
11079 .init_verbs = { alc662_init_verbs },
11080 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11081 .dac_nids = alc662_dac_nids,
11082 .dig_out_nid = ALC662_DIGOUT_NID,
11083 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11084 .adc_nids = alc662_adc_nids,
11085 .dig_in_nid = ALC662_DIGIN_NID,
11086 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11087 .channel_mode = alc662_3ST_2ch_modes,
11088 .input_mux = &alc662_capture_source,
11089 },
11090 [ALC662_3ST_6ch_DIG] = {
11091 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11092 .init_verbs = { alc662_init_verbs },
11093 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11094 .dac_nids = alc662_dac_nids,
11095 .dig_out_nid = ALC662_DIGOUT_NID,
11096 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11097 .adc_nids = alc662_adc_nids,
11098 .dig_in_nid = ALC662_DIGIN_NID,
11099 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11100 .channel_mode = alc662_3ST_6ch_modes,
11101 .need_dac_fix = 1,
11102 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011103 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011104 [ALC662_3ST_6ch] = {
11105 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11106 .init_verbs = { alc662_init_verbs },
11107 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11108 .dac_nids = alc662_dac_nids,
11109 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11110 .adc_nids = alc662_adc_nids,
11111 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11112 .channel_mode = alc662_3ST_6ch_modes,
11113 .need_dac_fix = 1,
11114 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011115 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011116 [ALC662_5ST_DIG] = {
11117 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11118 .init_verbs = { alc662_init_verbs },
11119 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11120 .dac_nids = alc662_dac_nids,
11121 .dig_out_nid = ALC662_DIGOUT_NID,
11122 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11123 .adc_nids = alc662_adc_nids,
11124 .dig_in_nid = ALC662_DIGIN_NID,
11125 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11126 .channel_mode = alc662_5stack_modes,
11127 .input_mux = &alc662_capture_source,
11128 },
11129 [ALC662_LENOVO_101E] = {
11130 .mixers = { alc662_lenovo_101e_mixer },
11131 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11132 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11133 .dac_nids = alc662_dac_nids,
11134 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11135 .adc_nids = alc662_adc_nids,
11136 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11137 .channel_mode = alc662_3ST_2ch_modes,
11138 .input_mux = &alc662_lenovo_101e_capture_source,
11139 .unsol_event = alc662_lenovo_101e_unsol_event,
11140 .init_hook = alc662_lenovo_101e_all_automute,
11141 },
11142
11143};
11144
11145
11146/*
11147 * BIOS auto configuration
11148 */
11149
11150/* add playback controls from the parsed DAC table */
11151static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11152 const struct auto_pin_cfg *cfg)
11153{
11154 char name[32];
11155 static const char *chname[4] = {
11156 "Front", "Surround", NULL /*CLFE*/, "Side"
11157 };
11158 hda_nid_t nid;
11159 int i, err;
11160
11161 for (i = 0; i < cfg->line_outs; i++) {
11162 if (!spec->multiout.dac_nids[i])
11163 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011164 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011165 if (i == 2) {
11166 /* Center/LFE */
11167 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11168 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011169 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11170 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011171 if (err < 0)
11172 return err;
11173 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11174 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011175 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11176 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011177 if (err < 0)
11178 return err;
11179 err = add_control(spec, ALC_CTL_BIND_MUTE,
11180 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011181 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11182 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011183 if (err < 0)
11184 return err;
11185 err = add_control(spec, ALC_CTL_BIND_MUTE,
11186 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011187 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11188 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011189 if (err < 0)
11190 return err;
11191 } else {
11192 sprintf(name, "%s Playback Volume", chname[i]);
11193 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011194 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11195 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011196 if (err < 0)
11197 return err;
11198 sprintf(name, "%s Playback Switch", chname[i]);
11199 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011200 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11201 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011202 if (err < 0)
11203 return err;
11204 }
11205 }
11206 return 0;
11207}
11208
11209/* add playback controls for speaker and HP outputs */
11210static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11211 const char *pfx)
11212{
11213 hda_nid_t nid;
11214 int err;
11215 char name[32];
11216
11217 if (!pin)
11218 return 0;
11219
11220 if (alc880_is_fixed_pin(pin)) {
11221 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11222 /* printk("DAC nid=%x\n",nid); */
11223 /* specify the DAC as the extra output */
11224 if (!spec->multiout.hp_nid)
11225 spec->multiout.hp_nid = nid;
11226 else
11227 spec->multiout.extra_out_nid[0] = nid;
11228 /* control HP volume/switch on the output mixer amp */
11229 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11230 sprintf(name, "%s Playback Volume", pfx);
11231 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11232 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11233 if (err < 0)
11234 return err;
11235 sprintf(name, "%s Playback Switch", pfx);
11236 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11237 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11238 if (err < 0)
11239 return err;
11240 } else if (alc880_is_multi_pin(pin)) {
11241 /* set manual connection */
11242 /* we have only a switch on HP-out PIN */
11243 sprintf(name, "%s Playback Switch", pfx);
11244 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11245 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11246 if (err < 0)
11247 return err;
11248 }
11249 return 0;
11250}
11251
11252/* create playback/capture controls for input pins */
11253static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11254 const struct auto_pin_cfg *cfg)
11255{
11256 struct hda_input_mux *imux = &spec->private_imux;
11257 int i, err, idx;
11258
11259 for (i = 0; i < AUTO_PIN_LAST; i++) {
11260 if (alc880_is_input_pin(cfg->input_pins[i])) {
11261 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11262 err = new_analog_input(spec, cfg->input_pins[i],
11263 auto_pin_cfg_labels[i],
11264 idx, 0x0b);
11265 if (err < 0)
11266 return err;
11267 imux->items[imux->num_items].label =
11268 auto_pin_cfg_labels[i];
11269 imux->items[imux->num_items].index =
11270 alc880_input_pin_idx(cfg->input_pins[i]);
11271 imux->num_items++;
11272 }
11273 }
11274 return 0;
11275}
11276
11277static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11278 hda_nid_t nid, int pin_type,
11279 int dac_idx)
11280{
11281 /* set as output */
11282 snd_hda_codec_write(codec, nid, 0,
11283 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11284 snd_hda_codec_write(codec, nid, 0,
11285 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11286 /* need the manual connection? */
11287 if (alc880_is_multi_pin(nid)) {
11288 struct alc_spec *spec = codec->spec;
11289 int idx = alc880_multi_pin_idx(nid);
11290 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11291 AC_VERB_SET_CONNECT_SEL,
11292 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11293 }
11294}
11295
11296static void alc662_auto_init_multi_out(struct hda_codec *codec)
11297{
11298 struct alc_spec *spec = codec->spec;
11299 int i;
11300
11301 for (i = 0; i <= HDA_SIDE; i++) {
11302 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011303 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011304 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011305 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011306 i);
11307 }
11308}
11309
11310static void alc662_auto_init_hp_out(struct hda_codec *codec)
11311{
11312 struct alc_spec *spec = codec->spec;
11313 hda_nid_t pin;
11314
11315 pin = spec->autocfg.hp_pins[0];
11316 if (pin) /* connect to front */
11317 /* use dac 0 */
11318 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11319}
11320
11321#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11322#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11323
11324static void alc662_auto_init_analog_input(struct hda_codec *codec)
11325{
11326 struct alc_spec *spec = codec->spec;
11327 int i;
11328
11329 for (i = 0; i < AUTO_PIN_LAST; i++) {
11330 hda_nid_t nid = spec->autocfg.input_pins[i];
11331 if (alc662_is_input_pin(nid)) {
11332 snd_hda_codec_write(codec, nid, 0,
11333 AC_VERB_SET_PIN_WIDGET_CONTROL,
11334 (i <= AUTO_PIN_FRONT_MIC ?
11335 PIN_VREF80 : PIN_IN));
11336 if (nid != ALC662_PIN_CD_NID)
11337 snd_hda_codec_write(codec, nid, 0,
11338 AC_VERB_SET_AMP_GAIN_MUTE,
11339 AMP_OUT_MUTE);
11340 }
11341 }
11342}
11343
11344static int alc662_parse_auto_config(struct hda_codec *codec)
11345{
11346 struct alc_spec *spec = codec->spec;
11347 int err;
11348 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11349
11350 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11351 alc662_ignore);
11352 if (err < 0)
11353 return err;
11354 if (!spec->autocfg.line_outs)
11355 return 0; /* can't find valid BIOS pin config */
11356
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011357 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11358 if (err < 0)
11359 return err;
11360 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11361 if (err < 0)
11362 return err;
11363 err = alc662_auto_create_extra_out(spec,
11364 spec->autocfg.speaker_pins[0],
11365 "Speaker");
11366 if (err < 0)
11367 return err;
11368 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11369 "Headphone");
11370 if (err < 0)
11371 return err;
11372 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11373 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011374 return err;
11375
11376 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11377
11378 if (spec->autocfg.dig_out_pin)
11379 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11380
11381 if (spec->kctl_alloc)
11382 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11383
11384 spec->num_mux_defs = 1;
11385 spec->input_mux = &spec->private_imux;
11386
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011387 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011388 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11389 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011390 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011391}
11392
11393/* additional initialization for auto-configuration model */
11394static void alc662_auto_init(struct hda_codec *codec)
11395{
11396 alc662_auto_init_multi_out(codec);
11397 alc662_auto_init_hp_out(codec);
11398 alc662_auto_init_analog_input(codec);
11399}
11400
11401static int patch_alc662(struct hda_codec *codec)
11402{
11403 struct alc_spec *spec;
11404 int err, board_config;
11405
11406 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11407 if (!spec)
11408 return -ENOMEM;
11409
11410 codec->spec = spec;
11411
11412 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11413 alc662_models,
11414 alc662_cfg_tbl);
11415 if (board_config < 0) {
11416 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11417 "trying auto-probe from BIOS...\n");
11418 board_config = ALC662_AUTO;
11419 }
11420
11421 if (board_config == ALC662_AUTO) {
11422 /* automatic parse from the BIOS config */
11423 err = alc662_parse_auto_config(codec);
11424 if (err < 0) {
11425 alc_free(codec);
11426 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011427 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011428 printk(KERN_INFO
11429 "hda_codec: Cannot set up configuration "
11430 "from BIOS. Using base mode...\n");
11431 board_config = ALC662_3ST_2ch_DIG;
11432 }
11433 }
11434
11435 if (board_config != ALC662_AUTO)
11436 setup_preset(spec, &alc662_presets[board_config]);
11437
11438 spec->stream_name_analog = "ALC662 Analog";
11439 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11440 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11441
11442 spec->stream_name_digital = "ALC662 Digital";
11443 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11444 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11445
11446 if (!spec->adc_nids && spec->input_mux) {
11447 spec->adc_nids = alc662_adc_nids;
11448 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11449 }
11450
11451 codec->patch_ops = alc_patch_ops;
11452 if (board_config == ALC662_AUTO)
11453 spec->init_hook = alc662_auto_init;
11454
11455 return 0;
11456}
11457
11458/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011459 * patch entries
11460 */
11461struct hda_codec_preset snd_hda_preset_realtek[] = {
11462 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011463 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011464 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011465 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011466 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011467 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11468 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11469 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011470 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11471 .patch = patch_alc883 },
11472 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11473 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011474 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011475 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011476 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011477 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011478 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011479 {} /* terminator */
11480};