blob: d839d567f8e473a3e18fbf47ece396bb34456861 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010074 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010076 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020077 ALC260_WILL,
78 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010079#ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020083 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Kailang Yangdf694da2005-12-05 19:42:22 +010086/* ALC262 models */
87enum {
88 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020089 ALC262_HIPPO,
90 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010091 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020092 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010093 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020095 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020096 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020097 ALC262_BENQ_T31,
Kailang Yangdf694da2005-12-05 19:42:22 +010098 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */
100};
101
Kailang Yanga361d842007-06-05 12:30:55 +0200102/* ALC268 models */
103enum {
104 ALC268_3ST,
105 ALC268_AUTO,
106 ALC268_MODEL_LAST /* last tag */
107};
108
Kailang Yangdf694da2005-12-05 19:42:22 +0100109/* ALC861 models */
110enum {
111 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200112 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100113 ALC861_3ST_DIG,
114 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200115 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200116 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200117 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100118 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100119 ALC861_AUTO,
120 ALC861_MODEL_LAST,
121};
122
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100123/* ALC861-VD models */
124enum {
125 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200126 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100127 ALC861VD_3ST,
128 ALC861VD_3ST_DIG,
129 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200130 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200131 ALC861VD_DALLAS,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100132 ALC861VD_AUTO,
133 ALC861VD_MODEL_LAST,
134};
135
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200136/* ALC662 models */
137enum {
138 ALC662_3ST_2ch_DIG,
139 ALC662_3ST_6ch_DIG,
140 ALC662_3ST_6ch,
141 ALC662_5ST_DIG,
142 ALC662_LENOVO_101E,
143 ALC662_AUTO,
144 ALC662_MODEL_LAST,
145};
146
Kailang Yangdf694da2005-12-05 19:42:22 +0100147/* ALC882 models */
148enum {
149 ALC882_3ST_DIG,
150 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200151 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200152 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200153 ALC882_TARGA,
154 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100155 ALC885_MACPRO,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200156 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200157 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100158 ALC882_MODEL_LAST,
159};
160
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200161/* ALC883 models */
162enum {
163 ALC883_3ST_2ch_DIG,
164 ALC883_3ST_6ch_DIG,
165 ALC883_3ST_6ch,
166 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200167 ALC883_TARGA_DIG,
168 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200169 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200170 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200171 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100172 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200174 ALC883_LENOVO_NB0763,
175 ALC888_LENOVO_MS7195_DIG,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200176 ALC888_6ST_HP,
177 ALC888_3ST_HP,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200178 ALC883_AUTO,
179 ALC883_MODEL_LAST,
180};
181
Kailang Yangdf694da2005-12-05 19:42:22 +0100182/* for GPIO Poll */
183#define GPIO_MASK 0x03
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185struct alc_spec {
186 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100187 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 unsigned int num_mixers;
189
Kailang Yangdf694da2005-12-05 19:42:22 +0100190 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200191 * don't forget NULL
192 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200193 */
194 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
Takashi Iwai16ded522005-06-10 19:58:24 +0200196 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 struct hda_pcm_stream *stream_analog_playback;
198 struct hda_pcm_stream *stream_analog_capture;
199
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200200 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 struct hda_pcm_stream *stream_digital_playback;
202 struct hda_pcm_stream *stream_digital_capture;
203
204 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200205 struct hda_multi_out multiout; /* playback set-up
206 * max_channels, dacs must be set
207 * dig_out_nid and hp_nid are optional
208 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210 /* capture */
211 unsigned int num_adc_nids;
212 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200213 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200216 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 const struct hda_input_mux *input_mux;
218 unsigned int cur_mux[3];
219
220 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100221 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200223 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
225 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100226 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200227
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200228 /* dynamic controls, init_verbs and input_mux */
229 struct auto_pin_cfg autocfg;
230 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100231 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200232 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100233 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100234
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100235 /* hooks */
236 void (*init_hook)(struct hda_codec *codec);
237 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
238
Takashi Iwai834be882006-03-01 14:16:17 +0100239 /* for pin sensing */
240 unsigned int sense_updated: 1;
241 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100242};
243
244/*
245 * configuration template - to be copied to the spec instance
246 */
247struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200248 struct snd_kcontrol_new *mixers[5]; /* should be identical size
249 * with spec
250 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100251 const struct hda_verb *init_verbs[5];
252 unsigned int num_dacs;
253 hda_nid_t *dac_nids;
254 hda_nid_t dig_out_nid; /* optional */
255 hda_nid_t hp_nid; /* optional */
256 unsigned int num_adc_nids;
257 hda_nid_t *adc_nids;
258 hda_nid_t dig_in_nid;
259 unsigned int num_channel_mode;
260 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200261 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200262 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100263 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100264 void (*unsol_event)(struct hda_codec *, unsigned int);
265 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266};
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269/*
270 * input MUX handling
271 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200272static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
273 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274{
275 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
276 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200277 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
278 if (mux_idx >= spec->num_mux_defs)
279 mux_idx = 0;
280 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281}
282
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200283static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285{
286 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
287 struct alc_spec *spec = codec->spec;
288 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
289
290 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
291 return 0;
292}
293
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200294static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
295 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296{
297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
298 struct alc_spec *spec = codec->spec;
299 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200300 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
301 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200302 spec->adc_nids[adc_idx],
303 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304}
305
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307/*
308 * channel mode setting
309 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200310static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312{
313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
314 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100315 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
316 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317}
318
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200319static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
320 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321{
322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
323 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100324 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200325 spec->num_channel_mode,
326 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327}
328
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200329static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
330 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
333 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200334 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
335 spec->num_channel_mode,
336 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200337 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200338 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
339 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340}
341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100343 * Control the mode of pin widget settings via the mixer. "pc" is used
344 * instead of "%" to avoid consequences of accidently treating the % as
345 * being part of a format specifier. Maximum allowed length of a value is
346 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100347 *
348 * Note: some retasking pin complexes seem to ignore requests for input
349 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
350 * are requested. Therefore order this list so that this behaviour will not
351 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200352 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
353 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200354 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100355static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100356 "Mic 50pc bias", "Mic 80pc bias",
357 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100358};
359static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100360 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100361};
362/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200363 * in the pin being assumed to be exclusively an input or an output pin. In
364 * addition, "input" pins may or may not process the mic bias option
365 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
366 * accept requests for bias as of chip versions up to March 2006) and/or
367 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100368 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200369#define ALC_PIN_DIR_IN 0x00
370#define ALC_PIN_DIR_OUT 0x01
371#define ALC_PIN_DIR_INOUT 0x02
372#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
373#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200375/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100376 * For each direction the minimum and maximum values are given.
377 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200378static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100379 { 0, 2 }, /* ALC_PIN_DIR_IN */
380 { 3, 4 }, /* ALC_PIN_DIR_OUT */
381 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200382 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
383 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100384};
385#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
386#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
387#define alc_pin_mode_n_items(_dir) \
388 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
389
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200390static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200392{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100393 unsigned int item_num = uinfo->value.enumerated.item;
394 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
395
396 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200397 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100398 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
399
400 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
401 item_num = alc_pin_mode_min(dir);
402 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200403 return 0;
404}
405
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200406static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200408{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100409 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100412 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200413 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200414 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
415 AC_VERB_GET_PIN_WIDGET_CONTROL,
416 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200417
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418 /* Find enumerated value for current pinctl setting */
419 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100421 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200422 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423 return 0;
424}
425
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200426static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
427 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100428{
429 signed int change;
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
431 hda_nid_t nid = kcontrol->private_value & 0xffff;
432 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
433 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200434 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
435 AC_VERB_GET_PIN_WIDGET_CONTROL,
436 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200438 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100439 val = alc_pin_mode_min(dir);
440
441 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100442 if (change) {
443 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200444 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100446
447 /* Also enable the retasking pin's input/output as required
448 * for the requested pin mode. Enum values of 2 or less are
449 * input modes.
450 *
451 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200452 * reduces noise slightly (particularly on input) so we'll
453 * do it. However, having both input and output buffers
454 * enabled simultaneously doesn't seem to be problematic if
455 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100456 */
457 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458 snd_hda_codec_write(codec, nid, 0,
459 AC_VERB_SET_AMP_GAIN_MUTE,
460 AMP_OUT_MUTE);
461 snd_hda_codec_write(codec, nid, 0,
462 AC_VERB_SET_AMP_GAIN_MUTE,
463 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100464 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200465 snd_hda_codec_write(codec, nid, 0,
466 AC_VERB_SET_AMP_GAIN_MUTE,
467 AMP_IN_MUTE(0));
468 snd_hda_codec_write(codec, nid, 0,
469 AC_VERB_SET_AMP_GAIN_MUTE,
470 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100471 }
472 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200473 return change;
474}
475
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200477 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478 .info = alc_pin_mode_info, \
479 .get = alc_pin_mode_get, \
480 .put = alc_pin_mode_put, \
481 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100482
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100483/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
484 * together using a mask with more than one bit set. This control is
485 * currently used only by the ALC260 test model. At this stage they are not
486 * needed for any "production" models.
487 */
488#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200489#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200490
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200491static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
492 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100493{
494 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
495 hda_nid_t nid = kcontrol->private_value & 0xffff;
496 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
497 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200498 unsigned int val = snd_hda_codec_read(codec, nid, 0,
499 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100500
501 *valp = (val & mask) != 0;
502 return 0;
503}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200504static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
505 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100506{
507 signed int change;
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 hda_nid_t nid = kcontrol->private_value & 0xffff;
510 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
511 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200512 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
513 AC_VERB_GET_GPIO_DATA,
514 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100515
516 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200517 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
518 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100519 gpio_data &= ~mask;
520 else
521 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200522 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100523
524 return change;
525}
526#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
527 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
528 .info = alc_gpio_data_info, \
529 .get = alc_gpio_data_get, \
530 .put = alc_gpio_data_put, \
531 .private_value = nid | (mask<<16) }
532#endif /* CONFIG_SND_DEBUG */
533
Jonathan Woithe92621f12006-02-28 11:47:47 +0100534/* A switch control to allow the enabling of the digital IO pins on the
535 * ALC260. This is incredibly simplistic; the intention of this control is
536 * to provide something in the test model allowing digital outputs to be
537 * identified if present. If models are found which can utilise these
538 * outputs a more complete mixer control can be devised for those models if
539 * necessary.
540 */
541#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200542#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200543
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100546{
547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
548 hda_nid_t nid = kcontrol->private_value & 0xffff;
549 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
550 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551 unsigned int val = snd_hda_codec_read(codec, nid, 0,
552 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100553
554 *valp = (val & mask) != 0;
555 return 0;
556}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
558 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100559{
560 signed int change;
561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 hda_nid_t nid = kcontrol->private_value & 0xffff;
563 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
564 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200565 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
566 AC_VERB_GET_DIGI_CONVERT,
567 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100568
569 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200570 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100571 if (val==0)
572 ctrl_data &= ~mask;
573 else
574 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
576 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100577
578 return change;
579}
580#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
581 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
582 .info = alc_spdif_ctrl_info, \
583 .get = alc_spdif_ctrl_get, \
584 .put = alc_spdif_ctrl_put, \
585 .private_value = nid | (mask<<16) }
586#endif /* CONFIG_SND_DEBUG */
587
Kailang Yangdf694da2005-12-05 19:42:22 +0100588/*
589 * set up from the preset table
590 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591static void setup_preset(struct alc_spec *spec,
592 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100593{
594 int i;
595
596 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
597 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
599 i++)
600 spec->init_verbs[spec->num_init_verbs++] =
601 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100602
603 spec->channel_mode = preset->channel_mode;
604 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200605 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100606
607 spec->multiout.max_channels = spec->channel_mode[0].channels;
608
609 spec->multiout.num_dacs = preset->num_dacs;
610 spec->multiout.dac_nids = preset->dac_nids;
611 spec->multiout.dig_out_nid = preset->dig_out_nid;
612 spec->multiout.hp_nid = preset->hp_nid;
613
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200614 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200615 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200616 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100617 spec->input_mux = preset->input_mux;
618
619 spec->num_adc_nids = preset->num_adc_nids;
620 spec->adc_nids = preset->adc_nids;
621 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100622
623 spec->unsol_event = preset->unsol_event;
624 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100625}
626
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200627/* Enable GPIO mask and set output */
628static struct hda_verb alc_gpio1_init_verbs[] = {
629 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
630 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
631 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
632 { }
633};
634
635static struct hda_verb alc_gpio2_init_verbs[] = {
636 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
637 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
638 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
639 { }
640};
641
Kailang Yangbdd148a2007-05-08 15:19:08 +0200642static struct hda_verb alc_gpio3_init_verbs[] = {
643 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
644 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
645 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
646 { }
647};
648
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200649/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
650 * 31 ~ 16 : Manufacture ID
651 * 15 ~ 8 : SKU ID
652 * 7 ~ 0 : Assembly ID
653 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
654 */
655static void alc_subsystem_id(struct hda_codec *codec,
656 unsigned int porta, unsigned int porte,
657 unsigned int portd)
658{
659 unsigned int ass, tmp;
660
661 ass = codec->subsystem_id;
662 if (!(ass & 1))
663 return;
664
665 /* Override */
666 tmp = (ass & 0x38) >> 3; /* external Amp control */
667 switch (tmp) {
668 case 1:
669 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
670 break;
671 case 3:
672 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
673 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200674 case 7:
675 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
676 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200677 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200678 switch (codec->vendor_id) {
679 case 0x10ec0862:
680 case 0x10ec0660:
681 case 0x10ec0662:
682 case 0x10ec0267:
683 case 0x10ec0268:
684 snd_hda_codec_write(codec, 0x14, 0,
685 AC_VERB_SET_EAPD_BTLENABLE, 2);
686 snd_hda_codec_write(codec, 0x15, 0,
687 AC_VERB_SET_EAPD_BTLENABLE, 2);
688 return;
689 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200690 case 6:
691 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
692 hda_nid_t port = 0;
693 tmp = (ass & 0x1800) >> 11;
694 switch (tmp) {
695 case 0: port = porta; break;
696 case 1: port = porte; break;
697 case 2: port = portd; break;
698 }
699 if (port)
700 snd_hda_codec_write(codec, port, 0,
701 AC_VERB_SET_EAPD_BTLENABLE,
702 2);
703 }
704 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
705 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
706 (tmp == 5 ? 0x3040 : 0x3050));
707 break;
708 }
709}
710
Takashi Iwai41e41f12005-06-08 14:48:49 +0200711/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200712 * Fix-up pin default configurations
713 */
714
715struct alc_pincfg {
716 hda_nid_t nid;
717 u32 val;
718};
719
720static void alc_fix_pincfg(struct hda_codec *codec,
721 const struct snd_pci_quirk *quirk,
722 const struct alc_pincfg **pinfix)
723{
724 const struct alc_pincfg *cfg;
725
726 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
727 if (!quirk)
728 return;
729
730 cfg = pinfix[quirk->value];
731 for (; cfg->nid; cfg++) {
732 int i;
733 u32 val = cfg->val;
734 for (i = 0; i < 4; i++) {
735 snd_hda_codec_write(codec, cfg->nid, 0,
736 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
737 val & 0xff);
738 val >>= 8;
739 }
740 }
741}
742
743/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200744 * ALC880 3-stack model
745 *
746 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200747 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
748 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 */
750
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200751static hda_nid_t alc880_dac_nids[4] = {
752 /* front, rear, clfe, rear_surr */
753 0x02, 0x05, 0x04, 0x03
754};
755
756static hda_nid_t alc880_adc_nids[3] = {
757 /* ADC0-2 */
758 0x07, 0x08, 0x09,
759};
760
761/* The datasheet says the node 0x07 is connected from inputs,
762 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100763 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200765static hda_nid_t alc880_adc_nids_alt[2] = {
766 /* ADC1-2 */
767 0x08, 0x09,
768};
769
770#define ALC880_DIGOUT_NID 0x06
771#define ALC880_DIGIN_NID 0x0a
772
773static struct hda_input_mux alc880_capture_source = {
774 .num_items = 4,
775 .items = {
776 { "Mic", 0x0 },
777 { "Front Mic", 0x3 },
778 { "Line", 0x2 },
779 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200781};
782
783/* channel source setting (2/6 channel selection for 3-stack) */
784/* 2ch mode */
785static struct hda_verb alc880_threestack_ch2_init[] = {
786 /* set line-in to input, mute it */
787 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
788 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
789 /* set mic-in to input vref 80%, mute it */
790 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
791 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 { } /* end */
793};
794
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200795/* 6ch mode */
796static struct hda_verb alc880_threestack_ch6_init[] = {
797 /* set line-in to output, unmute it */
798 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
799 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
800 /* set mic-in to output, unmute it */
801 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
802 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
803 { } /* end */
804};
805
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100806static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200807 { 2, alc880_threestack_ch2_init },
808 { 6, alc880_threestack_ch6_init },
809};
810
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100811static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200812 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100813 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200814 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100815 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200816 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
817 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100818 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
819 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
828 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
829 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200831 {
832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
833 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100834 .info = alc_ch_mode_info,
835 .get = alc_ch_mode_get,
836 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200837 },
838 { } /* end */
839};
840
841/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100842static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200843 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
844 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
845 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
846 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
847 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
848 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
849 {
850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
851 /* The multiple "Capture Source" controls confuse alsamixer
852 * So call somewhat different..
853 * FIXME: the controls appear in the "playback" view!
854 */
855 /* .name = "Capture Source", */
856 .name = "Input Source",
857 .count = 3,
858 .info = alc_mux_enum_info,
859 .get = alc_mux_enum_get,
860 .put = alc_mux_enum_put,
861 },
862 { } /* end */
863};
864
865/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100866static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200867 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
868 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
869 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
870 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 {
872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
873 /* The multiple "Capture Source" controls confuse alsamixer
874 * So call somewhat different..
875 * FIXME: the controls appear in the "playback" view!
876 */
877 /* .name = "Capture Source", */
878 .name = "Input Source",
879 .count = 2,
880 .info = alc_mux_enum_info,
881 .get = alc_mux_enum_get,
882 .put = alc_mux_enum_put,
883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 { } /* end */
885};
886
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200887
888
889/*
890 * ALC880 5-stack model
891 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200892 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
893 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200894 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
895 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
896 */
897
898/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100899static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200900 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100901 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 { } /* end */
903};
904
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200905/* channel source setting (6/8 channel selection for 5-stack) */
906/* 6ch mode */
907static struct hda_verb alc880_fivestack_ch6_init[] = {
908 /* set line-in to input, mute it */
909 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
910 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200911 { } /* end */
912};
913
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200914/* 8ch mode */
915static struct hda_verb alc880_fivestack_ch8_init[] = {
916 /* set line-in to output, unmute it */
917 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
918 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
919 { } /* end */
920};
921
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100922static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200923 { 6, alc880_fivestack_ch6_init },
924 { 8, alc880_fivestack_ch8_init },
925};
926
927
928/*
929 * ALC880 6-stack model
930 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200931 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
932 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200933 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
934 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
935 */
936
937static hda_nid_t alc880_6st_dac_nids[4] = {
938 /* front, rear, clfe, rear_surr */
939 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200940};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200941
942static struct hda_input_mux alc880_6stack_capture_source = {
943 .num_items = 4,
944 .items = {
945 { "Mic", 0x0 },
946 { "Front Mic", 0x1 },
947 { "Line", 0x2 },
948 { "CD", 0x4 },
949 },
950};
951
952/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100953static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200954 { 8, NULL },
955};
956
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100957static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200958 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100959 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200960 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100961 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200966 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100967 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
970 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
971 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
974 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
975 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
976 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
977 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200978 {
979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
980 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100981 .info = alc_ch_mode_info,
982 .get = alc_ch_mode_get,
983 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200984 },
985 { } /* end */
986};
987
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200988
989/*
990 * ALC880 W810 model
991 *
992 * W810 has rear IO for:
993 * Front (DAC 02)
994 * Surround (DAC 03)
995 * Center/LFE (DAC 04)
996 * Digital out (06)
997 *
998 * The system also has a pair of internal speakers, and a headphone jack.
999 * These are both connected to Line2 on the codec, hence to DAC 02.
1000 *
1001 * There is a variable resistor to control the speaker or headphone
1002 * volume. This is a hardware-only device without a software API.
1003 *
1004 * Plugging headphones in will disable the internal speakers. This is
1005 * implemented in hardware, not via the driver using jack sense. In
1006 * a similar fashion, plugging into the rear socket marked "front" will
1007 * disable both the speakers and headphones.
1008 *
1009 * For input, there's a microphone jack, and an "audio in" jack.
1010 * These may not do anything useful with this driver yet, because I
1011 * haven't setup any initialization verbs for these yet...
1012 */
1013
1014static hda_nid_t alc880_w810_dac_nids[3] = {
1015 /* front, rear/surround, clfe */
1016 0x02, 0x03, 0x04
1017};
1018
1019/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001020static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001021 { 6, NULL }
1022};
1023
1024/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001025static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001026 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001027 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001028 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001029 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001030 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1031 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001032 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1033 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1035 { } /* end */
1036};
1037
1038
1039/*
1040 * Z710V model
1041 *
1042 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001043 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1044 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001045 */
1046
1047static hda_nid_t alc880_z71v_dac_nids[1] = {
1048 0x02
1049};
1050#define ALC880_Z71V_HP_DAC 0x03
1051
1052/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001053static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001054 { 2, NULL }
1055};
1056
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001057static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001058 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001059 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001060 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001061 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001062 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1063 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1065 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1066 { } /* end */
1067};
1068
1069
1070/* FIXME! */
1071/*
1072 * ALC880 F1734 model
1073 *
1074 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1075 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1076 */
1077
1078static hda_nid_t alc880_f1734_dac_nids[1] = {
1079 0x03
1080};
1081#define ALC880_F1734_HP_DAC 0x02
1082
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001083static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001084 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001085 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001086 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001087 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001088 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1089 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001092 { } /* end */
1093};
1094
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001095
1096/* FIXME! */
1097/*
1098 * ALC880 ASUS model
1099 *
1100 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1101 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1102 * Mic = 0x18, Line = 0x1a
1103 */
1104
1105#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1106#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1107
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001108static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001109 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001110 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001111 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001112 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001113 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1114 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001115 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1116 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001117 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1118 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1119 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1120 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001123 {
1124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1125 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001126 .info = alc_ch_mode_info,
1127 .get = alc_ch_mode_get,
1128 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001129 },
1130 { } /* end */
1131};
1132
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001133/* FIXME! */
1134/*
1135 * ALC880 ASUS W1V model
1136 *
1137 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1138 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1139 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1140 */
1141
1142/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001143static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001144 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1145 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001146 { } /* end */
1147};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001149/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001150static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001151 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1152 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1153 { } /* end */
1154};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155
Kailang Yangdf694da2005-12-05 19:42:22 +01001156/* TCL S700 */
1157static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1158 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1159 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1160 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1161 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1162 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1165 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1166 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1167 {
1168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1169 /* The multiple "Capture Source" controls confuse alsamixer
1170 * So call somewhat different..
1171 * FIXME: the controls appear in the "playback" view!
1172 */
1173 /* .name = "Capture Source", */
1174 .name = "Input Source",
1175 .count = 1,
1176 .info = alc_mux_enum_info,
1177 .get = alc_mux_enum_get,
1178 .put = alc_mux_enum_put,
1179 },
1180 { } /* end */
1181};
1182
Kailang Yangccc656c2006-10-17 12:32:26 +02001183/* Uniwill */
1184static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1185 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1186 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1187 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1188 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1189 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1191 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1192 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1193 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1194 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1201 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1202 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1203 {
1204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1205 .name = "Channel Mode",
1206 .info = alc_ch_mode_info,
1207 .get = alc_ch_mode_get,
1208 .put = alc_ch_mode_put,
1209 },
1210 { } /* end */
1211};
1212
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001213static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1214 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1215 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1216 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1217 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1218 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1219 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1220 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1221 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1222 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1223 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1224 { } /* end */
1225};
1226
Kailang Yangccc656c2006-10-17 12:32:26 +02001227static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1228 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1229 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1230 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1231 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1234 { } /* end */
1235};
1236
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001238 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239 */
1240static int alc_build_controls(struct hda_codec *codec)
1241{
1242 struct alc_spec *spec = codec->spec;
1243 int err;
1244 int i;
1245
1246 for (i = 0; i < spec->num_mixers; i++) {
1247 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1248 if (err < 0)
1249 return err;
1250 }
1251
1252 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001253 err = snd_hda_create_spdif_out_ctls(codec,
1254 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 if (err < 0)
1256 return err;
1257 }
1258 if (spec->dig_in_nid) {
1259 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1260 if (err < 0)
1261 return err;
1262 }
1263 return 0;
1264}
1265
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001266
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267/*
1268 * initialize the codec volumes, etc
1269 */
1270
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001271/*
1272 * generic initialization of ADC, input mixers and output mixers
1273 */
1274static struct hda_verb alc880_volume_init_verbs[] = {
1275 /*
1276 * Unmute ADC0-2 and set the default input to mic-in
1277 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001278 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001280 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001282 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001283 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001285 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1286 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001287 * Note: PASD motherboards uses the Line In 2 as the input for front
1288 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001290 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001297 /*
1298 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001300 /* set vol=0 to output mixers */
1301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1304 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1305 /* set up input amps for analog loopback */
1306 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001313 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1314 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315
1316 { }
1317};
1318
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001319/*
1320 * 3-stack pin configuration:
1321 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1322 */
1323static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1324 /*
1325 * preset connection lists of input pins
1326 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1327 */
1328 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1329 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1330 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1331
1332 /*
1333 * Set pin mode and muting
1334 */
1335 /* set front pin widgets 0x14 for output */
1336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1337 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1338 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1339 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1340 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1341 /* Mic2 (as headphone out) for HP output */
1342 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1343 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1344 /* Line In pin widget for input */
1345 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1346 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1347 /* Line2 (as front mic) pin widget for input and vref at 80% */
1348 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1349 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1350 /* CD pin widget for input */
1351 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1352
1353 { }
1354};
1355
1356/*
1357 * 5-stack pin configuration:
1358 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1359 * line-in/side = 0x1a, f-mic = 0x1b
1360 */
1361static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1362 /*
1363 * preset connection lists of input pins
1364 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1365 */
1366 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1367 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1368
1369 /*
1370 * Set pin mode and muting
1371 */
1372 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1375 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1376 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001377 /* unmute pins for output (no gain on this amp) */
1378 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1379 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1380 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1381 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1382
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001384 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001385 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1386 /* Mic2 (as headphone out) for HP output */
1387 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001388 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001389 /* Line In pin widget for input */
1390 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1391 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1392 /* Line2 (as front mic) pin widget for input and vref at 80% */
1393 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1394 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1395 /* CD pin widget for input */
1396 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397
1398 { }
1399};
1400
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001401/*
1402 * W810 pin configuration:
1403 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1404 */
1405static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 /* hphone/speaker input selector: front DAC */
1407 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1408
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001409 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1410 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1411 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1413 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1414 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1415
1416 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001417 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419 { }
1420};
1421
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001422/*
1423 * Z71V pin configuration:
1424 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1425 */
1426static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001428 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001429 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001430 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001431
Takashi Iwai16ded522005-06-10 19:58:24 +02001432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001433 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001434 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001435 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001436
1437 { }
1438};
1439
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001440/*
1441 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001442 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1443 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001444 */
1445static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1446 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1447
Takashi Iwai16ded522005-06-10 19:58:24 +02001448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001450 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001452 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001453 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001454 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001455 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1456
Takashi Iwai16ded522005-06-10 19:58:24 +02001457 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001458 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001459 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001463 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001464 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001465 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1466
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001467 { }
1468};
Takashi Iwai16ded522005-06-10 19:58:24 +02001469
Kailang Yangccc656c2006-10-17 12:32:26 +02001470/*
1471 * Uniwill pin configuration:
1472 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1473 * line = 0x1a
1474 */
1475static struct hda_verb alc880_uniwill_init_verbs[] = {
1476 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1477
1478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1483 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1484 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1485 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1486 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1488 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1490 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1492
1493 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1494 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1495 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1496 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1497 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1498 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1499 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1500 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1501 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1502
1503 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1504 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1505
1506 { }
1507};
1508
1509/*
1510* Uniwill P53
1511* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1512 */
1513static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1514 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1515
1516 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1517 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1520 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1528
1529 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1530 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1531 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1532 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1533 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1534 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1535
1536 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1537 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1538
1539 { }
1540};
1541
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001542static struct hda_verb alc880_beep_init_verbs[] = {
1543 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1544 { }
1545};
1546
Kailang Yangccc656c2006-10-17 12:32:26 +02001547/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001548static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001549{
1550 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001551 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001552
1553 present = snd_hda_codec_read(codec, 0x14, 0,
1554 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001555 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001556 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001557 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001558 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001559 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001560 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001561 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001562 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001563 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001564}
1565
1566/* auto-toggle front mic */
1567static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1568{
1569 unsigned int present;
1570 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001571
1572 present = snd_hda_codec_read(codec, 0x18, 0,
1573 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001574 bits = present ? 0x80 : 0;
1575 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1576 0x80, bits);
1577 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1578 0x80, bits);
1579}
1580
1581static void alc880_uniwill_automute(struct hda_codec *codec)
1582{
1583 alc880_uniwill_hp_automute(codec);
1584 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001585}
1586
1587static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1588 unsigned int res)
1589{
1590 /* Looks like the unsol event is incompatible with the standard
1591 * definition. 4bit tag is placed at 28 bit!
1592 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001593 switch (res >> 28) {
1594 case ALC880_HP_EVENT:
1595 alc880_uniwill_hp_automute(codec);
1596 break;
1597 case ALC880_MIC_EVENT:
1598 alc880_uniwill_mic_automute(codec);
1599 break;
1600 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001601}
1602
1603static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1604{
1605 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001606 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001607
1608 present = snd_hda_codec_read(codec, 0x14, 0,
1609 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001610 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001611 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001612 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001613 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001614 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001615}
1616
1617static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1618{
1619 unsigned int present;
1620
1621 present = snd_hda_codec_read(codec, 0x21, 0,
1622 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1623
1624 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1625 0x7f, present);
1626 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1627 0x7f, present);
1628
1629 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1630 0x7f, present);
1631 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1632 0x7f, present);
1633
1634}
1635static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1636 unsigned int res)
1637{
1638 /* Looks like the unsol event is incompatible with the standard
1639 * definition. 4bit tag is placed at 28 bit!
1640 */
1641 if ((res >> 28) == ALC880_HP_EVENT)
1642 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001643 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001644 alc880_uniwill_p53_dcvol_automute(codec);
1645}
1646
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001647/* FIXME! */
1648/*
1649 * F1734 pin configuration:
1650 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1651 */
1652static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1653 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1654 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1655 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1656 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1657
1658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662
1663 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1664 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1665 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1666 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1667 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1668 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1669 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1670 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1671 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001672
1673 { }
1674};
1675
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001676/* FIXME! */
1677/*
1678 * ASUS pin configuration:
1679 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1680 */
1681static struct hda_verb alc880_pin_asus_init_verbs[] = {
1682 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1683 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1684 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1685 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1686
1687 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1688 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1691 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1693 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695
1696 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1697 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1698 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1700 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1702 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1704 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1705
1706 { }
1707};
1708
1709/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001710#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1711#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001712
Kailang Yangdf694da2005-12-05 19:42:22 +01001713/* Clevo m520g init */
1714static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1715 /* headphone output */
1716 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1717 /* line-out */
1718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1720 /* Line-in */
1721 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1723 /* CD */
1724 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1725 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1726 /* Mic1 (rear panel) */
1727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1729 /* Mic2 (front panel) */
1730 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1731 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1732 /* headphone */
1733 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1735 /* change to EAPD mode */
1736 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1737 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1738
1739 { }
1740};
1741
1742static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001743 /* change to EAPD mode */
1744 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1745 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1746
Kailang Yangdf694da2005-12-05 19:42:22 +01001747 /* Headphone output */
1748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1749 /* Front output*/
1750 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1751 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1752
1753 /* Line In pin widget for input */
1754 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1755 /* CD pin widget for input */
1756 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1757 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1759
1760 /* change to EAPD mode */
1761 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1762 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1763
1764 { }
1765};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001766
1767/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001768 * LG m1 express dual
1769 *
1770 * Pin assignment:
1771 * Rear Line-In/Out (blue): 0x14
1772 * Build-in Mic-In: 0x15
1773 * Speaker-out: 0x17
1774 * HP-Out (green): 0x1b
1775 * Mic-In/Out (red): 0x19
1776 * SPDIF-Out: 0x1e
1777 */
1778
1779/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1780static hda_nid_t alc880_lg_dac_nids[3] = {
1781 0x05, 0x02, 0x03
1782};
1783
1784/* seems analog CD is not working */
1785static struct hda_input_mux alc880_lg_capture_source = {
1786 .num_items = 3,
1787 .items = {
1788 { "Mic", 0x1 },
1789 { "Line", 0x5 },
1790 { "Internal Mic", 0x6 },
1791 },
1792};
1793
1794/* 2,4,6 channel modes */
1795static struct hda_verb alc880_lg_ch2_init[] = {
1796 /* set line-in and mic-in to input */
1797 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1798 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1799 { }
1800};
1801
1802static struct hda_verb alc880_lg_ch4_init[] = {
1803 /* set line-in to out and mic-in to input */
1804 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1805 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1806 { }
1807};
1808
1809static struct hda_verb alc880_lg_ch6_init[] = {
1810 /* set line-in and mic-in to output */
1811 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1812 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1813 { }
1814};
1815
1816static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1817 { 2, alc880_lg_ch2_init },
1818 { 4, alc880_lg_ch4_init },
1819 { 6, alc880_lg_ch6_init },
1820};
1821
1822static struct snd_kcontrol_new alc880_lg_mixer[] = {
1823 /* FIXME: it's not really "master" but front channels */
1824 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1825 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1826 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1827 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1828 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1829 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1830 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1831 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1836 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1837 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1838 {
1839 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1840 .name = "Channel Mode",
1841 .info = alc_ch_mode_info,
1842 .get = alc_ch_mode_get,
1843 .put = alc_ch_mode_put,
1844 },
1845 { } /* end */
1846};
1847
1848static struct hda_verb alc880_lg_init_verbs[] = {
1849 /* set capture source to mic-in */
1850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1851 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1852 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1853 /* mute all amp mixer inputs */
1854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1857 /* line-in to input */
1858 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1859 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 /* built-in mic */
1861 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1863 /* speaker-out */
1864 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1865 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1866 /* mic-in to input */
1867 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1868 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1869 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1870 /* HP-out */
1871 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1872 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1874 /* jack sense */
1875 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1876 { }
1877};
1878
1879/* toggle speaker-output according to the hp-jack state */
1880static void alc880_lg_automute(struct hda_codec *codec)
1881{
1882 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001883 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001884
1885 present = snd_hda_codec_read(codec, 0x1b, 0,
1886 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001887 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001888 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001889 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001890 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001891 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001892}
1893
1894static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1895{
1896 /* Looks like the unsol event is incompatible with the standard
1897 * definition. 4bit tag is placed at 28 bit!
1898 */
1899 if ((res >> 28) == 0x01)
1900 alc880_lg_automute(codec);
1901}
1902
1903/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001904 * LG LW20
1905 *
1906 * Pin assignment:
1907 * Speaker-out: 0x14
1908 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001909 * Built-in Mic-In: 0x19
1910 * Line-In: 0x1b
1911 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01001912 * SPDIF-Out: 0x1e
1913 */
1914
Takashi Iwaid6815182006-03-23 16:06:23 +01001915static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001916 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01001917 .items = {
1918 { "Mic", 0x0 },
1919 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001920 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001921 },
1922};
1923
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001924#define alc880_lg_lw_modes alc880_threestack_modes
1925
Takashi Iwaid6815182006-03-23 16:06:23 +01001926static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001927 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1928 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1929 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1930 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1931 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1932 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1933 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1934 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1935 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1936 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1939 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1940 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001941 {
1942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1943 .name = "Channel Mode",
1944 .info = alc_ch_mode_info,
1945 .get = alc_ch_mode_get,
1946 .put = alc_ch_mode_put,
1947 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001948 { } /* end */
1949};
1950
1951static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001952 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1953 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1954 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1955
Takashi Iwaid6815182006-03-23 16:06:23 +01001956 /* set capture source to mic-in */
1957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1958 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1961 /* speaker-out */
1962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1964 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1966 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1967 /* mic-in to input */
1968 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1969 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1970 /* built-in mic */
1971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1972 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1973 /* jack sense */
1974 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1975 { }
1976};
1977
1978/* toggle speaker-output according to the hp-jack state */
1979static void alc880_lg_lw_automute(struct hda_codec *codec)
1980{
1981 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001982 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001983
1984 present = snd_hda_codec_read(codec, 0x1b, 0,
1985 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001986 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001987 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001988 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001989 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001990 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001991}
1992
1993static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1994{
1995 /* Looks like the unsol event is incompatible with the standard
1996 * definition. 4bit tag is placed at 28 bit!
1997 */
1998 if ((res >> 28) == 0x01)
1999 alc880_lg_lw_automute(codec);
2000}
2001
2002/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002003 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002004 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002005
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006static int alc_init(struct hda_codec *codec)
2007{
2008 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002009 unsigned int i;
2010
2011 for (i = 0; i < spec->num_init_verbs; i++)
2012 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002013
2014 if (spec->init_hook)
2015 spec->init_hook(codec);
2016
Linus Torvalds1da177e2005-04-16 15:20:36 -07002017 return 0;
2018}
2019
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002020static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2021{
2022 struct alc_spec *spec = codec->spec;
2023
2024 if (spec->unsol_event)
2025 spec->unsol_event(codec, res);
2026}
2027
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028#ifdef CONFIG_PM
2029/*
2030 * resume
2031 */
2032static int alc_resume(struct hda_codec *codec)
2033{
2034 struct alc_spec *spec = codec->spec;
2035 int i;
2036
2037 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002038 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040 if (spec->multiout.dig_out_nid)
2041 snd_hda_resume_spdif_out(codec);
2042 if (spec->dig_in_nid)
2043 snd_hda_resume_spdif_in(codec);
2044
2045 return 0;
2046}
2047#endif
2048
2049/*
2050 * Analog playback callbacks
2051 */
2052static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2053 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002054 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055{
2056 struct alc_spec *spec = codec->spec;
2057 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2058}
2059
2060static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2061 struct hda_codec *codec,
2062 unsigned int stream_tag,
2063 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002064 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065{
2066 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002067 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2068 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002069}
2070
2071static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2072 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002073 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074{
2075 struct alc_spec *spec = codec->spec;
2076 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2077}
2078
2079/*
2080 * Digital out
2081 */
2082static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2083 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002084 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085{
2086 struct alc_spec *spec = codec->spec;
2087 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2088}
2089
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002090static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2091 struct hda_codec *codec,
2092 unsigned int stream_tag,
2093 unsigned int format,
2094 struct snd_pcm_substream *substream)
2095{
2096 struct alc_spec *spec = codec->spec;
2097 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2098 stream_tag, format, substream);
2099}
2100
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2102 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002103 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104{
2105 struct alc_spec *spec = codec->spec;
2106 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2107}
2108
2109/*
2110 * Analog capture
2111 */
2112static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2113 struct hda_codec *codec,
2114 unsigned int stream_tag,
2115 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002116 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002117{
2118 struct alc_spec *spec = codec->spec;
2119
2120 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2121 stream_tag, 0, format);
2122 return 0;
2123}
2124
2125static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2126 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002127 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128{
2129 struct alc_spec *spec = codec->spec;
2130
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002131 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2132 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002133 return 0;
2134}
2135
2136
2137/*
2138 */
2139static struct hda_pcm_stream alc880_pcm_analog_playback = {
2140 .substreams = 1,
2141 .channels_min = 2,
2142 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002143 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144 .ops = {
2145 .open = alc880_playback_pcm_open,
2146 .prepare = alc880_playback_pcm_prepare,
2147 .cleanup = alc880_playback_pcm_cleanup
2148 },
2149};
2150
2151static struct hda_pcm_stream alc880_pcm_analog_capture = {
2152 .substreams = 2,
2153 .channels_min = 2,
2154 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002155 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156 .ops = {
2157 .prepare = alc880_capture_pcm_prepare,
2158 .cleanup = alc880_capture_pcm_cleanup
2159 },
2160};
2161
2162static struct hda_pcm_stream alc880_pcm_digital_playback = {
2163 .substreams = 1,
2164 .channels_min = 2,
2165 .channels_max = 2,
2166 /* NID is set in alc_build_pcms */
2167 .ops = {
2168 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002169 .close = alc880_dig_playback_pcm_close,
2170 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 },
2172};
2173
2174static struct hda_pcm_stream alc880_pcm_digital_capture = {
2175 .substreams = 1,
2176 .channels_min = 2,
2177 .channels_max = 2,
2178 /* NID is set in alc_build_pcms */
2179};
2180
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002181/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2182static struct hda_pcm_stream alc_pcm_null_playback = {
2183 .substreams = 0,
2184 .channels_min = 0,
2185 .channels_max = 0,
2186};
2187
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188static int alc_build_pcms(struct hda_codec *codec)
2189{
2190 struct alc_spec *spec = codec->spec;
2191 struct hda_pcm *info = spec->pcm_rec;
2192 int i;
2193
2194 codec->num_pcms = 1;
2195 codec->pcm_info = info;
2196
2197 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002198 if (spec->stream_analog_playback) {
2199 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2200 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2201 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2202 }
2203 if (spec->stream_analog_capture) {
2204 snd_assert(spec->adc_nids, return -EINVAL);
2205 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2206 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2207 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208
Takashi Iwai4a471b72005-12-07 13:56:29 +01002209 if (spec->channel_mode) {
2210 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2211 for (i = 0; i < spec->num_channel_mode; i++) {
2212 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2213 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2214 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215 }
2216 }
2217
Takashi Iwaie08a0072006-09-07 17:52:14 +02002218 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002220 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002221 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002223 if (spec->multiout.dig_out_nid &&
2224 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2226 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2227 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002228 if (spec->dig_in_nid &&
2229 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2231 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2232 }
2233 }
2234
Takashi Iwaie08a0072006-09-07 17:52:14 +02002235 /* If the use of more than one ADC is requested for the current
2236 * model, configure a second analog capture-only PCM.
2237 */
2238 /* Additional Analaog capture for index #2 */
2239 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2240 spec->adc_nids) {
2241 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002242 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002243 info->name = spec->stream_name_analog;
2244 /* No playback stream for second PCM */
2245 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2246 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2247 if (spec->stream_analog_capture) {
2248 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2249 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2250 }
2251 }
2252
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 return 0;
2254}
2255
2256static void alc_free(struct hda_codec *codec)
2257{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002258 struct alc_spec *spec = codec->spec;
2259 unsigned int i;
2260
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002261 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002262 return;
2263
2264 if (spec->kctl_alloc) {
2265 for (i = 0; i < spec->num_kctl_used; i++)
2266 kfree(spec->kctl_alloc[i].name);
2267 kfree(spec->kctl_alloc);
2268 }
2269 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270}
2271
2272/*
2273 */
2274static struct hda_codec_ops alc_patch_ops = {
2275 .build_controls = alc_build_controls,
2276 .build_pcms = alc_build_pcms,
2277 .init = alc_init,
2278 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002279 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002280#ifdef CONFIG_PM
2281 .resume = alc_resume,
2282#endif
2283};
2284
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002285
2286/*
2287 * Test configuration for debugging
2288 *
2289 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2290 * enum controls.
2291 */
2292#ifdef CONFIG_SND_DEBUG
2293static hda_nid_t alc880_test_dac_nids[4] = {
2294 0x02, 0x03, 0x04, 0x05
2295};
2296
2297static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002298 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002299 .items = {
2300 { "In-1", 0x0 },
2301 { "In-2", 0x1 },
2302 { "In-3", 0x2 },
2303 { "In-4", 0x3 },
2304 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002305 { "Front", 0x5 },
2306 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002307 },
2308};
2309
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002310static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002311 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002312 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002313 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002314 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002315};
2316
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002317static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2318 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002319{
2320 static char *texts[] = {
2321 "N/A", "Line Out", "HP Out",
2322 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2323 };
2324 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2325 uinfo->count = 1;
2326 uinfo->value.enumerated.items = 8;
2327 if (uinfo->value.enumerated.item >= 8)
2328 uinfo->value.enumerated.item = 7;
2329 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2330 return 0;
2331}
2332
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002333static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2334 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002335{
2336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2337 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2338 unsigned int pin_ctl, item = 0;
2339
2340 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2341 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2342 if (pin_ctl & AC_PINCTL_OUT_EN) {
2343 if (pin_ctl & AC_PINCTL_HP_EN)
2344 item = 2;
2345 else
2346 item = 1;
2347 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2348 switch (pin_ctl & AC_PINCTL_VREFEN) {
2349 case AC_PINCTL_VREF_HIZ: item = 3; break;
2350 case AC_PINCTL_VREF_50: item = 4; break;
2351 case AC_PINCTL_VREF_GRD: item = 5; break;
2352 case AC_PINCTL_VREF_80: item = 6; break;
2353 case AC_PINCTL_VREF_100: item = 7; break;
2354 }
2355 }
2356 ucontrol->value.enumerated.item[0] = item;
2357 return 0;
2358}
2359
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002360static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2361 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002362{
2363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2364 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2365 static unsigned int ctls[] = {
2366 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2367 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2368 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2369 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2372 };
2373 unsigned int old_ctl, new_ctl;
2374
2375 old_ctl = snd_hda_codec_read(codec, nid, 0,
2376 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2377 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2378 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002379 snd_hda_codec_write(codec, nid, 0,
2380 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002381 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002382 (ucontrol->value.enumerated.item[0] >= 3 ?
2383 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002384 return 1;
2385 }
2386 return 0;
2387}
2388
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002389static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2390 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002391{
2392 static char *texts[] = {
2393 "Front", "Surround", "CLFE", "Side"
2394 };
2395 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2396 uinfo->count = 1;
2397 uinfo->value.enumerated.items = 4;
2398 if (uinfo->value.enumerated.item >= 4)
2399 uinfo->value.enumerated.item = 3;
2400 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2401 return 0;
2402}
2403
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002404static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2405 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002406{
2407 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2408 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2409 unsigned int sel;
2410
2411 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2412 ucontrol->value.enumerated.item[0] = sel & 3;
2413 return 0;
2414}
2415
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002416static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2417 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002418{
2419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2420 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2421 unsigned int sel;
2422
2423 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2424 if (ucontrol->value.enumerated.item[0] != sel) {
2425 sel = ucontrol->value.enumerated.item[0] & 3;
2426 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2427 return 1;
2428 }
2429 return 0;
2430}
2431
2432#define PIN_CTL_TEST(xname,nid) { \
2433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2434 .name = xname, \
2435 .info = alc_test_pin_ctl_info, \
2436 .get = alc_test_pin_ctl_get, \
2437 .put = alc_test_pin_ctl_put, \
2438 .private_value = nid \
2439 }
2440
2441#define PIN_SRC_TEST(xname,nid) { \
2442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2443 .name = xname, \
2444 .info = alc_test_pin_src_info, \
2445 .get = alc_test_pin_src_get, \
2446 .put = alc_test_pin_src_put, \
2447 .private_value = nid \
2448 }
2449
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002450static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002451 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2452 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2453 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2454 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002455 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2456 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2457 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2458 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002459 PIN_CTL_TEST("Front Pin Mode", 0x14),
2460 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2461 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2462 PIN_CTL_TEST("Side Pin Mode", 0x17),
2463 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2464 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2465 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2466 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2467 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2468 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2469 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2470 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2471 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2472 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2473 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2474 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2475 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2476 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2477 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2478 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002481 {
2482 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2483 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002484 .info = alc_ch_mode_info,
2485 .get = alc_ch_mode_get,
2486 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002487 },
2488 { } /* end */
2489};
2490
2491static struct hda_verb alc880_test_init_verbs[] = {
2492 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2499 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2500 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002501 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002506 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2509 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2510 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002511 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2514 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2515 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002516 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002517 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002519 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2521 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002522 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002523 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2524 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2525 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2526 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002527 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002529 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002531 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002532 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002533 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002534 /* Analog input/passthru */
2535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002540 { }
2541};
2542#endif
2543
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544/*
2545 */
2546
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002547static const char *alc880_models[ALC880_MODEL_LAST] = {
2548 [ALC880_3ST] = "3stack",
2549 [ALC880_TCL_S700] = "tcl",
2550 [ALC880_3ST_DIG] = "3stack-digout",
2551 [ALC880_CLEVO] = "clevo",
2552 [ALC880_5ST] = "5stack",
2553 [ALC880_5ST_DIG] = "5stack-digout",
2554 [ALC880_W810] = "w810",
2555 [ALC880_Z71V] = "z71v",
2556 [ALC880_6ST] = "6stack",
2557 [ALC880_6ST_DIG] = "6stack-digout",
2558 [ALC880_ASUS] = "asus",
2559 [ALC880_ASUS_W1V] = "asus-w1v",
2560 [ALC880_ASUS_DIG] = "asus-dig",
2561 [ALC880_ASUS_DIG2] = "asus-dig2",
2562 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002563 [ALC880_UNIWILL_P53] = "uniwill-p53",
2564 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002565 [ALC880_F1734] = "F1734",
2566 [ALC880_LG] = "lg",
2567 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002568#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002569 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002570#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002571 [ALC880_AUTO] = "auto",
2572};
2573
2574static struct snd_pci_quirk alc880_cfg_tbl[] = {
2575 /* Broken BIOS configuration */
2576 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2577 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2578
2579 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2580 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002581 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002582 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2583 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2584 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2585 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2586 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2587 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2588
2589 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2590 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2591
2592 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2593 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2594 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2595 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2596 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2597 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2598 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2599 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2600 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2601 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002602 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002603 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2604 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2605 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2606 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2607
2608 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2609 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2610 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2611 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2612 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2613 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2614 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2615 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2616 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2617 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2618 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2619 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2620 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2621 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2622 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2623 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2624 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2625 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2626
2627 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2628 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2629 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2630 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2631
2632 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2633 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2634 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002635 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002636
2637 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2638 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2639 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2640 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2641
2642 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2643 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2644 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2645 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2646 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2647 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2648 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2649 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002653
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 {}
2655};
2656
Takashi Iwai16ded522005-06-10 19:58:24 +02002657/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002658 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002659 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002660static struct alc_config_preset alc880_presets[] = {
2661 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002663 .init_verbs = { alc880_volume_init_verbs,
2664 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002665 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002666 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2668 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002669 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 .input_mux = &alc880_capture_source,
2671 },
2672 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002674 .init_verbs = { alc880_volume_init_verbs,
2675 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002676 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 .dac_nids = alc880_dac_nids,
2678 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002679 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2680 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002681 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002682 .input_mux = &alc880_capture_source,
2683 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002684 [ALC880_TCL_S700] = {
2685 .mixers = { alc880_tcl_s700_mixer },
2686 .init_verbs = { alc880_volume_init_verbs,
2687 alc880_pin_tcl_S700_init_verbs,
2688 alc880_gpio2_init_verbs },
2689 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2690 .dac_nids = alc880_dac_nids,
2691 .hp_nid = 0x03,
2692 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2693 .channel_mode = alc880_2_jack_modes,
2694 .input_mux = &alc880_capture_source,
2695 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002696 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002697 .mixers = { alc880_three_stack_mixer,
2698 alc880_five_stack_mixer},
2699 .init_verbs = { alc880_volume_init_verbs,
2700 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002701 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2702 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002703 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2704 .channel_mode = alc880_fivestack_modes,
2705 .input_mux = &alc880_capture_source,
2706 },
2707 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002708 .mixers = { alc880_three_stack_mixer,
2709 alc880_five_stack_mixer },
2710 .init_verbs = { alc880_volume_init_verbs,
2711 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002712 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2713 .dac_nids = alc880_dac_nids,
2714 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002715 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2716 .channel_mode = alc880_fivestack_modes,
2717 .input_mux = &alc880_capture_source,
2718 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002719 [ALC880_6ST] = {
2720 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002721 .init_verbs = { alc880_volume_init_verbs,
2722 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002723 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2724 .dac_nids = alc880_6st_dac_nids,
2725 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2726 .channel_mode = alc880_sixstack_modes,
2727 .input_mux = &alc880_6stack_capture_source,
2728 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002731 .init_verbs = { alc880_volume_init_verbs,
2732 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2734 .dac_nids = alc880_6st_dac_nids,
2735 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002736 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2737 .channel_mode = alc880_sixstack_modes,
2738 .input_mux = &alc880_6stack_capture_source,
2739 },
2740 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002741 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002742 .init_verbs = { alc880_volume_init_verbs,
2743 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002744 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002745 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2746 .dac_nids = alc880_w810_dac_nids,
2747 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002748 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2749 .channel_mode = alc880_w810_modes,
2750 .input_mux = &alc880_capture_source,
2751 },
2752 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002753 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002754 .init_verbs = { alc880_volume_init_verbs,
2755 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002756 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2757 .dac_nids = alc880_z71v_dac_nids,
2758 .dig_out_nid = ALC880_DIGOUT_NID,
2759 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002760 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2761 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002762 .input_mux = &alc880_capture_source,
2763 },
2764 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002765 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002766 .init_verbs = { alc880_volume_init_verbs,
2767 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002768 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2769 .dac_nids = alc880_f1734_dac_nids,
2770 .hp_nid = 0x02,
2771 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2772 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002773 .input_mux = &alc880_capture_source,
2774 },
2775 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002777 .init_verbs = { alc880_volume_init_verbs,
2778 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002779 alc880_gpio1_init_verbs },
2780 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2781 .dac_nids = alc880_asus_dac_nids,
2782 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2783 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002784 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002785 .input_mux = &alc880_capture_source,
2786 },
2787 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002788 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002789 .init_verbs = { alc880_volume_init_verbs,
2790 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002791 alc880_gpio1_init_verbs },
2792 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2793 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2796 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002797 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002798 .input_mux = &alc880_capture_source,
2799 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002800 [ALC880_ASUS_DIG2] = {
2801 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002802 .init_verbs = { alc880_volume_init_verbs,
2803 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002804 alc880_gpio2_init_verbs }, /* use GPIO2 */
2805 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2806 .dac_nids = alc880_asus_dac_nids,
2807 .dig_out_nid = ALC880_DIGOUT_NID,
2808 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2809 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002810 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002811 .input_mux = &alc880_capture_source,
2812 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002813 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002814 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002815 .init_verbs = { alc880_volume_init_verbs,
2816 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002817 alc880_gpio1_init_verbs },
2818 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2819 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002820 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002821 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2822 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002823 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002824 .input_mux = &alc880_capture_source,
2825 },
2826 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002827 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002828 .init_verbs = { alc880_volume_init_verbs,
2829 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002830 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2831 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002832 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002833 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2834 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002835 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002836 .input_mux = &alc880_capture_source,
2837 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002838 [ALC880_UNIWILL] = {
2839 .mixers = { alc880_uniwill_mixer },
2840 .init_verbs = { alc880_volume_init_verbs,
2841 alc880_uniwill_init_verbs },
2842 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2843 .dac_nids = alc880_asus_dac_nids,
2844 .dig_out_nid = ALC880_DIGOUT_NID,
2845 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2846 .channel_mode = alc880_threestack_modes,
2847 .need_dac_fix = 1,
2848 .input_mux = &alc880_capture_source,
2849 .unsol_event = alc880_uniwill_unsol_event,
2850 .init_hook = alc880_uniwill_automute,
2851 },
2852 [ALC880_UNIWILL_P53] = {
2853 .mixers = { alc880_uniwill_p53_mixer },
2854 .init_verbs = { alc880_volume_init_verbs,
2855 alc880_uniwill_p53_init_verbs },
2856 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2857 .dac_nids = alc880_asus_dac_nids,
2858 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002859 .channel_mode = alc880_threestack_modes,
2860 .input_mux = &alc880_capture_source,
2861 .unsol_event = alc880_uniwill_p53_unsol_event,
2862 .init_hook = alc880_uniwill_p53_hp_automute,
2863 },
2864 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002865 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002866 alc880_pcbeep_mixer, },
2867 .init_verbs = { alc880_volume_init_verbs,
2868 alc880_uniwill_p53_init_verbs,
2869 alc880_beep_init_verbs },
2870 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2871 .dac_nids = alc880_dac_nids,
2872 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2873 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002874 .input_mux = &alc880_capture_source,
2875 .unsol_event = alc880_uniwill_p53_unsol_event,
2876 .init_hook = alc880_uniwill_p53_hp_automute,
2877 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002878 [ALC880_CLEVO] = {
2879 .mixers = { alc880_three_stack_mixer },
2880 .init_verbs = { alc880_volume_init_verbs,
2881 alc880_pin_clevo_init_verbs },
2882 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2883 .dac_nids = alc880_dac_nids,
2884 .hp_nid = 0x03,
2885 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2886 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002887 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002888 .input_mux = &alc880_capture_source,
2889 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002890 [ALC880_LG] = {
2891 .mixers = { alc880_lg_mixer },
2892 .init_verbs = { alc880_volume_init_verbs,
2893 alc880_lg_init_verbs },
2894 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2895 .dac_nids = alc880_lg_dac_nids,
2896 .dig_out_nid = ALC880_DIGOUT_NID,
2897 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2898 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002899 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002900 .input_mux = &alc880_lg_capture_source,
2901 .unsol_event = alc880_lg_unsol_event,
2902 .init_hook = alc880_lg_automute,
2903 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002904 [ALC880_LG_LW] = {
2905 .mixers = { alc880_lg_lw_mixer },
2906 .init_verbs = { alc880_volume_init_verbs,
2907 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002908 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002909 .dac_nids = alc880_dac_nids,
2910 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002911 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2912 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002913 .input_mux = &alc880_lg_lw_capture_source,
2914 .unsol_event = alc880_lg_lw_unsol_event,
2915 .init_hook = alc880_lg_lw_automute,
2916 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002917#ifdef CONFIG_SND_DEBUG
2918 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002919 .mixers = { alc880_test_mixer },
2920 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002921 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2922 .dac_nids = alc880_test_dac_nids,
2923 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002924 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2925 .channel_mode = alc880_test_modes,
2926 .input_mux = &alc880_test_capture_source,
2927 },
2928#endif
2929};
2930
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002931/*
2932 * Automatic parse of I/O pins from the BIOS configuration
2933 */
2934
2935#define NUM_CONTROL_ALLOC 32
2936#define NUM_VERB_ALLOC 32
2937
2938enum {
2939 ALC_CTL_WIDGET_VOL,
2940 ALC_CTL_WIDGET_MUTE,
2941 ALC_CTL_BIND_MUTE,
2942};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002943static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002944 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2945 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002946 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002947};
2948
2949/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002950static int add_control(struct alc_spec *spec, int type, const char *name,
2951 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002952{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002953 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954
2955 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2956 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2957
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002958 /* array + terminator */
2959 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2960 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961 return -ENOMEM;
2962 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002963 memcpy(knew, spec->kctl_alloc,
2964 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002965 kfree(spec->kctl_alloc);
2966 }
2967 spec->kctl_alloc = knew;
2968 spec->num_kctl_alloc = num;
2969 }
2970
2971 knew = &spec->kctl_alloc[spec->num_kctl_used];
2972 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002973 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002974 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975 return -ENOMEM;
2976 knew->private_value = val;
2977 spec->num_kctl_used++;
2978 return 0;
2979}
2980
2981#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2982#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2983#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2984#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2985#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2986#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2987#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2988#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2989#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2990#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2991#define ALC880_PIN_CD_NID 0x1c
2992
2993/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002994static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2995 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002996{
2997 hda_nid_t nid;
2998 int assigned[4];
2999 int i, j;
3000
3001 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003002 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003003
3004 /* check the pins hardwired to audio widget */
3005 for (i = 0; i < cfg->line_outs; i++) {
3006 nid = cfg->line_out_pins[i];
3007 if (alc880_is_fixed_pin(nid)) {
3008 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003009 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003010 assigned[idx] = 1;
3011 }
3012 }
3013 /* left pins can be connect to any audio widget */
3014 for (i = 0; i < cfg->line_outs; i++) {
3015 nid = cfg->line_out_pins[i];
3016 if (alc880_is_fixed_pin(nid))
3017 continue;
3018 /* search for an empty channel */
3019 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003020 if (!assigned[j]) {
3021 spec->multiout.dac_nids[i] =
3022 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003023 assigned[j] = 1;
3024 break;
3025 }
3026 }
3027 }
3028 spec->multiout.num_dacs = cfg->line_outs;
3029 return 0;
3030}
3031
3032/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003033static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3034 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003035{
3036 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003037 static const char *chname[4] = {
3038 "Front", "Surround", NULL /*CLFE*/, "Side"
3039 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003040 hda_nid_t nid;
3041 int i, err;
3042
3043 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003044 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045 continue;
3046 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3047 if (i == 2) {
3048 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003049 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3050 "Center Playback Volume",
3051 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3052 HDA_OUTPUT));
3053 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003054 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003055 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3056 "LFE Playback Volume",
3057 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3058 HDA_OUTPUT));
3059 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003061 err = add_control(spec, ALC_CTL_BIND_MUTE,
3062 "Center Playback Switch",
3063 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3064 HDA_INPUT));
3065 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003066 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003067 err = add_control(spec, ALC_CTL_BIND_MUTE,
3068 "LFE Playback Switch",
3069 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3070 HDA_INPUT));
3071 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072 return err;
3073 } else {
3074 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003075 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3076 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3077 HDA_OUTPUT));
3078 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 return err;
3080 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003081 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3082 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3083 HDA_INPUT));
3084 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 return err;
3086 }
3087 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 return 0;
3089}
3090
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003091/* add playback controls for speaker and HP outputs */
3092static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3093 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003094{
3095 hda_nid_t nid;
3096 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003097 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003098
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003099 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003100 return 0;
3101
3102 if (alc880_is_fixed_pin(pin)) {
3103 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003104 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003105 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003107 else
3108 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 /* control HP volume/switch on the output mixer amp */
3110 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003111 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003112 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3113 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3114 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003115 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003116 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003117 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3118 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3119 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 return err;
3121 } else if (alc880_is_multi_pin(pin)) {
3122 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003123 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003124 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003125 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3126 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3127 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003128 return err;
3129 }
3130 return 0;
3131}
3132
3133/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003134static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3135 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003136 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137{
3138 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003139 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003140
3141 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003142 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3143 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3144 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003145 return err;
3146 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003147 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3148 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3149 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003150 return err;
3151 return 0;
3152}
3153
3154/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003155static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3156 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003157{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003158 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003159 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003160
3161 for (i = 0; i < AUTO_PIN_LAST; i++) {
3162 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003163 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003164 err = new_analog_input(spec, cfg->input_pins[i],
3165 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003166 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003167 if (err < 0)
3168 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003169 imux->items[imux->num_items].label =
3170 auto_pin_cfg_labels[i];
3171 imux->items[imux->num_items].index =
3172 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003173 imux->num_items++;
3174 }
3175 }
3176 return 0;
3177}
3178
Kailang Yangdf694da2005-12-05 19:42:22 +01003179static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3180 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003181 int dac_idx)
3182{
3183 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003184 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3185 pin_type);
3186 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3187 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003188 /* need the manual connection? */
3189 if (alc880_is_multi_pin(nid)) {
3190 struct alc_spec *spec = codec->spec;
3191 int idx = alc880_multi_pin_idx(nid);
3192 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3193 AC_VERB_SET_CONNECT_SEL,
3194 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3195 }
3196}
3197
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003198static int get_pin_type(int line_out_type)
3199{
3200 if (line_out_type == AUTO_PIN_HP_OUT)
3201 return PIN_HP;
3202 else
3203 return PIN_OUT;
3204}
3205
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003206static void alc880_auto_init_multi_out(struct hda_codec *codec)
3207{
3208 struct alc_spec *spec = codec->spec;
3209 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003210
3211 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003212 for (i = 0; i < spec->autocfg.line_outs; i++) {
3213 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003214 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3215 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003216 }
3217}
3218
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003219static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003220{
3221 struct alc_spec *spec = codec->spec;
3222 hda_nid_t pin;
3223
Takashi Iwai82bc9552006-03-21 11:24:42 +01003224 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003225 if (pin) /* connect to front */
3226 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003227 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003228 if (pin) /* connect to front */
3229 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3230}
3231
3232static void alc880_auto_init_analog_input(struct hda_codec *codec)
3233{
3234 struct alc_spec *spec = codec->spec;
3235 int i;
3236
3237 for (i = 0; i < AUTO_PIN_LAST; i++) {
3238 hda_nid_t nid = spec->autocfg.input_pins[i];
3239 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003240 snd_hda_codec_write(codec, nid, 0,
3241 AC_VERB_SET_PIN_WIDGET_CONTROL,
3242 i <= AUTO_PIN_FRONT_MIC ?
3243 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003244 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003245 snd_hda_codec_write(codec, nid, 0,
3246 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247 AMP_OUT_MUTE);
3248 }
3249 }
3250}
3251
3252/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003253/* return 1 if successful, 0 if the proper config is not found,
3254 * or a negative error code
3255 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256static int alc880_parse_auto_config(struct hda_codec *codec)
3257{
3258 struct alc_spec *spec = codec->spec;
3259 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003260 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003262 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3263 alc880_ignore);
3264 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003266 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003268
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003269 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3270 if (err < 0)
3271 return err;
3272 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3273 if (err < 0)
3274 return err;
3275 err = alc880_auto_create_extra_out(spec,
3276 spec->autocfg.speaker_pins[0],
3277 "Speaker");
3278 if (err < 0)
3279 return err;
3280 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3281 "Headphone");
3282 if (err < 0)
3283 return err;
3284 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3285 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003286 return err;
3287
3288 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3289
3290 if (spec->autocfg.dig_out_pin)
3291 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3292 if (spec->autocfg.dig_in_pin)
3293 spec->dig_in_nid = ALC880_DIGIN_NID;
3294
3295 if (spec->kctl_alloc)
3296 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3297
3298 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3299
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003300 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003301 spec->input_mux = &spec->private_imux;
3302
3303 return 1;
3304}
3305
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003306/* additional initialization for auto-configuration model */
3307static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003308{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003309 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003310 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003311 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003312}
3313
3314/*
3315 * OK, here we have finally the patch for ALC880
3316 */
3317
Linus Torvalds1da177e2005-04-16 15:20:36 -07003318static int patch_alc880(struct hda_codec *codec)
3319{
3320 struct alc_spec *spec;
3321 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003322 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003323
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003324 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325 if (spec == NULL)
3326 return -ENOMEM;
3327
3328 codec->spec = spec;
3329
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003330 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3331 alc880_models,
3332 alc880_cfg_tbl);
3333 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003334 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3335 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003336 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003337 }
3338
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003339 if (board_config == ALC880_AUTO) {
3340 /* automatic parse from the BIOS config */
3341 err = alc880_parse_auto_config(codec);
3342 if (err < 0) {
3343 alc_free(codec);
3344 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003345 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003346 printk(KERN_INFO
3347 "hda_codec: Cannot set up configuration "
3348 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003349 board_config = ALC880_3ST;
3350 }
3351 }
3352
Kailang Yangdf694da2005-12-05 19:42:22 +01003353 if (board_config != ALC880_AUTO)
3354 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003355
3356 spec->stream_name_analog = "ALC880 Analog";
3357 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3358 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3359
3360 spec->stream_name_digital = "ALC880 Digital";
3361 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3362 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3363
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003364 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003366 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003367 /* get type */
3368 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003369 if (wcap != AC_WID_AUD_IN) {
3370 spec->adc_nids = alc880_adc_nids_alt;
3371 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003372 spec->mixers[spec->num_mixers] =
3373 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003374 spec->num_mixers++;
3375 } else {
3376 spec->adc_nids = alc880_adc_nids;
3377 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3378 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3379 spec->num_mixers++;
3380 }
3381 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003382
3383 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003384 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003385 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386
3387 return 0;
3388}
3389
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390
Linus Torvalds1da177e2005-04-16 15:20:36 -07003391/*
3392 * ALC260 support
3393 */
3394
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395static hda_nid_t alc260_dac_nids[1] = {
3396 /* front */
3397 0x02,
3398};
3399
3400static hda_nid_t alc260_adc_nids[1] = {
3401 /* ADC0 */
3402 0x04,
3403};
3404
Kailang Yangdf694da2005-12-05 19:42:22 +01003405static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003406 /* ADC1 */
3407 0x05,
3408};
3409
Kailang Yangdf694da2005-12-05 19:42:22 +01003410static hda_nid_t alc260_hp_adc_nids[2] = {
3411 /* ADC1, 0 */
3412 0x05, 0x04
3413};
3414
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003415/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3416 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3417 */
3418static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003419 /* ADC0, ADC1 */
3420 0x04, 0x05
3421};
3422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003423#define ALC260_DIGOUT_NID 0x03
3424#define ALC260_DIGIN_NID 0x06
3425
3426static struct hda_input_mux alc260_capture_source = {
3427 .num_items = 4,
3428 .items = {
3429 { "Mic", 0x0 },
3430 { "Front Mic", 0x1 },
3431 { "Line", 0x2 },
3432 { "CD", 0x4 },
3433 },
3434};
3435
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003436/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003437 * headphone jack and the internal CD lines since these are the only pins at
3438 * which audio can appear. For flexibility, also allow the option of
3439 * recording the mixer output on the second ADC (ADC0 doesn't have a
3440 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003441 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003442static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3443 {
3444 .num_items = 3,
3445 .items = {
3446 { "Mic/Line", 0x0 },
3447 { "CD", 0x4 },
3448 { "Headphone", 0x2 },
3449 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003450 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003451 {
3452 .num_items = 4,
3453 .items = {
3454 { "Mic/Line", 0x0 },
3455 { "CD", 0x4 },
3456 { "Headphone", 0x2 },
3457 { "Mixer", 0x5 },
3458 },
3459 },
3460
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003461};
3462
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003463/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3464 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003465 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003466static struct hda_input_mux alc260_acer_capture_sources[2] = {
3467 {
3468 .num_items = 4,
3469 .items = {
3470 { "Mic", 0x0 },
3471 { "Line", 0x2 },
3472 { "CD", 0x4 },
3473 { "Headphone", 0x5 },
3474 },
3475 },
3476 {
3477 .num_items = 5,
3478 .items = {
3479 { "Mic", 0x0 },
3480 { "Line", 0x2 },
3481 { "CD", 0x4 },
3482 { "Headphone", 0x6 },
3483 { "Mixer", 0x5 },
3484 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003485 },
3486};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003487/*
3488 * This is just place-holder, so there's something for alc_build_pcms to look
3489 * at when it calculates the maximum number of channels. ALC260 has no mixer
3490 * element which allows changing the channel mode, so the verb list is
3491 * never used.
3492 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003493static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003494 { 2, NULL },
3495};
3496
Kailang Yangdf694da2005-12-05 19:42:22 +01003497
3498/* Mixer combinations
3499 *
3500 * basic: base_output + input + pc_beep + capture
3501 * HP: base_output + input + capture_alt
3502 * HP_3013: hp_3013 + input + capture
3503 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003504 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003505 */
3506
3507static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003508 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003509 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003510 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3511 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3512 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3513 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3514 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003515};
Kailang Yangdf694da2005-12-05 19:42:22 +01003516
3517static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003518 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3519 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3520 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3521 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3523 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3524 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3525 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003526 { } /* end */
3527};
3528
Kailang Yangdf694da2005-12-05 19:42:22 +01003529static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3530 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3531 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3532 { } /* end */
3533};
3534
3535static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3536 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3537 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3538 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3539 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3540 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3542 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3543 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003544 { } /* end */
3545};
3546
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003547/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3548 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3549 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003550static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003551 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003552 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003553 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003554 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3555 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3556 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3557 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003558 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003559 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3560 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3561 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003562 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003563 { } /* end */
3564};
3565
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003566/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3567 * versions of the ALC260 don't act on requests to enable mic bias from NID
3568 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3569 * datasheet doesn't mention this restriction. At this stage it's not clear
3570 * whether this behaviour is intentional or is a hardware bug in chip
3571 * revisions available in early 2006. Therefore for now allow the
3572 * "Headphone Jack Mode" control to span all choices, but if it turns out
3573 * that the lack of mic bias for this NID is intentional we could change the
3574 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3575 *
3576 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3577 * don't appear to make the mic bias available from the "line" jack, even
3578 * though the NID used for this jack (0x14) can supply it. The theory is
3579 * that perhaps Acer have included blocking capacitors between the ALC260
3580 * and the output jack. If this turns out to be the case for all such
3581 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3582 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003583 *
3584 * The C20x Tablet series have a mono internal speaker which is controlled
3585 * via the chip's Mono sum widget and pin complex, so include the necessary
3586 * controls for such models. On models without a "mono speaker" the control
3587 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003588 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003589static struct snd_kcontrol_new alc260_acer_mixer[] = {
3590 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3591 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003592 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003593 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3594 HDA_OUTPUT),
3595 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3596 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003597 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3598 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3599 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3600 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3601 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3602 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3603 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3604 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3605 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3606 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3607 { } /* end */
3608};
3609
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003610/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3611 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3612 */
3613static struct snd_kcontrol_new alc260_will_mixer[] = {
3614 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3615 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3617 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3618 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3619 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3620 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3621 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3622 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3623 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3624 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3625 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3626 { } /* end */
3627};
3628
3629/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3630 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3631 */
3632static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3633 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3634 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3636 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3637 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3638 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3639 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3640 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3641 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3642 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3643 { } /* end */
3644};
3645
Kailang Yangdf694da2005-12-05 19:42:22 +01003646/* capture mixer elements */
3647static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003648 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3649 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003650 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3651 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003652 {
3653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003654 /* The multiple "Capture Source" controls confuse alsamixer
3655 * So call somewhat different..
3656 * FIXME: the controls appear in the "playback" view!
3657 */
3658 /* .name = "Capture Source", */
3659 .name = "Input Source",
3660 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003661 .info = alc_mux_enum_info,
3662 .get = alc_mux_enum_get,
3663 .put = alc_mux_enum_put,
3664 },
3665 { } /* end */
3666};
3667
Kailang Yangdf694da2005-12-05 19:42:22 +01003668static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3669 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3670 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3671 {
3672 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3673 /* The multiple "Capture Source" controls confuse alsamixer
3674 * So call somewhat different..
3675 * FIXME: the controls appear in the "playback" view!
3676 */
3677 /* .name = "Capture Source", */
3678 .name = "Input Source",
3679 .count = 1,
3680 .info = alc_mux_enum_info,
3681 .get = alc_mux_enum_get,
3682 .put = alc_mux_enum_put,
3683 },
3684 { } /* end */
3685};
3686
3687/*
3688 * initialization verbs
3689 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003690static struct hda_verb alc260_init_verbs[] = {
3691 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003693 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003695 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003696 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003697 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003698 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003699 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003701 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003702 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003703 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003704 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003706 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003707 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003708 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3709 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003710 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003711 /* set connection select to line in (default select for this ADC) */
3712 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003713 /* mute capture amp left and right */
3714 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3715 /* set connection select to line in (default select for this ADC) */
3716 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003717 /* set vol=0 Line-Out mixer amp left and right */
3718 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3719 /* unmute pin widget amp left and right (no gain on this amp) */
3720 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3721 /* set vol=0 HP mixer amp left and right */
3722 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3723 /* unmute pin widget amp left and right (no gain on this amp) */
3724 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3725 /* set vol=0 Mono mixer amp left and right */
3726 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3727 /* unmute pin widget amp left and right (no gain on this amp) */
3728 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3729 /* unmute LINE-2 out pin */
3730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003731 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3732 * Line In 2 = 0x03
3733 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003734 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003736 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003738 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003740 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003741 /* mute Front out path */
3742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3744 /* mute Headphone out path */
3745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3747 /* mute Mono out path */
3748 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3749 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003750 { }
3751};
3752
Takashi Iwai474167d2006-05-17 17:17:43 +02003753#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003754static struct hda_verb alc260_hp_init_verbs[] = {
3755 /* Headphone and output */
3756 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3757 /* mono output */
3758 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3759 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3760 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3761 /* Mic2 (front panel) pin widget for input and vref at 80% */
3762 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3763 /* Line In pin widget for input */
3764 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3765 /* Line-2 pin widget for output */
3766 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3767 /* CD pin widget for input */
3768 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3769 /* unmute amp left and right */
3770 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3771 /* set connection select to line in (default select for this ADC) */
3772 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3773 /* unmute Line-Out mixer amp left and right (volume = 0) */
3774 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3775 /* mute pin widget amp left and right (no gain on this amp) */
3776 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3777 /* unmute HP mixer amp left and right (volume = 0) */
3778 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3779 /* mute pin widget amp left and right (no gain on this amp) */
3780 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003781 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3782 * Line In 2 = 0x03
3783 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003784 /* unmute CD */
3785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3786 /* unmute Line In */
3787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3788 /* unmute Mic */
3789 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3790 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3791 /* Unmute Front out path */
3792 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3794 /* Unmute Headphone out path */
3795 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3797 /* Unmute Mono out path */
3798 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3799 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3800 { }
3801};
Takashi Iwai474167d2006-05-17 17:17:43 +02003802#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003803
3804static struct hda_verb alc260_hp_3013_init_verbs[] = {
3805 /* Line out and output */
3806 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3807 /* mono output */
3808 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3809 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3810 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3811 /* Mic2 (front panel) pin widget for input and vref at 80% */
3812 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3813 /* Line In pin widget for input */
3814 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3815 /* Headphone pin widget for output */
3816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3817 /* CD pin widget for input */
3818 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3819 /* unmute amp left and right */
3820 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3821 /* set connection select to line in (default select for this ADC) */
3822 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3823 /* unmute Line-Out mixer amp left and right (volume = 0) */
3824 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3825 /* mute pin widget amp left and right (no gain on this amp) */
3826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3827 /* unmute HP mixer amp left and right (volume = 0) */
3828 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3829 /* mute pin widget amp left and right (no gain on this amp) */
3830 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003831 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3832 * Line In 2 = 0x03
3833 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003834 /* unmute CD */
3835 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3836 /* unmute Line In */
3837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3838 /* unmute Mic */
3839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3840 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3841 /* Unmute Front out path */
3842 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3843 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3844 /* Unmute Headphone out path */
3845 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3846 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3847 /* Unmute Mono out path */
3848 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3849 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3850 { }
3851};
3852
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003853/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003854 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3855 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003856 */
3857static struct hda_verb alc260_fujitsu_init_verbs[] = {
3858 /* Disable all GPIOs */
3859 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3860 /* Internal speaker is connected to headphone pin */
3861 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3862 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3863 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003864 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3865 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3866 /* Ensure all other unused pins are disabled and muted. */
3867 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3868 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003869 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003870 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003871 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003872 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003875
Jonathan Woithef7ace402006-02-28 11:46:14 +01003876 /* Disable digital (SPDIF) pins */
3877 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3878 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003879
Jonathan Woithef7ace402006-02-28 11:46:14 +01003880 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3881 * when acting as an output.
3882 */
3883 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3884
3885 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003886 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3887 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3892 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3893 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3894 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003895
Jonathan Woithef7ace402006-02-28 11:46:14 +01003896 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3897 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3898 /* Unmute Line1 pin widget output buffer since it starts as an output.
3899 * If the pin mode is changed by the user the pin mode control will
3900 * take care of enabling the pin's input/output buffers as needed.
3901 * Therefore there's no need to enable the input buffer at this
3902 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003903 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003905 /* Unmute input buffer of pin widget used for Line-in (no equiv
3906 * mixer ctrl)
3907 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003908 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003909
Jonathan Woithef7ace402006-02-28 11:46:14 +01003910 /* Mute capture amp left and right */
3911 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3912 /* Set ADC connection select to match default mixer setting - line
3913 * in (on mic1 pin)
3914 */
3915 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003916
Jonathan Woithef7ace402006-02-28 11:46:14 +01003917 /* Do the same for the second ADC: mute capture input amp and
3918 * set ADC connection to line in (on mic1 pin)
3919 */
3920 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3921 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003922
Jonathan Woithef7ace402006-02-28 11:46:14 +01003923 /* Mute all inputs to mixer widget (even unconnected ones) */
3924 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3925 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3926 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003932
3933 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003934};
3935
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003936/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3937 * similar laptops (adapted from Fujitsu init verbs).
3938 */
3939static struct hda_verb alc260_acer_init_verbs[] = {
3940 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3941 * the headphone jack. Turn this on and rely on the standard mute
3942 * methods whenever the user wants to turn these outputs off.
3943 */
3944 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3945 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3946 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3947 /* Internal speaker/Headphone jack is connected to Line-out pin */
3948 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3949 /* Internal microphone/Mic jack is connected to Mic1 pin */
3950 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3951 /* Line In jack is connected to Line1 pin */
3952 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003953 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3954 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003955 /* Ensure all other unused pins are disabled and muted. */
3956 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3957 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003958 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3959 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3962 /* Disable digital (SPDIF) pins */
3963 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3964 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3965
3966 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3967 * bus when acting as outputs.
3968 */
3969 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3970 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3971
3972 /* Start with output sum widgets muted and their output gains at min */
3973 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3976 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3978 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3979 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3980 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3981 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3982
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003983 /* Unmute Line-out pin widget amp left and right
3984 * (no equiv mixer ctrl)
3985 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003986 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003987 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3988 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003989 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3990 * inputs. If the pin mode is changed by the user the pin mode control
3991 * will take care of enabling the pin's input/output buffers as needed.
3992 * Therefore there's no need to enable the input buffer at this
3993 * stage.
3994 */
3995 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3996 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3997
3998 /* Mute capture amp left and right */
3999 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4000 /* Set ADC connection select to match default mixer setting - mic
4001 * (on mic1 pin)
4002 */
4003 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4004
4005 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004006 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004007 */
4008 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004009 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004010
4011 /* Mute all inputs to mixer widget (even unconnected ones) */
4012 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4014 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4020
4021 { }
4022};
4023
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004024static struct hda_verb alc260_will_verbs[] = {
4025 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4026 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4027 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4028 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4029 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4030 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4031 {}
4032};
4033
4034static struct hda_verb alc260_replacer_672v_verbs[] = {
4035 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4036 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4037 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4038
4039 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4040 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4041 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4042
4043 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4044 {}
4045};
4046
4047/* toggle speaker-output according to the hp-jack state */
4048static void alc260_replacer_672v_automute(struct hda_codec *codec)
4049{
4050 unsigned int present;
4051
4052 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4053 present = snd_hda_codec_read(codec, 0x0f, 0,
4054 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4055 if (present) {
4056 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4057 snd_hda_codec_write(codec, 0x0f, 0,
4058 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4059 } else {
4060 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4061 snd_hda_codec_write(codec, 0x0f, 0,
4062 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4063 }
4064}
4065
4066static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4067 unsigned int res)
4068{
4069 if ((res >> 26) == ALC880_HP_EVENT)
4070 alc260_replacer_672v_automute(codec);
4071}
4072
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004073/* Test configuration for debugging, modelled after the ALC880 test
4074 * configuration.
4075 */
4076#ifdef CONFIG_SND_DEBUG
4077static hda_nid_t alc260_test_dac_nids[1] = {
4078 0x02,
4079};
4080static hda_nid_t alc260_test_adc_nids[2] = {
4081 0x04, 0x05,
4082};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004083/* For testing the ALC260, each input MUX needs its own definition since
4084 * the signal assignments are different. This assumes that the first ADC
4085 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004086 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004087static struct hda_input_mux alc260_test_capture_sources[2] = {
4088 {
4089 .num_items = 7,
4090 .items = {
4091 { "MIC1 pin", 0x0 },
4092 { "MIC2 pin", 0x1 },
4093 { "LINE1 pin", 0x2 },
4094 { "LINE2 pin", 0x3 },
4095 { "CD pin", 0x4 },
4096 { "LINE-OUT pin", 0x5 },
4097 { "HP-OUT pin", 0x6 },
4098 },
4099 },
4100 {
4101 .num_items = 8,
4102 .items = {
4103 { "MIC1 pin", 0x0 },
4104 { "MIC2 pin", 0x1 },
4105 { "LINE1 pin", 0x2 },
4106 { "LINE2 pin", 0x3 },
4107 { "CD pin", 0x4 },
4108 { "Mixer", 0x5 },
4109 { "LINE-OUT pin", 0x6 },
4110 { "HP-OUT pin", 0x7 },
4111 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004112 },
4113};
4114static struct snd_kcontrol_new alc260_test_mixer[] = {
4115 /* Output driver widgets */
4116 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4117 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4118 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4119 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4120 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4121 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4122
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004123 /* Modes for retasking pin widgets
4124 * Note: the ALC260 doesn't seem to act on requests to enable mic
4125 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4126 * mention this restriction. At this stage it's not clear whether
4127 * this behaviour is intentional or is a hardware bug in chip
4128 * revisions available at least up until early 2006. Therefore for
4129 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4130 * choices, but if it turns out that the lack of mic bias for these
4131 * NIDs is intentional we could change their modes from
4132 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4133 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004134 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4135 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4136 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4137 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4138 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4139 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4140
4141 /* Loopback mixer controls */
4142 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4143 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4144 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4145 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4146 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4147 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4148 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4149 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4150 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4151 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4152 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4153 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4154 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4155 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4156 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4157 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004158
4159 /* Controls for GPIO pins, assuming they are configured as outputs */
4160 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4161 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4162 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4163 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4164
Jonathan Woithe92621f12006-02-28 11:47:47 +01004165 /* Switches to allow the digital IO pins to be enabled. The datasheet
4166 * is ambigious as to which NID is which; testing on laptops which
4167 * make this output available should provide clarification.
4168 */
4169 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4170 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4171
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004172 { } /* end */
4173};
4174static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004175 /* Enable all GPIOs as outputs with an initial value of 0 */
4176 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4177 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4178 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4179
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004180 /* Enable retasking pins as output, initially without power amp */
4181 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4182 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4184 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4185 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4186 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4187
Jonathan Woithe92621f12006-02-28 11:47:47 +01004188 /* Disable digital (SPDIF) pins initially, but users can enable
4189 * them via a mixer switch. In the case of SPDIF-out, this initverb
4190 * payload also sets the generation to 0, output to be in "consumer"
4191 * PCM format, copyright asserted, no pre-emphasis and no validity
4192 * control.
4193 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004194 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4195 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4196
Jonathan Woithef7ace402006-02-28 11:46:14 +01004197 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004198 * OUT1 sum bus when acting as an output.
4199 */
4200 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4201 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4202 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4203 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4204
4205 /* Start with output sum widgets muted and their output gains at min */
4206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4207 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4208 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4209 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4211 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4212 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4213 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4214 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4215
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004216 /* Unmute retasking pin widget output buffers since the default
4217 * state appears to be output. As the pin mode is changed by the
4218 * user the pin mode control will take care of enabling the pin's
4219 * input/output buffers as needed.
4220 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004221 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4222 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4225 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4226 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4227 /* Also unmute the mono-out pin widget */
4228 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4229
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004230 /* Mute capture amp left and right */
4231 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004232 /* Set ADC connection select to match default mixer setting (mic1
4233 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004234 */
4235 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4236
4237 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004238 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004239 */
4240 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4241 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4242
4243 /* Mute all inputs to mixer widget (even unconnected ones) */
4244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4252
4253 { }
4254};
4255#endif
4256
Linus Torvalds1da177e2005-04-16 15:20:36 -07004257static struct hda_pcm_stream alc260_pcm_analog_playback = {
4258 .substreams = 1,
4259 .channels_min = 2,
4260 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004261};
4262
4263static struct hda_pcm_stream alc260_pcm_analog_capture = {
4264 .substreams = 1,
4265 .channels_min = 2,
4266 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004267};
4268
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004269#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4270#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4271
Kailang Yangdf694da2005-12-05 19:42:22 +01004272/*
4273 * for BIOS auto-configuration
4274 */
4275
4276static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4277 const char *pfx)
4278{
4279 hda_nid_t nid_vol;
4280 unsigned long vol_val, sw_val;
4281 char name[32];
4282 int err;
4283
4284 if (nid >= 0x0f && nid < 0x11) {
4285 nid_vol = nid - 0x7;
4286 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4287 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4288 } else if (nid == 0x11) {
4289 nid_vol = nid - 0x7;
4290 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4291 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4292 } else if (nid >= 0x12 && nid <= 0x15) {
4293 nid_vol = 0x08;
4294 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4295 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4296 } else
4297 return 0; /* N/A */
4298
4299 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004300 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4301 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004302 return err;
4303 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004304 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4305 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004306 return err;
4307 return 1;
4308}
4309
4310/* add playback controls from the parsed DAC table */
4311static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4312 const struct auto_pin_cfg *cfg)
4313{
4314 hda_nid_t nid;
4315 int err;
4316
4317 spec->multiout.num_dacs = 1;
4318 spec->multiout.dac_nids = spec->private_dac_nids;
4319 spec->multiout.dac_nids[0] = 0x02;
4320
4321 nid = cfg->line_out_pins[0];
4322 if (nid) {
4323 err = alc260_add_playback_controls(spec, nid, "Front");
4324 if (err < 0)
4325 return err;
4326 }
4327
Takashi Iwai82bc9552006-03-21 11:24:42 +01004328 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004329 if (nid) {
4330 err = alc260_add_playback_controls(spec, nid, "Speaker");
4331 if (err < 0)
4332 return err;
4333 }
4334
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004335 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004336 if (nid) {
4337 err = alc260_add_playback_controls(spec, nid, "Headphone");
4338 if (err < 0)
4339 return err;
4340 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004341 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004342}
4343
4344/* create playback/capture controls for input pins */
4345static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4346 const struct auto_pin_cfg *cfg)
4347{
Kailang Yangdf694da2005-12-05 19:42:22 +01004348 struct hda_input_mux *imux = &spec->private_imux;
4349 int i, err, idx;
4350
4351 for (i = 0; i < AUTO_PIN_LAST; i++) {
4352 if (cfg->input_pins[i] >= 0x12) {
4353 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004354 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004355 auto_pin_cfg_labels[i], idx,
4356 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004357 if (err < 0)
4358 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004359 imux->items[imux->num_items].label =
4360 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004361 imux->items[imux->num_items].index = idx;
4362 imux->num_items++;
4363 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004364 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004365 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004366 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004367 auto_pin_cfg_labels[i], idx,
4368 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004369 if (err < 0)
4370 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004371 imux->items[imux->num_items].label =
4372 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004373 imux->items[imux->num_items].index = idx;
4374 imux->num_items++;
4375 }
4376 }
4377 return 0;
4378}
4379
4380static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4381 hda_nid_t nid, int pin_type,
4382 int sel_idx)
4383{
4384 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004385 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4386 pin_type);
4387 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4388 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004389 /* need the manual connection? */
4390 if (nid >= 0x12) {
4391 int idx = nid - 0x12;
4392 snd_hda_codec_write(codec, idx + 0x0b, 0,
4393 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004394 }
4395}
4396
4397static void alc260_auto_init_multi_out(struct hda_codec *codec)
4398{
4399 struct alc_spec *spec = codec->spec;
4400 hda_nid_t nid;
4401
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004402 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004403 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004404 if (nid) {
4405 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4406 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4407 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004408
Takashi Iwai82bc9552006-03-21 11:24:42 +01004409 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004410 if (nid)
4411 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4412
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004413 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004414 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004415 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004416}
Kailang Yangdf694da2005-12-05 19:42:22 +01004417
4418#define ALC260_PIN_CD_NID 0x16
4419static void alc260_auto_init_analog_input(struct hda_codec *codec)
4420{
4421 struct alc_spec *spec = codec->spec;
4422 int i;
4423
4424 for (i = 0; i < AUTO_PIN_LAST; i++) {
4425 hda_nid_t nid = spec->autocfg.input_pins[i];
4426 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004427 snd_hda_codec_write(codec, nid, 0,
4428 AC_VERB_SET_PIN_WIDGET_CONTROL,
4429 i <= AUTO_PIN_FRONT_MIC ?
4430 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004431 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004432 snd_hda_codec_write(codec, nid, 0,
4433 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004434 AMP_OUT_MUTE);
4435 }
4436 }
4437}
4438
4439/*
4440 * generic initialization of ADC, input mixers and output mixers
4441 */
4442static struct hda_verb alc260_volume_init_verbs[] = {
4443 /*
4444 * Unmute ADC0-1 and set the default input to mic-in
4445 */
4446 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4447 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4448 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4449 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4450
4451 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4452 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004453 * Note: PASD motherboards uses the Line In 2 as the input for
4454 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004455 */
4456 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4462
4463 /*
4464 * Set up output mixers (0x08 - 0x0a)
4465 */
4466 /* set vol=0 to output mixers */
4467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4470 /* set up input amps for analog loopback */
4471 /* Amp Indices: DAC = 0, mixer = 1 */
4472 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4473 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4474 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4475 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4476 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4477 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4478
4479 { }
4480};
4481
4482static int alc260_parse_auto_config(struct hda_codec *codec)
4483{
4484 struct alc_spec *spec = codec->spec;
4485 unsigned int wcap;
4486 int err;
4487 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4488
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004489 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4490 alc260_ignore);
4491 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004492 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004493 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4494 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004495 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004496 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004497 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004498 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4499 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004500 return err;
4501
4502 spec->multiout.max_channels = 2;
4503
4504 if (spec->autocfg.dig_out_pin)
4505 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4506 if (spec->kctl_alloc)
4507 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4508
4509 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4510
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004511 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004512 spec->input_mux = &spec->private_imux;
4513
4514 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004515 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004516 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4517 if (wcap != AC_WID_AUD_IN) {
4518 spec->adc_nids = alc260_adc_nids_alt;
4519 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4520 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004521 } else {
4522 spec->adc_nids = alc260_adc_nids;
4523 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4524 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004525 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004526 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004527
4528 return 1;
4529}
4530
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004531/* additional initialization for auto-configuration model */
4532static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004533{
Kailang Yangdf694da2005-12-05 19:42:22 +01004534 alc260_auto_init_multi_out(codec);
4535 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004536}
4537
4538/*
4539 * ALC260 configurations
4540 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004541static const char *alc260_models[ALC260_MODEL_LAST] = {
4542 [ALC260_BASIC] = "basic",
4543 [ALC260_HP] = "hp",
4544 [ALC260_HP_3013] = "hp-3013",
4545 [ALC260_FUJITSU_S702X] = "fujitsu",
4546 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004547 [ALC260_WILL] = "will",
4548 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004549#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004550 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004551#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004552 [ALC260_AUTO] = "auto",
4553};
4554
4555static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004556 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004557 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004558 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004559 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004560 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4561 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4562 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4563 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4564 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4565 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4566 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4567 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4568 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4569 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4570 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4571 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004572 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4573 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004574 {}
4575};
4576
Kailang Yangdf694da2005-12-05 19:42:22 +01004577static struct alc_config_preset alc260_presets[] = {
4578 [ALC260_BASIC] = {
4579 .mixers = { alc260_base_output_mixer,
4580 alc260_input_mixer,
4581 alc260_pc_beep_mixer,
4582 alc260_capture_mixer },
4583 .init_verbs = { alc260_init_verbs },
4584 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4585 .dac_nids = alc260_dac_nids,
4586 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4587 .adc_nids = alc260_adc_nids,
4588 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4589 .channel_mode = alc260_modes,
4590 .input_mux = &alc260_capture_source,
4591 },
4592 [ALC260_HP] = {
4593 .mixers = { alc260_base_output_mixer,
4594 alc260_input_mixer,
4595 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004596 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004597 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4598 .dac_nids = alc260_dac_nids,
4599 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4600 .adc_nids = alc260_hp_adc_nids,
4601 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4602 .channel_mode = alc260_modes,
4603 .input_mux = &alc260_capture_source,
4604 },
4605 [ALC260_HP_3013] = {
4606 .mixers = { alc260_hp_3013_mixer,
4607 alc260_input_mixer,
4608 alc260_capture_alt_mixer },
4609 .init_verbs = { alc260_hp_3013_init_verbs },
4610 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4611 .dac_nids = alc260_dac_nids,
4612 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4613 .adc_nids = alc260_hp_adc_nids,
4614 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4615 .channel_mode = alc260_modes,
4616 .input_mux = &alc260_capture_source,
4617 },
4618 [ALC260_FUJITSU_S702X] = {
4619 .mixers = { alc260_fujitsu_mixer,
4620 alc260_capture_mixer },
4621 .init_verbs = { alc260_fujitsu_init_verbs },
4622 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4623 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004624 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4625 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004626 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4627 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004628 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4629 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004630 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004631 [ALC260_ACER] = {
4632 .mixers = { alc260_acer_mixer,
4633 alc260_capture_mixer },
4634 .init_verbs = { alc260_acer_init_verbs },
4635 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4636 .dac_nids = alc260_dac_nids,
4637 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4638 .adc_nids = alc260_dual_adc_nids,
4639 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4640 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004641 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4642 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004643 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004644 [ALC260_WILL] = {
4645 .mixers = { alc260_will_mixer,
4646 alc260_capture_mixer },
4647 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4648 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4649 .dac_nids = alc260_dac_nids,
4650 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4651 .adc_nids = alc260_adc_nids,
4652 .dig_out_nid = ALC260_DIGOUT_NID,
4653 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4654 .channel_mode = alc260_modes,
4655 .input_mux = &alc260_capture_source,
4656 },
4657 [ALC260_REPLACER_672V] = {
4658 .mixers = { alc260_replacer_672v_mixer,
4659 alc260_capture_mixer },
4660 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4661 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4662 .dac_nids = alc260_dac_nids,
4663 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4664 .adc_nids = alc260_adc_nids,
4665 .dig_out_nid = ALC260_DIGOUT_NID,
4666 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4667 .channel_mode = alc260_modes,
4668 .input_mux = &alc260_capture_source,
4669 .unsol_event = alc260_replacer_672v_unsol_event,
4670 .init_hook = alc260_replacer_672v_automute,
4671 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004672#ifdef CONFIG_SND_DEBUG
4673 [ALC260_TEST] = {
4674 .mixers = { alc260_test_mixer,
4675 alc260_capture_mixer },
4676 .init_verbs = { alc260_test_init_verbs },
4677 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4678 .dac_nids = alc260_test_dac_nids,
4679 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4680 .adc_nids = alc260_test_adc_nids,
4681 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4682 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004683 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4684 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004685 },
4686#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004687};
4688
Linus Torvalds1da177e2005-04-16 15:20:36 -07004689static int patch_alc260(struct hda_codec *codec)
4690{
4691 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004692 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004693
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004694 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004695 if (spec == NULL)
4696 return -ENOMEM;
4697
4698 codec->spec = spec;
4699
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004700 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4701 alc260_models,
4702 alc260_cfg_tbl);
4703 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004704 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4705 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004706 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004707 }
4708
Kailang Yangdf694da2005-12-05 19:42:22 +01004709 if (board_config == ALC260_AUTO) {
4710 /* automatic parse from the BIOS config */
4711 err = alc260_parse_auto_config(codec);
4712 if (err < 0) {
4713 alc_free(codec);
4714 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004715 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004716 printk(KERN_INFO
4717 "hda_codec: Cannot set up configuration "
4718 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004719 board_config = ALC260_BASIC;
4720 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004721 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004722
Kailang Yangdf694da2005-12-05 19:42:22 +01004723 if (board_config != ALC260_AUTO)
4724 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004725
4726 spec->stream_name_analog = "ALC260 Analog";
4727 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4728 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4729
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004730 spec->stream_name_digital = "ALC260 Digital";
4731 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4732 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4733
Linus Torvalds1da177e2005-04-16 15:20:36 -07004734 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004735 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004736 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004737
4738 return 0;
4739}
4740
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741
Linus Torvalds1da177e2005-04-16 15:20:36 -07004742/*
4743 * ALC882 support
4744 *
4745 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4746 * configuration. Each pin widget can choose any input DACs and a mixer.
4747 * Each ADC is connected from a mixer of all inputs. This makes possible
4748 * 6-channel independent captures.
4749 *
4750 * In addition, an independent DAC for the multi-playback (not used in this
4751 * driver yet).
4752 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004753#define ALC882_DIGOUT_NID 0x06
4754#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004755
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004756static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004757 { 8, NULL }
4758};
4759
4760static hda_nid_t alc882_dac_nids[4] = {
4761 /* front, rear, clfe, rear_surr */
4762 0x02, 0x03, 0x04, 0x05
4763};
4764
Kailang Yangdf694da2005-12-05 19:42:22 +01004765/* identical with ALC880 */
4766#define alc882_adc_nids alc880_adc_nids
4767#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004768
4769/* input MUX */
4770/* FIXME: should be a matrix-type input source selection */
4771
4772static struct hda_input_mux alc882_capture_source = {
4773 .num_items = 4,
4774 .items = {
4775 { "Mic", 0x0 },
4776 { "Front Mic", 0x1 },
4777 { "Line", 0x2 },
4778 { "CD", 0x4 },
4779 },
4780};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004781#define alc882_mux_enum_info alc_mux_enum_info
4782#define alc882_mux_enum_get alc_mux_enum_get
4783
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004784static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4785 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004786{
4787 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4788 struct alc_spec *spec = codec->spec;
4789 const struct hda_input_mux *imux = spec->input_mux;
4790 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4791 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4792 hda_nid_t nid = capture_mixers[adc_idx];
4793 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4794 unsigned int i, idx;
4795
4796 idx = ucontrol->value.enumerated.item[0];
4797 if (idx >= imux->num_items)
4798 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004799 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004800 return 0;
4801 for (i = 0; i < imux->num_items; i++) {
4802 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4803 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4804 v | (imux->items[i].index << 8));
4805 }
4806 *cur_val = idx;
4807 return 1;
4808}
4809
Kailang Yangdf694da2005-12-05 19:42:22 +01004810/*
Kailang Yang272a5272007-05-14 11:00:38 +02004811 * 2ch mode
4812 */
4813static struct hda_verb alc882_3ST_ch2_init[] = {
4814 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4815 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4816 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4817 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4818 { } /* end */
4819};
4820
4821/*
4822 * 6ch mode
4823 */
4824static struct hda_verb alc882_3ST_ch6_init[] = {
4825 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4826 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4827 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4828 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4829 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4830 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4831 { } /* end */
4832};
4833
4834static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4835 { 2, alc882_3ST_ch2_init },
4836 { 6, alc882_3ST_ch6_init },
4837};
4838
4839/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004840 * 6ch mode
4841 */
4842static struct hda_verb alc882_sixstack_ch6_init[] = {
4843 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4844 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4845 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4846 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4847 { } /* end */
4848};
4849
4850/*
4851 * 8ch mode
4852 */
4853static struct hda_verb alc882_sixstack_ch8_init[] = {
4854 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4855 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4856 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4857 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4858 { } /* end */
4859};
4860
4861static struct hda_channel_mode alc882_sixstack_modes[2] = {
4862 { 6, alc882_sixstack_ch6_init },
4863 { 8, alc882_sixstack_ch8_init },
4864};
4865
Linus Torvalds1da177e2005-04-16 15:20:36 -07004866/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4867 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4868 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004869static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004870 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004871 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004872 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004873 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004874 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4875 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004876 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4877 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004878 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004879 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004880 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
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),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004886 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004887 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4888 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004889 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004890 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4891 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4892 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004893 { } /* end */
4894};
4895
Kailang Yangbdd148a2007-05-08 15:19:08 +02004896static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4897 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4898 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4899 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4900 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4901 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4902 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4904 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4906 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4907 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4908 { } /* end */
4909};
4910
Kailang Yang272a5272007-05-14 11:00:38 +02004911static struct snd_kcontrol_new alc882_targa_mixer[] = {
4912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4913 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4921 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4922 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4923 { } /* end */
4924};
4925
4926/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4927 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4928 */
4929static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4930 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4931 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4932 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4933 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4934 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4935 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4936 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4937 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4938 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4939 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4941 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4942 { } /* end */
4943};
4944
Kailang Yangdf694da2005-12-05 19:42:22 +01004945static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4946 {
4947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4948 .name = "Channel Mode",
4949 .info = alc_ch_mode_info,
4950 .get = alc_ch_mode_get,
4951 .put = alc_ch_mode_put,
4952 },
4953 { } /* end */
4954};
4955
Linus Torvalds1da177e2005-04-16 15:20:36 -07004956static struct hda_verb alc882_init_verbs[] = {
4957 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004961 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4964 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004965 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004966 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004969 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004970 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4971 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4972 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004973
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004974 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004976 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004977 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004978 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004983 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004984 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004985 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004986 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004987 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004988 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004989 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4993 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004994 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004995 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4996 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004997 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004998 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4999 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5000 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5001 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5002 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005003 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005004 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005005
5006 /* FIXME: use matrix-type input source selection */
5007 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5008 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005009 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5010 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005013 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005014 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005018 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5023 /* ADC1: mute amp left and right */
5024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005025 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005026 /* ADC2: mute amp left and right */
5027 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005028 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005029 /* ADC3: mute amp left and right */
5030 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005031 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005032
5033 { }
5034};
5035
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005036static struct hda_verb alc882_eapd_verbs[] = {
5037 /* change to EAPD mode */
5038 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005039 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005040 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005041};
5042
Tobin Davis9102cd12006-12-15 10:02:12 +01005043/* Mac Pro test */
5044static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5046 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5050 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5051 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5052 { } /* end */
5053};
5054
5055static struct hda_verb alc882_macpro_init_verbs[] = {
5056 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5057 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5060 /* Front Pin: output 0 (0x0c) */
5061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5063 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5064 /* Front Mic pin: input vref at 80% */
5065 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5066 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5067 /* Speaker: output */
5068 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5069 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5070 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5071 /* Headphone output (output 0 - 0x0c) */
5072 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5074 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5075
5076 /* FIXME: use matrix-type input source selection */
5077 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5078 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5079 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5080 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5083 /* Input mixer2 */
5084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5087 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5088 /* Input mixer3 */
5089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5093 /* ADC1: mute amp left and right */
5094 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5095 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5096 /* ADC2: mute amp left and right */
5097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5098 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5099 /* ADC3: mute amp left and right */
5100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5101 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5102
5103 { }
5104};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005105
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005106/* iMac 24 mixer. */
5107static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5108 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5109 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5110 { } /* end */
5111};
5112
5113/* iMac 24 init verbs. */
5114static struct hda_verb alc885_imac24_init_verbs[] = {
5115 /* Internal speakers: output 0 (0x0c) */
5116 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5117 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5118 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5119 /* Internal speakers: output 0 (0x0c) */
5120 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5121 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5122 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5123 /* Headphone: output 0 (0x0c) */
5124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5126 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5127 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5128 /* Front Mic: input vref at 80% */
5129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5130 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5131 { }
5132};
5133
5134/* Toggle speaker-output according to the hp-jack state */
5135static void alc885_imac24_automute(struct hda_codec *codec)
5136{
5137 unsigned int present;
5138
5139 present = snd_hda_codec_read(codec, 0x14, 0,
5140 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5141 snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
5142 0x80, present ? 0x80 : 0);
5143 snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
5144 0x80, present ? 0x80 : 0);
5145 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
5146 0x80, present ? 0x80 : 0);
5147 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
5148 0x80, present ? 0x80 : 0);
5149}
5150
5151/* Processes unsolicited events. */
5152static void alc885_imac24_unsol_event(struct hda_codec *codec,
5153 unsigned int res)
5154{
5155 /* Headphone insertion or removal. */
5156 if ((res >> 26) == ALC880_HP_EVENT)
5157 alc885_imac24_automute(codec);
5158}
5159
Kailang Yang272a5272007-05-14 11:00:38 +02005160static struct hda_verb alc882_targa_verbs[] = {
5161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5163
5164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5165 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5166
5167 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5168 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5169 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5170
5171 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5172 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5173 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5174 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5175 { } /* end */
5176};
5177
5178/* toggle speaker-output according to the hp-jack state */
5179static void alc882_targa_automute(struct hda_codec *codec)
5180{
5181 unsigned int present;
5182
5183 present = snd_hda_codec_read(codec, 0x14, 0,
5184 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5185 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5186 0x80, present ? 0x80 : 0);
5187 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5188 0x80, present ? 0x80 : 0);
5189 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5190}
5191
5192static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5193{
5194 /* Looks like the unsol event is incompatible with the standard
5195 * definition. 4bit tag is placed at 26 bit!
5196 */
5197 if (((res >> 26) == ALC880_HP_EVENT)) {
5198 alc882_targa_automute(codec);
5199 }
5200}
5201
5202static struct hda_verb alc882_asus_a7j_verbs[] = {
5203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5205
5206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5208 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5209
5210 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5211 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5212 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5213
5214 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5215 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5216 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5217 { } /* end */
5218};
5219
Tobin Davis9102cd12006-12-15 10:02:12 +01005220static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5221{
5222 unsigned int gpiostate, gpiomask, gpiodir;
5223
5224 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5225 AC_VERB_GET_GPIO_DATA, 0);
5226
5227 if (!muted)
5228 gpiostate |= (1 << pin);
5229 else
5230 gpiostate &= ~(1 << pin);
5231
5232 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5233 AC_VERB_GET_GPIO_MASK, 0);
5234 gpiomask |= (1 << pin);
5235
5236 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5237 AC_VERB_GET_GPIO_DIRECTION, 0);
5238 gpiodir |= (1 << pin);
5239
5240
5241 snd_hda_codec_write(codec, codec->afg, 0,
5242 AC_VERB_SET_GPIO_MASK, gpiomask);
5243 snd_hda_codec_write(codec, codec->afg, 0,
5244 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5245
5246 msleep(1);
5247
5248 snd_hda_codec_write(codec, codec->afg, 0,
5249 AC_VERB_SET_GPIO_DATA, gpiostate);
5250}
5251
Kailang Yangdf694da2005-12-05 19:42:22 +01005252/*
5253 * generic initialization of ADC, input mixers and output mixers
5254 */
5255static struct hda_verb alc882_auto_init_verbs[] = {
5256 /*
5257 * Unmute ADC0-2 and set the default input to mic-in
5258 */
5259 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5261 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5263 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5264 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5265
5266 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5267 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005268 * Note: PASD motherboards uses the Line In 2 as the input for
5269 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005270 */
5271 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5277
5278 /*
5279 * Set up output mixers (0x0c - 0x0f)
5280 */
5281 /* set vol=0 to output mixers */
5282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5285 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5286 /* set up input amps for analog loopback */
5287 /* Amp Indices: DAC = 0, mixer = 1 */
5288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5291 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5296 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5297 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5298
5299 /* FIXME: use matrix-type input source selection */
5300 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5301 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5306 /* Input mixer2 */
5307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5311 /* Input mixer3 */
5312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5316
5317 { }
5318};
5319
5320/* capture mixer elements */
5321static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5322 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5323 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5324 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5325 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5326 {
5327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5328 /* The multiple "Capture Source" controls confuse alsamixer
5329 * So call somewhat different..
5330 * FIXME: the controls appear in the "playback" view!
5331 */
5332 /* .name = "Capture Source", */
5333 .name = "Input Source",
5334 .count = 2,
5335 .info = alc882_mux_enum_info,
5336 .get = alc882_mux_enum_get,
5337 .put = alc882_mux_enum_put,
5338 },
5339 { } /* end */
5340};
5341
5342static struct snd_kcontrol_new alc882_capture_mixer[] = {
5343 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5344 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5345 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5346 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5347 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5348 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5349 {
5350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5351 /* The multiple "Capture Source" controls confuse alsamixer
5352 * So call somewhat different..
5353 * FIXME: the controls appear in the "playback" view!
5354 */
5355 /* .name = "Capture Source", */
5356 .name = "Input Source",
5357 .count = 3,
5358 .info = alc882_mux_enum_info,
5359 .get = alc882_mux_enum_get,
5360 .put = alc882_mux_enum_put,
5361 },
5362 { } /* end */
5363};
5364
5365/* pcm configuration: identiacal with ALC880 */
5366#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5367#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5368#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5369#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5370
5371/*
5372 * configuration and preset
5373 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005374static const char *alc882_models[ALC882_MODEL_LAST] = {
5375 [ALC882_3ST_DIG] = "3stack-dig",
5376 [ALC882_6ST_DIG] = "6stack-dig",
5377 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005378 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005379 [ALC885_MACPRO] = "macpro",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005380 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005381 [ALC882_AUTO] = "auto",
5382};
5383
5384static struct snd_pci_quirk alc882_cfg_tbl[] = {
5385 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5386 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5387 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005388 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005389 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005390 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005391 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005392 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005393 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005394 {}
5395};
5396
5397static struct alc_config_preset alc882_presets[] = {
5398 [ALC882_3ST_DIG] = {
5399 .mixers = { alc882_base_mixer },
5400 .init_verbs = { alc882_init_verbs },
5401 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5402 .dac_nids = alc882_dac_nids,
5403 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005404 .dig_in_nid = ALC882_DIGIN_NID,
5405 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5406 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005407 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005408 .input_mux = &alc882_capture_source,
5409 },
5410 [ALC882_6ST_DIG] = {
5411 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5412 .init_verbs = { alc882_init_verbs },
5413 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5414 .dac_nids = alc882_dac_nids,
5415 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005416 .dig_in_nid = ALC882_DIGIN_NID,
5417 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5418 .channel_mode = alc882_sixstack_modes,
5419 .input_mux = &alc882_capture_source,
5420 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005421 [ALC882_ARIMA] = {
5422 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5423 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5424 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5425 .dac_nids = alc882_dac_nids,
5426 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5427 .channel_mode = alc882_sixstack_modes,
5428 .input_mux = &alc882_capture_source,
5429 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005430 [ALC882_W2JC] = {
5431 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5432 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5433 alc880_gpio1_init_verbs },
5434 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5435 .dac_nids = alc882_dac_nids,
5436 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5437 .channel_mode = alc880_threestack_modes,
5438 .need_dac_fix = 1,
5439 .input_mux = &alc882_capture_source,
5440 .dig_out_nid = ALC882_DIGOUT_NID,
5441 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005442 [ALC885_MACPRO] = {
5443 .mixers = { alc882_macpro_mixer },
5444 .init_verbs = { alc882_macpro_init_verbs },
5445 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5446 .dac_nids = alc882_dac_nids,
5447 .dig_out_nid = ALC882_DIGOUT_NID,
5448 .dig_in_nid = ALC882_DIGIN_NID,
5449 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5450 .channel_mode = alc882_ch_modes,
5451 .input_mux = &alc882_capture_source,
5452 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005453 [ALC885_IMAC24] = {
5454 .mixers = { alc885_imac24_mixer },
5455 .init_verbs = { alc885_imac24_init_verbs },
5456 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5457 .dac_nids = alc882_dac_nids,
5458 .dig_out_nid = ALC882_DIGOUT_NID,
5459 .dig_in_nid = ALC882_DIGIN_NID,
5460 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5461 .channel_mode = alc882_ch_modes,
5462 .input_mux = &alc882_capture_source,
5463 .unsol_event = alc885_imac24_unsol_event,
5464 .init_hook = alc885_imac24_automute,
5465 },
Kailang Yang272a5272007-05-14 11:00:38 +02005466 [ALC882_TARGA] = {
5467 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5468 alc882_capture_mixer },
5469 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5470 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5471 .dac_nids = alc882_dac_nids,
5472 .dig_out_nid = ALC882_DIGOUT_NID,
5473 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5474 .adc_nids = alc882_adc_nids,
5475 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5476 .channel_mode = alc882_3ST_6ch_modes,
5477 .need_dac_fix = 1,
5478 .input_mux = &alc882_capture_source,
5479 .unsol_event = alc882_targa_unsol_event,
5480 .init_hook = alc882_targa_automute,
5481 },
5482 [ALC882_ASUS_A7J] = {
5483 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5484 alc882_capture_mixer },
5485 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5486 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5487 .dac_nids = alc882_dac_nids,
5488 .dig_out_nid = ALC882_DIGOUT_NID,
5489 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5490 .adc_nids = alc882_adc_nids,
5491 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5492 .channel_mode = alc882_3ST_6ch_modes,
5493 .need_dac_fix = 1,
5494 .input_mux = &alc882_capture_source,
5495 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005496};
5497
5498
5499/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005500 * Pin config fixes
5501 */
5502enum {
5503 PINFIX_ABIT_AW9D_MAX
5504};
5505
5506static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5507 { 0x15, 0x01080104 }, /* side */
5508 { 0x16, 0x01011012 }, /* rear */
5509 { 0x17, 0x01016011 }, /* clfe */
5510 { }
5511};
5512
5513static const struct alc_pincfg *alc882_pin_fixes[] = {
5514 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5515};
5516
5517static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5518 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5519 {}
5520};
5521
5522/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005523 * BIOS auto configuration
5524 */
5525static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5526 hda_nid_t nid, int pin_type,
5527 int dac_idx)
5528{
5529 /* set as output */
5530 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005531 int idx;
5532
Kailang Yangdf694da2005-12-05 19:42:22 +01005533 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5534 idx = 4;
5535 else
5536 idx = spec->multiout.dac_nids[dac_idx] - 2;
5537
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005538 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5539 pin_type);
5540 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5541 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005542 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5543
5544}
5545
5546static void alc882_auto_init_multi_out(struct hda_codec *codec)
5547{
5548 struct alc_spec *spec = codec->spec;
5549 int i;
5550
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005551 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005552 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005553 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005554 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005555 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005556 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005557 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005558 }
5559}
5560
5561static void alc882_auto_init_hp_out(struct hda_codec *codec)
5562{
5563 struct alc_spec *spec = codec->spec;
5564 hda_nid_t pin;
5565
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005566 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005567 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005568 /* use dac 0 */
5569 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005570}
5571
5572#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5573#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5574
5575static void alc882_auto_init_analog_input(struct hda_codec *codec)
5576{
5577 struct alc_spec *spec = codec->spec;
5578 int i;
5579
5580 for (i = 0; i < AUTO_PIN_LAST; i++) {
5581 hda_nid_t nid = spec->autocfg.input_pins[i];
5582 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005583 snd_hda_codec_write(codec, nid, 0,
5584 AC_VERB_SET_PIN_WIDGET_CONTROL,
5585 i <= AUTO_PIN_FRONT_MIC ?
5586 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005587 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005588 snd_hda_codec_write(codec, nid, 0,
5589 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005590 AMP_OUT_MUTE);
5591 }
5592 }
5593}
5594
5595/* almost identical with ALC880 parser... */
5596static int alc882_parse_auto_config(struct hda_codec *codec)
5597{
5598 struct alc_spec *spec = codec->spec;
5599 int err = alc880_parse_auto_config(codec);
5600
5601 if (err < 0)
5602 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005603 else if (err > 0)
5604 /* hack - override the init verbs */
5605 spec->init_verbs[0] = alc882_auto_init_verbs;
5606 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005607}
5608
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005609/* additional initialization for auto-configuration model */
5610static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005611{
Kailang Yangdf694da2005-12-05 19:42:22 +01005612 alc882_auto_init_multi_out(codec);
5613 alc882_auto_init_hp_out(codec);
5614 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005615}
5616
Linus Torvalds1da177e2005-04-16 15:20:36 -07005617static int patch_alc882(struct hda_codec *codec)
5618{
5619 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005620 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005621
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005622 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005623 if (spec == NULL)
5624 return -ENOMEM;
5625
Linus Torvalds1da177e2005-04-16 15:20:36 -07005626 codec->spec = spec;
5627
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005628 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5629 alc882_models,
5630 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005631
Kailang Yangdf694da2005-12-05 19:42:22 +01005632 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005633 /* Pick up systems that don't supply PCI SSID */
5634 switch (codec->subsystem_id) {
5635 case 0x106b0c00: /* Mac Pro */
5636 board_config = ALC885_MACPRO;
5637 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005638 case 0x106b1000: /* iMac 24 */
5639 board_config = ALC885_IMAC24;
5640 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01005641 default:
5642 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5643 "trying auto-probe from BIOS...\n");
5644 board_config = ALC882_AUTO;
5645 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005646 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005647
Takashi Iwaif95474e2007-07-10 00:47:43 +02005648 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5649
Kailang Yangdf694da2005-12-05 19:42:22 +01005650 if (board_config == ALC882_AUTO) {
5651 /* automatic parse from the BIOS config */
5652 err = alc882_parse_auto_config(codec);
5653 if (err < 0) {
5654 alc_free(codec);
5655 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005656 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005657 printk(KERN_INFO
5658 "hda_codec: Cannot set up configuration "
5659 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005660 board_config = ALC882_3ST_DIG;
5661 }
5662 }
5663
5664 if (board_config != ALC882_AUTO)
5665 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005666
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005667 if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
Tobin Davis9102cd12006-12-15 10:02:12 +01005668 alc882_gpio_mute(codec, 0, 0);
5669 alc882_gpio_mute(codec, 1, 0);
5670 }
5671
Linus Torvalds1da177e2005-04-16 15:20:36 -07005672 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005673 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5674 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005675
5676 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005677 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5678 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005679
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005680 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005681 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005682 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005683 /* get type */
5684 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005685 if (wcap != AC_WID_AUD_IN) {
5686 spec->adc_nids = alc882_adc_nids_alt;
5687 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005688 spec->mixers[spec->num_mixers] =
5689 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005690 spec->num_mixers++;
5691 } else {
5692 spec->adc_nids = alc882_adc_nids;
5693 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5694 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5695 spec->num_mixers++;
5696 }
5697 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005698
5699 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005700 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005701 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005702
5703 return 0;
5704}
5705
5706/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005707 * ALC883 support
5708 *
5709 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5710 * configuration. Each pin widget can choose any input DACs and a mixer.
5711 * Each ADC is connected from a mixer of all inputs. This makes possible
5712 * 6-channel independent captures.
5713 *
5714 * In addition, an independent DAC for the multi-playback (not used in this
5715 * driver yet).
5716 */
5717#define ALC883_DIGOUT_NID 0x06
5718#define ALC883_DIGIN_NID 0x0a
5719
5720static hda_nid_t alc883_dac_nids[4] = {
5721 /* front, rear, clfe, rear_surr */
5722 0x02, 0x04, 0x03, 0x05
5723};
5724
5725static hda_nid_t alc883_adc_nids[2] = {
5726 /* ADC1-2 */
5727 0x08, 0x09,
5728};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005729
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005730/* input MUX */
5731/* FIXME: should be a matrix-type input source selection */
5732
5733static struct hda_input_mux alc883_capture_source = {
5734 .num_items = 4,
5735 .items = {
5736 { "Mic", 0x0 },
5737 { "Front Mic", 0x1 },
5738 { "Line", 0x2 },
5739 { "CD", 0x4 },
5740 },
5741};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005742
5743static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5744 .num_items = 2,
5745 .items = {
5746 { "Mic", 0x1 },
5747 { "Line", 0x2 },
5748 },
5749};
5750
Kailang Yang272a5272007-05-14 11:00:38 +02005751static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5752 .num_items = 4,
5753 .items = {
5754 { "Mic", 0x0 },
5755 { "iMic", 0x1 },
5756 { "Line", 0x2 },
5757 { "CD", 0x4 },
5758 },
5759};
5760
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005761#define alc883_mux_enum_info alc_mux_enum_info
5762#define alc883_mux_enum_get alc_mux_enum_get
5763
5764static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5765 struct snd_ctl_elem_value *ucontrol)
5766{
5767 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5768 struct alc_spec *spec = codec->spec;
5769 const struct hda_input_mux *imux = spec->input_mux;
5770 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5771 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5772 hda_nid_t nid = capture_mixers[adc_idx];
5773 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5774 unsigned int i, idx;
5775
5776 idx = ucontrol->value.enumerated.item[0];
5777 if (idx >= imux->num_items)
5778 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005779 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005780 return 0;
5781 for (i = 0; i < imux->num_items; i++) {
5782 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5783 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5784 v | (imux->items[i].index << 8));
5785 }
5786 *cur_val = idx;
5787 return 1;
5788}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005789
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005790/*
5791 * 2ch mode
5792 */
5793static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5794 { 2, NULL }
5795};
5796
5797/*
5798 * 2ch mode
5799 */
5800static struct hda_verb alc883_3ST_ch2_init[] = {
5801 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5802 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5803 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5804 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5805 { } /* end */
5806};
5807
5808/*
5809 * 6ch mode
5810 */
5811static struct hda_verb alc883_3ST_ch6_init[] = {
5812 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5813 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5814 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5815 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5816 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5817 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5818 { } /* end */
5819};
5820
5821static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5822 { 2, alc883_3ST_ch2_init },
5823 { 6, alc883_3ST_ch6_init },
5824};
5825
5826/*
5827 * 6ch mode
5828 */
5829static struct hda_verb alc883_sixstack_ch6_init[] = {
5830 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5831 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5832 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5833 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5834 { } /* end */
5835};
5836
5837/*
5838 * 8ch mode
5839 */
5840static struct hda_verb alc883_sixstack_ch8_init[] = {
5841 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5842 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5843 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5844 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5845 { } /* end */
5846};
5847
5848static struct hda_channel_mode alc883_sixstack_modes[2] = {
5849 { 6, alc883_sixstack_ch6_init },
5850 { 8, alc883_sixstack_ch8_init },
5851};
5852
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005853static struct hda_verb alc883_medion_eapd_verbs[] = {
5854 /* eanable EAPD on medion laptop */
5855 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5856 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5857 { }
5858};
5859
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005860/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5861 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5862 */
5863
5864static struct snd_kcontrol_new alc883_base_mixer[] = {
5865 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5866 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5867 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5868 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5869 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5870 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5871 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5872 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5873 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5874 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5875 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5876 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5877 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5878 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5879 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005881 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005882 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5883 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005884 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005885 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5886 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5887 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5888 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5889 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5890 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5891 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5892 {
5893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5894 /* .name = "Capture Source", */
5895 .name = "Input Source",
5896 .count = 2,
5897 .info = alc883_mux_enum_info,
5898 .get = alc883_mux_enum_get,
5899 .put = alc883_mux_enum_put,
5900 },
5901 { } /* end */
5902};
5903
5904static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5905 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5906 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5907 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5908 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5909 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005913 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5915 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005916 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5918 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5919 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5920 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5921 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5922 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5923 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5924 {
5925 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5926 /* .name = "Capture Source", */
5927 .name = "Input Source",
5928 .count = 2,
5929 .info = alc883_mux_enum_info,
5930 .get = alc883_mux_enum_get,
5931 .put = alc883_mux_enum_put,
5932 },
5933 { } /* end */
5934};
5935
5936static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5937 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5938 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5939 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5940 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5941 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5942 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5943 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5944 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5948 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5949 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5950 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005951 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005954 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005955 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5956 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5957 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5958 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5959 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5960 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5961 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5962 {
5963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5964 /* .name = "Capture Source", */
5965 .name = "Input Source",
5966 .count = 2,
5967 .info = alc883_mux_enum_info,
5968 .get = alc883_mux_enum_get,
5969 .put = alc883_mux_enum_put,
5970 },
5971 { } /* end */
5972};
5973
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005974static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005975 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5976 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5977 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5978 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5979 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5980 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5981 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5982 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005989 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5991 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005992 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005993 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5994 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5995 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5996 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5997 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5998
5999 {
6000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6001 /* .name = "Capture Source", */
6002 .name = "Input Source",
6003 .count = 1,
6004 .info = alc883_mux_enum_info,
6005 .get = alc883_mux_enum_get,
6006 .put = alc883_mux_enum_put,
6007 },
6008 { } /* end */
6009};
6010
Kailang Yangccc656c2006-10-17 12:32:26 +02006011static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6014 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6015 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6016 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6017 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6018 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6019 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6020 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6021 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6022 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006026 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006027 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6028 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6029 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6030 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6031 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6032 {
6033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6034 /* .name = "Capture Source", */
6035 .name = "Input Source",
6036 .count = 2,
6037 .info = alc883_mux_enum_info,
6038 .get = alc883_mux_enum_get,
6039 .put = alc883_mux_enum_put,
6040 },
6041 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006042};
Kailang Yangccc656c2006-10-17 12:32:26 +02006043
6044static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6047 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006051 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006052 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, 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 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006067};
Kailang Yangccc656c2006-10-17 12:32:26 +02006068
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006069static struct snd_kcontrol_new alc883_lenovo_101e_2ch_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("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6073 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6074 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6078 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6079 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6080 {
6081 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6082 /* .name = "Capture Source", */
6083 .name = "Input Source",
6084 .count = 1,
6085 .info = alc883_mux_enum_info,
6086 .get = alc883_mux_enum_get,
6087 .put = alc883_mux_enum_put,
6088 },
6089 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006090};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006091
Kailang Yang272a5272007-05-14 11:00:38 +02006092static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6093 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6094 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6096 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6097 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6100 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6101 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6102 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6103 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6104 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6105 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6106 {
6107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6108 /* .name = "Capture Source", */
6109 .name = "Input Source",
6110 .count = 2,
6111 .info = alc883_mux_enum_info,
6112 .get = alc883_mux_enum_get,
6113 .put = alc883_mux_enum_put,
6114 },
6115 { } /* end */
6116};
6117
6118static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6121 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6126 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6127 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6128 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6129 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6130 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6131 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6132 {
6133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6134 /* .name = "Capture Source", */
6135 .name = "Input Source",
6136 .count = 2,
6137 .info = alc883_mux_enum_info,
6138 .get = alc883_mux_enum_get,
6139 .put = alc883_mux_enum_put,
6140 },
6141 { } /* end */
6142};
6143
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006144static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6146 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6147 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6148 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6149 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6150 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6151 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6153 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6154 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6155 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6156 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6157 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6158 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6159 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6161 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6162 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6163 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6164 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6165 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6166 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6167 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6168 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6169 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6170 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6171 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6172 {
6173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6174 /* .name = "Capture Source", */
6175 .name = "Input Source",
6176 .count = 2,
6177 .info = alc883_mux_enum_info,
6178 .get = alc883_mux_enum_get,
6179 .put = alc883_mux_enum_put,
6180 },
6181 { } /* end */
6182};
6183
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006184static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006185 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6186 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6187 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6188 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6189 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6191 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6192 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6193 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6194 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6195 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6199 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6201 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6202 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6204 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6205 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6206 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6207 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6208 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6209 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6210 {
6211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6212 /* .name = "Capture Source", */
6213 .name = "Input Source",
6214 .count = 2,
6215 .info = alc883_mux_enum_info,
6216 .get = alc883_mux_enum_get,
6217 .put = alc883_mux_enum_put,
6218 },
6219 { } /* end */
6220};
6221
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006222static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6223 {
6224 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6225 .name = "Channel Mode",
6226 .info = alc_ch_mode_info,
6227 .get = alc_ch_mode_get,
6228 .put = alc_ch_mode_put,
6229 },
6230 { } /* end */
6231};
6232
6233static struct hda_verb alc883_init_verbs[] = {
6234 /* ADC1: mute amp left and right */
6235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6236 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6237 /* ADC2: mute amp left and right */
6238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6239 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6240 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6244 /* Rear mixer */
6245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6248 /* CLFE mixer */
6249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6252 /* Side mixer */
6253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6255 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6256
6257 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6262
6263 /* Front Pin: output 0 (0x0c) */
6264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6265 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6266 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6267 /* Rear Pin: output 1 (0x0d) */
6268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6271 /* CLFE Pin: output 2 (0x0e) */
6272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6274 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6275 /* Side Pin: output 3 (0x0f) */
6276 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6278 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6279 /* Mic (rear) pin: input vref at 80% */
6280 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6281 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6282 /* Front Mic pin: input vref at 80% */
6283 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6284 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6285 /* Line In pin: input */
6286 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6287 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6288 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6289 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6290 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6291 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6292 /* CD pin widget for input */
6293 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6294
6295 /* FIXME: use matrix-type input source selection */
6296 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6297 /* Input mixer2 */
6298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6301 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6302 /* Input mixer3 */
6303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6307 { }
6308};
6309
Kailang Yangccc656c2006-10-17 12:32:26 +02006310static struct hda_verb alc883_tagra_verbs[] = {
6311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6313
6314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6315 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6316
6317 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6318 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6319 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6320
6321 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006322 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6323 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6324 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006325
6326 { } /* end */
6327};
6328
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006329static struct hda_verb alc883_lenovo_101e_verbs[] = {
6330 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6331 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6332 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6333 { } /* end */
6334};
6335
Kailang Yang272a5272007-05-14 11:00:38 +02006336static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6339 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6341 { } /* end */
6342};
6343
6344static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6347 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6349 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6350 { } /* end */
6351};
6352
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006353static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006354 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6356 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6357 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6358 { }
6359};
6360
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006361static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006362 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6363 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6364 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6365 { }
6366};
6367
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006368static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006369 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6370 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6371 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6372 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6373 { }
6374};
6375
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006376static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006377 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6378 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6379 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6380 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6381 { }
6382};
6383
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006384static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6385 { 2, alc888_3st_hp_2ch_init },
6386 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006387};
6388
Kailang Yang272a5272007-05-14 11:00:38 +02006389/* toggle front-jack and RCA according to the hp-jack state */
6390static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6391{
6392 unsigned int present;
6393
6394 present = snd_hda_codec_read(codec, 0x1b, 0,
6395 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6396 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6397 0x80, present ? 0x80 : 0);
6398 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6399 0x80, present ? 0x80 : 0);
6400 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6401 0x80, present ? 0x80 : 0);
6402 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6403 0x80, present ? 0x80 : 0);
6404
6405}
6406
6407/* toggle RCA according to the front-jack state */
6408static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6409{
6410 unsigned int present;
6411
6412 present = snd_hda_codec_read(codec, 0x14, 0,
6413 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6414 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6415 0x80, present ? 0x80 : 0);
6416 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6417 0x80, present ? 0x80 : 0);
6418
6419}
6420static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6421 unsigned int res)
6422{
6423 if ((res >> 26) == ALC880_HP_EVENT)
6424 alc888_lenovo_ms7195_front_automute(codec);
6425 if ((res >> 26) == ALC880_FRONT_EVENT)
6426 alc888_lenovo_ms7195_rca_automute(codec);
6427}
6428
6429static struct hda_verb alc883_medion_md2_verbs[] = {
6430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6432
6433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6434
6435 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6436 { } /* end */
6437};
6438
6439/* toggle speaker-output according to the hp-jack state */
6440static void alc883_medion_md2_automute(struct hda_codec *codec)
6441{
6442 unsigned int present;
6443
6444 present = snd_hda_codec_read(codec, 0x14, 0,
6445 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6446 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6447 0x80, present ? 0x80 : 0);
6448 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6449 0x80, present ? 0x80 : 0);
6450}
6451
6452static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6453 unsigned int res)
6454{
6455 if ((res >> 26) == ALC880_HP_EVENT)
6456 alc883_medion_md2_automute(codec);
6457}
6458
Kailang Yangccc656c2006-10-17 12:32:26 +02006459/* toggle speaker-output according to the hp-jack state */
6460static void alc883_tagra_automute(struct hda_codec *codec)
6461{
6462 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006463 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006464
6465 present = snd_hda_codec_read(codec, 0x14, 0,
6466 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006467 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006468 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006469 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006470 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006471 0x80, bits);
6472 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6473 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006474}
6475
6476static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6477{
6478 if ((res >> 26) == ALC880_HP_EVENT)
6479 alc883_tagra_automute(codec);
6480}
6481
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006482static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6483{
6484 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006485 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006486
6487 present = snd_hda_codec_read(codec, 0x14, 0,
6488 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006489 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006490 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006491 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006492 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006493 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006494}
6495
6496static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6497{
6498 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006499 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006500
6501 present = snd_hda_codec_read(codec, 0x1b, 0,
6502 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006503 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006504 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006505 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006506 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006507 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006508 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006509 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006510 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006511 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006512}
6513
6514static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6515 unsigned int res)
6516{
6517 if ((res >> 26) == ALC880_HP_EVENT)
6518 alc883_lenovo_101e_all_automute(codec);
6519 if ((res >> 26) == ALC880_FRONT_EVENT)
6520 alc883_lenovo_101e_ispeaker_automute(codec);
6521}
6522
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006523/*
6524 * generic initialization of ADC, input mixers and output mixers
6525 */
6526static struct hda_verb alc883_auto_init_verbs[] = {
6527 /*
6528 * Unmute ADC0-2 and set the default input to mic-in
6529 */
6530 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6532 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6533 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6534
6535 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6536 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006537 * Note: PASD motherboards uses the Line In 2 as the input for
6538 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006539 */
6540 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6546
6547 /*
6548 * Set up output mixers (0x0c - 0x0f)
6549 */
6550 /* set vol=0 to output mixers */
6551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6552 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6553 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6554 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6555 /* set up input amps for analog loopback */
6556 /* Amp Indices: DAC = 0, mixer = 1 */
6557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6559 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6560 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6561 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6562 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6563 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6564 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6565 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6566 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6567
6568 /* FIXME: use matrix-type input source selection */
6569 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6570 /* Input mixer1 */
6571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006574 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6576 /* Input mixer2 */
6577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006580 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006581 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6582
6583 { }
6584};
6585
6586/* capture mixer elements */
6587static struct snd_kcontrol_new alc883_capture_mixer[] = {
6588 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6589 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6590 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6591 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6592 {
6593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6594 /* The multiple "Capture Source" controls confuse alsamixer
6595 * So call somewhat different..
6596 * FIXME: the controls appear in the "playback" view!
6597 */
6598 /* .name = "Capture Source", */
6599 .name = "Input Source",
6600 .count = 2,
6601 .info = alc882_mux_enum_info,
6602 .get = alc882_mux_enum_get,
6603 .put = alc882_mux_enum_put,
6604 },
6605 { } /* end */
6606};
6607
6608/* pcm configuration: identiacal with ALC880 */
6609#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6610#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6611#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6612#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6613
6614/*
6615 * configuration and preset
6616 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006617static const char *alc883_models[ALC883_MODEL_LAST] = {
6618 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6619 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6620 [ALC883_3ST_6ch] = "3stack-6ch",
6621 [ALC883_6ST_DIG] = "6stack-dig",
6622 [ALC883_TARGA_DIG] = "targa-dig",
6623 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006624 [ALC883_ACER] = "acer",
6625 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006626 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006627 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006628 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006629 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6630 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006631 [ALC888_6ST_HP] = "6stack-hp",
6632 [ALC888_3ST_HP] = "3stack-hp",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006633 [ALC883_AUTO] = "auto",
6634};
6635
6636static struct snd_pci_quirk alc883_cfg_tbl[] = {
6637 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006638 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006639 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6640 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6641 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006642 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006643 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6644 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006645 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006646 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02006647 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006648 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006649 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006650 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006651 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6652 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6653 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6654 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6655 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6656 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6657 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6658 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6659 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6660 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006661 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006662 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6663 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6664 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006665 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6666 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6667 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006668 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6669 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6670 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
Kailang Yang272a5272007-05-14 11:00:38 +02006671 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006672 {}
6673};
6674
6675static struct alc_config_preset alc883_presets[] = {
6676 [ALC883_3ST_2ch_DIG] = {
6677 .mixers = { alc883_3ST_2ch_mixer },
6678 .init_verbs = { alc883_init_verbs },
6679 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6680 .dac_nids = alc883_dac_nids,
6681 .dig_out_nid = ALC883_DIGOUT_NID,
6682 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6683 .adc_nids = alc883_adc_nids,
6684 .dig_in_nid = ALC883_DIGIN_NID,
6685 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6686 .channel_mode = alc883_3ST_2ch_modes,
6687 .input_mux = &alc883_capture_source,
6688 },
6689 [ALC883_3ST_6ch_DIG] = {
6690 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6691 .init_verbs = { alc883_init_verbs },
6692 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6693 .dac_nids = alc883_dac_nids,
6694 .dig_out_nid = ALC883_DIGOUT_NID,
6695 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6696 .adc_nids = alc883_adc_nids,
6697 .dig_in_nid = ALC883_DIGIN_NID,
6698 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6699 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006700 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006701 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006702 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006703 [ALC883_3ST_6ch] = {
6704 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6705 .init_verbs = { alc883_init_verbs },
6706 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6707 .dac_nids = alc883_dac_nids,
6708 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6709 .adc_nids = alc883_adc_nids,
6710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6711 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006712 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006713 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006714 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006715 [ALC883_6ST_DIG] = {
6716 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6717 .init_verbs = { alc883_init_verbs },
6718 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6719 .dac_nids = alc883_dac_nids,
6720 .dig_out_nid = ALC883_DIGOUT_NID,
6721 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6722 .adc_nids = alc883_adc_nids,
6723 .dig_in_nid = ALC883_DIGIN_NID,
6724 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6725 .channel_mode = alc883_sixstack_modes,
6726 .input_mux = &alc883_capture_source,
6727 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006728 [ALC883_TARGA_DIG] = {
6729 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6730 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6731 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6732 .dac_nids = alc883_dac_nids,
6733 .dig_out_nid = ALC883_DIGOUT_NID,
6734 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6735 .adc_nids = alc883_adc_nids,
6736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6737 .channel_mode = alc883_3ST_6ch_modes,
6738 .need_dac_fix = 1,
6739 .input_mux = &alc883_capture_source,
6740 .unsol_event = alc883_tagra_unsol_event,
6741 .init_hook = alc883_tagra_automute,
6742 },
6743 [ALC883_TARGA_2ch_DIG] = {
6744 .mixers = { alc883_tagra_2ch_mixer},
6745 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6746 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6747 .dac_nids = alc883_dac_nids,
6748 .dig_out_nid = ALC883_DIGOUT_NID,
6749 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6750 .adc_nids = alc883_adc_nids,
6751 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6752 .channel_mode = alc883_3ST_2ch_modes,
6753 .input_mux = &alc883_capture_source,
6754 .unsol_event = alc883_tagra_unsol_event,
6755 .init_hook = alc883_tagra_automute,
6756 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02006757 [ALC883_ACER] = {
6758 .mixers = { alc883_base_mixer,
6759 alc883_chmode_mixer },
6760 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6761 * and the headphone jack. Turn this on and rely on the
6762 * standard mute methods whenever the user wants to turn
6763 * these outputs off.
6764 */
6765 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6766 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6767 .dac_nids = alc883_dac_nids,
6768 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6769 .adc_nids = alc883_adc_nids,
6770 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6771 .channel_mode = alc883_3ST_2ch_modes,
6772 .input_mux = &alc883_capture_source,
6773 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006774 [ALC883_MEDION] = {
6775 .mixers = { alc883_fivestack_mixer,
6776 alc883_chmode_mixer },
6777 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006778 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006779 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6780 .dac_nids = alc883_dac_nids,
6781 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6782 .adc_nids = alc883_adc_nids,
6783 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6784 .channel_mode = alc883_sixstack_modes,
6785 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006786 },
Kailang Yang272a5272007-05-14 11:00:38 +02006787 [ALC883_MEDION_MD2] = {
6788 .mixers = { alc883_medion_md2_mixer},
6789 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6790 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6791 .dac_nids = alc883_dac_nids,
6792 .dig_out_nid = ALC883_DIGOUT_NID,
6793 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6794 .adc_nids = alc883_adc_nids,
6795 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6796 .channel_mode = alc883_3ST_2ch_modes,
6797 .input_mux = &alc883_capture_source,
6798 .unsol_event = alc883_medion_md2_unsol_event,
6799 .init_hook = alc883_medion_md2_automute,
6800 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006801 [ALC883_LAPTOP_EAPD] = {
6802 .mixers = { alc883_base_mixer,
6803 alc883_chmode_mixer },
6804 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6805 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6806 .dac_nids = alc883_dac_nids,
6807 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6808 .adc_nids = alc883_adc_nids,
6809 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6810 .channel_mode = alc883_3ST_2ch_modes,
6811 .input_mux = &alc883_capture_source,
6812 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006813 [ALC883_LENOVO_101E_2ch] = {
6814 .mixers = { alc883_lenovo_101e_2ch_mixer},
6815 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6816 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6817 .dac_nids = alc883_dac_nids,
6818 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6819 .adc_nids = alc883_adc_nids,
6820 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6821 .channel_mode = alc883_3ST_2ch_modes,
6822 .input_mux = &alc883_lenovo_101e_capture_source,
6823 .unsol_event = alc883_lenovo_101e_unsol_event,
6824 .init_hook = alc883_lenovo_101e_all_automute,
6825 },
Kailang Yang272a5272007-05-14 11:00:38 +02006826 [ALC883_LENOVO_NB0763] = {
6827 .mixers = { alc883_lenovo_nb0763_mixer },
6828 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6829 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6830 .dac_nids = alc883_dac_nids,
6831 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6832 .adc_nids = alc883_adc_nids,
6833 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6834 .channel_mode = alc883_3ST_2ch_modes,
6835 .need_dac_fix = 1,
6836 .input_mux = &alc883_lenovo_nb0763_capture_source,
6837 .unsol_event = alc883_medion_md2_unsol_event,
6838 .init_hook = alc883_medion_md2_automute,
6839 },
6840 [ALC888_LENOVO_MS7195_DIG] = {
6841 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6842 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6843 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6844 .dac_nids = alc883_dac_nids,
6845 .dig_out_nid = ALC883_DIGOUT_NID,
6846 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6847 .adc_nids = alc883_adc_nids,
6848 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6849 .channel_mode = alc883_3ST_6ch_modes,
6850 .need_dac_fix = 1,
6851 .input_mux = &alc883_capture_source,
6852 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6853 .init_hook = alc888_lenovo_ms7195_front_automute,
6854 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006855 [ALC888_6ST_HP] = {
6856 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6857 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6859 .dac_nids = alc883_dac_nids,
6860 .dig_out_nid = ALC883_DIGOUT_NID,
6861 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6862 .adc_nids = alc883_adc_nids,
6863 .dig_in_nid = ALC883_DIGIN_NID,
6864 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6865 .channel_mode = alc883_sixstack_modes,
6866 .input_mux = &alc883_capture_source,
6867 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006868 [ALC888_3ST_HP] = {
6869 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6870 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006871 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6872 .dac_nids = alc883_dac_nids,
6873 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6874 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006875 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6876 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006877 .need_dac_fix = 1,
6878 .input_mux = &alc883_capture_source,
6879 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006880};
6881
6882
6883/*
6884 * BIOS auto configuration
6885 */
6886static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6887 hda_nid_t nid, int pin_type,
6888 int dac_idx)
6889{
6890 /* set as output */
6891 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006892 int idx;
6893
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006894 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6895 idx = 4;
6896 else
6897 idx = spec->multiout.dac_nids[dac_idx] - 2;
6898
6899 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6900 pin_type);
6901 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6902 AMP_OUT_UNMUTE);
6903 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6904
6905}
6906
6907static void alc883_auto_init_multi_out(struct hda_codec *codec)
6908{
6909 struct alc_spec *spec = codec->spec;
6910 int i;
6911
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006912 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006913 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006914 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006915 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006916 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006917 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006918 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006919 }
6920}
6921
6922static void alc883_auto_init_hp_out(struct hda_codec *codec)
6923{
6924 struct alc_spec *spec = codec->spec;
6925 hda_nid_t pin;
6926
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006927 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006928 if (pin) /* connect to front */
6929 /* use dac 0 */
6930 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6931}
6932
6933#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6934#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6935
6936static void alc883_auto_init_analog_input(struct hda_codec *codec)
6937{
6938 struct alc_spec *spec = codec->spec;
6939 int i;
6940
6941 for (i = 0; i < AUTO_PIN_LAST; i++) {
6942 hda_nid_t nid = spec->autocfg.input_pins[i];
6943 if (alc883_is_input_pin(nid)) {
6944 snd_hda_codec_write(codec, nid, 0,
6945 AC_VERB_SET_PIN_WIDGET_CONTROL,
6946 (i <= AUTO_PIN_FRONT_MIC ?
6947 PIN_VREF80 : PIN_IN));
6948 if (nid != ALC883_PIN_CD_NID)
6949 snd_hda_codec_write(codec, nid, 0,
6950 AC_VERB_SET_AMP_GAIN_MUTE,
6951 AMP_OUT_MUTE);
6952 }
6953 }
6954}
6955
6956/* almost identical with ALC880 parser... */
6957static int alc883_parse_auto_config(struct hda_codec *codec)
6958{
6959 struct alc_spec *spec = codec->spec;
6960 int err = alc880_parse_auto_config(codec);
6961
6962 if (err < 0)
6963 return err;
6964 else if (err > 0)
6965 /* hack - override the init verbs */
6966 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006967 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6968 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006969 return err;
6970}
6971
6972/* additional initialization for auto-configuration model */
6973static void alc883_auto_init(struct hda_codec *codec)
6974{
6975 alc883_auto_init_multi_out(codec);
6976 alc883_auto_init_hp_out(codec);
6977 alc883_auto_init_analog_input(codec);
6978}
6979
6980static int patch_alc883(struct hda_codec *codec)
6981{
6982 struct alc_spec *spec;
6983 int err, board_config;
6984
6985 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6986 if (spec == NULL)
6987 return -ENOMEM;
6988
6989 codec->spec = spec;
6990
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006991 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6992 alc883_models,
6993 alc883_cfg_tbl);
6994 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006995 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6996 "trying auto-probe from BIOS...\n");
6997 board_config = ALC883_AUTO;
6998 }
6999
7000 if (board_config == ALC883_AUTO) {
7001 /* automatic parse from the BIOS config */
7002 err = alc883_parse_auto_config(codec);
7003 if (err < 0) {
7004 alc_free(codec);
7005 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007006 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007007 printk(KERN_INFO
7008 "hda_codec: Cannot set up configuration "
7009 "from BIOS. Using base mode...\n");
7010 board_config = ALC883_3ST_2ch_DIG;
7011 }
7012 }
7013
7014 if (board_config != ALC883_AUTO)
7015 setup_preset(spec, &alc883_presets[board_config]);
7016
7017 spec->stream_name_analog = "ALC883 Analog";
7018 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7019 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7020
7021 spec->stream_name_digital = "ALC883 Digital";
7022 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7023 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7024
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007025 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007026 spec->adc_nids = alc883_adc_nids;
7027 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7028 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007029
7030 codec->patch_ops = alc_patch_ops;
7031 if (board_config == ALC883_AUTO)
7032 spec->init_hook = alc883_auto_init;
7033
7034 return 0;
7035}
7036
7037/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007038 * ALC262 support
7039 */
7040
7041#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7042#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7043
7044#define alc262_dac_nids alc260_dac_nids
7045#define alc262_adc_nids alc882_adc_nids
7046#define alc262_adc_nids_alt alc882_adc_nids_alt
7047
7048#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007049#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007050
7051static struct snd_kcontrol_new alc262_base_mixer[] = {
7052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7053 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007060 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007063 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007064 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7065 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7066 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7068 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7069 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007070 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007071};
7072
Kailang Yangccc656c2006-10-17 12:32:26 +02007073static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7074 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7075 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7076 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7077 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7078 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7079 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007083 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7084 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007085 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007086 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7087 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7088 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7090 { } /* end */
7091};
7092
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007093static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7094 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7095 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7097 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7098 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7099
7100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007102 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007103 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007105 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7110 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7111 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7112 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7113 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7114 { } /* end */
7115};
7116
Kailang Yangcd7509a2007-01-26 18:33:17 +01007117static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7118 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7119 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7120 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7122 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7123 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007126 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7131 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7132 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7133 { } /* end */
7134};
7135
7136static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7137 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7138 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007139 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007140 { } /* end */
7141};
7142
Takashi Iwai5b319542007-07-26 11:49:22 +02007143static int alc262_sony_sw_put(struct snd_kcontrol *kcontrol,
7144 struct snd_ctl_elem_value *ucontrol)
7145{
7146 unsigned long private_save = kcontrol->private_value;
7147 int change;
7148 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT);
7149 change = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
7150 kcontrol->private_value = private_save;
7151 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
7152 return change;
7153}
7154
Kailang Yang272a5272007-05-14 11:00:38 +02007155static struct snd_kcontrol_new alc262_sony_mixer[] = {
7156 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai5b319542007-07-26 11:49:22 +02007157 {
7158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7159 .name = "Front Playback Switch",
7160 .info = snd_hda_mixer_amp_switch_info,
7161 .get = snd_hda_mixer_amp_switch_get,
7162 .put = alc262_sony_sw_put,
7163 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7164 },
Kailang Yang272a5272007-05-14 11:00:38 +02007165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7167 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7168 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7169 { } /* end */
7170};
7171
Kailang Yang83c34212007-07-05 11:43:05 +02007172static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7174 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7178 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7179 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7180 { } /* end */
7181};
Kailang Yang272a5272007-05-14 11:00:38 +02007182
Kailang Yangdf694da2005-12-05 19:42:22 +01007183#define alc262_capture_mixer alc882_capture_mixer
7184#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7185
7186/*
7187 * generic initialization of ADC, input mixers and output mixers
7188 */
7189static struct hda_verb alc262_init_verbs[] = {
7190 /*
7191 * Unmute ADC0-2 and set the default input to mic-in
7192 */
7193 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7195 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7197 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7198 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7199
7200 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7201 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007202 * Note: PASD motherboards uses the Line In 2 as the input for
7203 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007204 */
7205 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7211
7212 /*
7213 * Set up output mixers (0x0c - 0x0e)
7214 */
7215 /* set vol=0 to output mixers */
7216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7218 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7219 /* set up input amps for analog loopback */
7220 /* Amp Indices: DAC = 0, mixer = 1 */
7221 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7225 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7226 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7227
7228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7230 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7231 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7232 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7233 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7234
7235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7237 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7238 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7240
7241 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7242 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7243
7244 /* FIXME: use matrix-type input source selection */
7245 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7246 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7249 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7251 /* Input mixer2 */
7252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7253 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7256 /* Input mixer3 */
7257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007261
7262 { }
7263};
7264
Kailang Yangccc656c2006-10-17 12:32:26 +02007265static struct hda_verb alc262_hippo_unsol_verbs[] = {
7266 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7268 {}
7269};
7270
7271static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7273 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7275
7276 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7278 {}
7279};
7280
Kailang Yang272a5272007-05-14 11:00:38 +02007281static struct hda_verb alc262_sony_unsol_verbs[] = {
7282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7284 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7285
7286 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7288};
7289
Kailang Yangccc656c2006-10-17 12:32:26 +02007290/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02007291static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007292{
7293 struct alc_spec *spec = codec->spec;
7294 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007295 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007296
Takashi Iwai5b319542007-07-26 11:49:22 +02007297 /* need to execute and sync at first */
7298 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7299 present = snd_hda_codec_read(codec, 0x15, 0,
7300 AC_VERB_GET_PIN_SENSE, 0);
7301 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02007302 if (spec->jack_present) {
7303 /* mute internal speaker */
7304 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7305 0x80, 0x80);
7306 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7307 0x80, 0x80);
7308 } else {
7309 /* unmute internal speaker if necessary */
7310 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7311 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7312 0x80, mute & 0x80);
7313 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7314 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7315 0x80, mute & 0x80);
7316 }
7317}
7318
7319/* unsolicited event for HP jack sensing */
7320static void alc262_hippo_unsol_event(struct hda_codec *codec,
7321 unsigned int res)
7322{
7323 if ((res >> 26) != ALC880_HP_EVENT)
7324 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007325 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007326}
7327
Takashi Iwai5b319542007-07-26 11:49:22 +02007328static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007329{
Kailang Yangccc656c2006-10-17 12:32:26 +02007330 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007331 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007332
Takashi Iwai5b319542007-07-26 11:49:22 +02007333 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7334 present = snd_hda_codec_read(codec, 0x1b, 0,
7335 AC_VERB_GET_PIN_SENSE, 0);
7336 present = (present & 0x80000000) != 0;
7337 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007338 /* mute internal speaker */
7339 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7340 0x80, 0x80);
7341 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7342 0x80, 0x80);
7343 } else {
7344 /* unmute internal speaker if necessary */
7345 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7346 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7347 0x80, mute & 0x80);
7348 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7349 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7350 0x80, mute & 0x80);
7351 }
7352}
7353
7354/* unsolicited event for HP jack sensing */
7355static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7356 unsigned int res)
7357{
7358 if ((res >> 26) != ALC880_HP_EVENT)
7359 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007360 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007361}
7362
Takashi Iwai834be882006-03-01 14:16:17 +01007363/*
7364 * fujitsu model
7365 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7366 */
7367
7368#define ALC_HP_EVENT 0x37
7369
7370static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7371 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7373 {}
7374};
7375
7376static struct hda_input_mux alc262_fujitsu_capture_source = {
7377 .num_items = 2,
7378 .items = {
7379 { "Mic", 0x0 },
7380 { "CD", 0x4 },
7381 },
7382};
7383
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007384static struct hda_input_mux alc262_HP_capture_source = {
7385 .num_items = 5,
7386 .items = {
7387 { "Mic", 0x0 },
7388 { "Front Mic", 0x3 },
7389 { "Line", 0x2 },
7390 { "CD", 0x4 },
7391 { "AUX IN", 0x6 },
7392 },
7393};
7394
Takashi Iwai834be882006-03-01 14:16:17 +01007395/* mute/unmute internal speaker according to the hp jack and mute state */
7396static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7397{
7398 struct alc_spec *spec = codec->spec;
7399 unsigned int mute;
7400
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007401 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007402 unsigned int present;
7403 /* need to execute and sync at first */
7404 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7405 present = snd_hda_codec_read(codec, 0x14, 0,
7406 AC_VERB_GET_PIN_SENSE, 0);
7407 spec->jack_present = (present & 0x80000000) != 0;
7408 spec->sense_updated = 1;
7409 }
7410 if (spec->jack_present) {
7411 /* mute internal speaker */
7412 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7413 0x80, 0x80);
7414 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7415 0x80, 0x80);
7416 } else {
7417 /* unmute internal speaker if necessary */
7418 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7419 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7420 0x80, mute & 0x80);
7421 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7422 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7423 0x80, mute & 0x80);
7424 }
7425}
7426
7427/* unsolicited event for HP jack sensing */
7428static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7429 unsigned int res)
7430{
7431 if ((res >> 26) != ALC_HP_EVENT)
7432 return;
7433 alc262_fujitsu_automute(codec, 1);
7434}
7435
7436/* bind volumes of both NID 0x0c and 0x0d */
7437static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7438 struct snd_ctl_elem_value *ucontrol)
7439{
7440 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7441 long *valp = ucontrol->value.integer.value;
7442 int change;
7443
7444 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7445 0x7f, valp[0] & 0x7f);
7446 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7447 0x7f, valp[1] & 0x7f);
7448 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7449 0x7f, valp[0] & 0x7f);
7450 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7451 0x7f, valp[1] & 0x7f);
7452 return change;
7453}
7454
7455/* bind hp and internal speaker mute (with plug check) */
7456static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7457 struct snd_ctl_elem_value *ucontrol)
7458{
7459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7460 long *valp = ucontrol->value.integer.value;
7461 int change;
7462
7463 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7464 0x80, valp[0] ? 0 : 0x80);
7465 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7466 0x80, valp[1] ? 0 : 0x80);
7467 if (change || codec->in_resume)
7468 alc262_fujitsu_automute(codec, codec->in_resume);
7469 return change;
7470}
7471
7472static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7473 {
7474 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7475 .name = "Master Playback Volume",
7476 .info = snd_hda_mixer_amp_volume_info,
7477 .get = snd_hda_mixer_amp_volume_get,
7478 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007479 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007480 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7481 },
7482 {
7483 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7484 .name = "Master Playback Switch",
7485 .info = snd_hda_mixer_amp_switch_info,
7486 .get = snd_hda_mixer_amp_switch_get,
7487 .put = alc262_fujitsu_master_sw_put,
7488 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7489 },
7490 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7491 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7492 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7493 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7494 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7495 { } /* end */
7496};
7497
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007498/* additional init verbs for Benq laptops */
7499static struct hda_verb alc262_EAPD_verbs[] = {
7500 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7501 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7502 {}
7503};
7504
Kailang Yang83c34212007-07-05 11:43:05 +02007505static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7508
7509 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7510 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7511 {}
7512};
7513
Kailang Yangdf694da2005-12-05 19:42:22 +01007514/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007515static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7516 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007517{
7518 hda_nid_t nid;
7519 int err;
7520
7521 spec->multiout.num_dacs = 1; /* only use one dac */
7522 spec->multiout.dac_nids = spec->private_dac_nids;
7523 spec->multiout.dac_nids[0] = 2;
7524
7525 nid = cfg->line_out_pins[0];
7526 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007527 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7528 "Front Playback Volume",
7529 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7530 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007531 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007532 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7533 "Front Playback Switch",
7534 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7535 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007536 return err;
7537 }
7538
Takashi Iwai82bc9552006-03-21 11:24:42 +01007539 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007540 if (nid) {
7541 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007542 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7543 "Speaker Playback Volume",
7544 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7545 HDA_OUTPUT));
7546 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007547 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007548 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7549 "Speaker Playback Switch",
7550 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7551 HDA_OUTPUT));
7552 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007553 return err;
7554 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007555 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7556 "Speaker Playback Switch",
7557 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7558 HDA_OUTPUT));
7559 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007560 return err;
7561 }
7562 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007563 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007564 if (nid) {
7565 /* spec->multiout.hp_nid = 2; */
7566 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007567 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7568 "Headphone Playback Volume",
7569 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7570 HDA_OUTPUT));
7571 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007572 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007573 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7574 "Headphone Playback Switch",
7575 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7576 HDA_OUTPUT));
7577 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007578 return err;
7579 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007580 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7581 "Headphone Playback Switch",
7582 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7583 HDA_OUTPUT));
7584 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007585 return err;
7586 }
7587 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007588 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007589}
7590
7591/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007592#define alc262_auto_create_analog_input_ctls \
7593 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007594
7595/*
7596 * generic initialization of ADC, input mixers and output mixers
7597 */
7598static struct hda_verb alc262_volume_init_verbs[] = {
7599 /*
7600 * Unmute ADC0-2 and set the default input to mic-in
7601 */
7602 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7603 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7604 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7606 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7608
7609 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7610 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007611 * Note: PASD motherboards uses the Line In 2 as the input for
7612 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007613 */
7614 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7619 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7620
7621 /*
7622 * Set up output mixers (0x0c - 0x0f)
7623 */
7624 /* set vol=0 to output mixers */
7625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7628
7629 /* set up input amps for analog loopback */
7630 /* Amp Indices: DAC = 0, mixer = 1 */
7631 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7632 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7634 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7635 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7637
7638 /* FIXME: use matrix-type input source selection */
7639 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7640 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7641 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7642 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7643 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7645 /* Input mixer2 */
7646 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7647 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7650 /* Input mixer3 */
7651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7653 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7655
7656 { }
7657};
7658
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007659static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7660 /*
7661 * Unmute ADC0-2 and set the default input to mic-in
7662 */
7663 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7664 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7665 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7666 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7667 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7668 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7669
7670 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7671 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007672 * Note: PASD motherboards uses the Line In 2 as the input for
7673 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007674 */
7675 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7683
7684 /*
7685 * Set up output mixers (0x0c - 0x0e)
7686 */
7687 /* set vol=0 to output mixers */
7688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7689 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7691
7692 /* set up input amps for analog loopback */
7693 /* Amp Indices: DAC = 0, mixer = 1 */
7694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7695 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7696 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7697 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7698 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7699 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7700
7701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7702 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7703 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7704
7705 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7707
7708 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7709 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7710
7711 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7712 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7713 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7715 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7716
7717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7719 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7720 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7721 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7722 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7723
7724
7725 /* FIXME: use matrix-type input source selection */
7726 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7727 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7731 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7732 /* Input mixer2 */
7733 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7734 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7735 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7736 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7737 /* Input mixer3 */
7738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7739 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7741 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7742
7743 { }
7744};
7745
Kailang Yangcd7509a2007-01-26 18:33:17 +01007746static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7747 /*
7748 * Unmute ADC0-2 and set the default input to mic-in
7749 */
7750 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7752 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7754 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7756
7757 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7758 * mixer widget
7759 * Note: PASD motherboards uses the Line In 2 as the input for front
7760 * panel mic (mic 2)
7761 */
7762 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7771 /*
7772 * Set up output mixers (0x0c - 0x0e)
7773 */
7774 /* set vol=0 to output mixers */
7775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7776 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7777 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7778
7779 /* set up input amps for analog loopback */
7780 /* Amp Indices: DAC = 0, mixer = 1 */
7781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7783 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7784 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7785 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7786 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7787
7788
7789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7790 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7791 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7792 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7793 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7794 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7795 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7796
7797 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7799
7800 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7802
7803 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7804 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7806 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7807 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7808 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7809
7810 /* FIXME: use matrix-type input source selection */
7811 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7812 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7813 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7814 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7815 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7816 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7818 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7819 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7820 /* Input mixer2 */
7821 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7824 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7826 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7827 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7828 /* Input mixer3 */
7829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7832 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7834 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7836
7837 { }
7838};
7839
Kailang Yangdf694da2005-12-05 19:42:22 +01007840/* pcm configuration: identiacal with ALC880 */
7841#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7842#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7843#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7844#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7845
7846/*
7847 * BIOS auto configuration
7848 */
7849static int alc262_parse_auto_config(struct hda_codec *codec)
7850{
7851 struct alc_spec *spec = codec->spec;
7852 int err;
7853 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7854
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007855 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7856 alc262_ignore);
7857 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007858 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007859 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007860 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007861 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7862 if (err < 0)
7863 return err;
7864 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7865 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007866 return err;
7867
7868 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7869
7870 if (spec->autocfg.dig_out_pin)
7871 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7872 if (spec->autocfg.dig_in_pin)
7873 spec->dig_in_nid = ALC262_DIGIN_NID;
7874
7875 if (spec->kctl_alloc)
7876 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7877
7878 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007879 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007880 spec->input_mux = &spec->private_imux;
7881
7882 return 1;
7883}
7884
7885#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7886#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7887#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7888
7889
7890/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007891static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007892{
Kailang Yangdf694da2005-12-05 19:42:22 +01007893 alc262_auto_init_multi_out(codec);
7894 alc262_auto_init_hp_out(codec);
7895 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007896}
7897
7898/*
7899 * configuration and preset
7900 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007901static const char *alc262_models[ALC262_MODEL_LAST] = {
7902 [ALC262_BASIC] = "basic",
7903 [ALC262_HIPPO] = "hippo",
7904 [ALC262_HIPPO_1] = "hippo_1",
7905 [ALC262_FUJITSU] = "fujitsu",
7906 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007907 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007908 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02007909 [ALC262_BENQ_T31] = "benq-t31",
7910 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007911 [ALC262_AUTO] = "auto",
7912};
7913
7914static struct snd_pci_quirk alc262_cfg_tbl[] = {
7915 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7916 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7917 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007918 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7919 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007920 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007921 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007922 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02007923 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007924 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7925 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7926 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7927 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7928 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7929 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7930 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7931 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007932 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7933 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7934 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7935 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02007936 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwai5b319542007-07-26 11:49:22 +02007937 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yang272a5272007-05-14 11:00:38 +02007938 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7939 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7940 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007941 {}
7942};
7943
7944static struct alc_config_preset alc262_presets[] = {
7945 [ALC262_BASIC] = {
7946 .mixers = { alc262_base_mixer },
7947 .init_verbs = { alc262_init_verbs },
7948 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7949 .dac_nids = alc262_dac_nids,
7950 .hp_nid = 0x03,
7951 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7952 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007953 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007954 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007955 [ALC262_HIPPO] = {
7956 .mixers = { alc262_base_mixer },
7957 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7958 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7959 .dac_nids = alc262_dac_nids,
7960 .hp_nid = 0x03,
7961 .dig_out_nid = ALC262_DIGOUT_NID,
7962 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7963 .channel_mode = alc262_modes,
7964 .input_mux = &alc262_capture_source,
7965 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02007966 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02007967 },
7968 [ALC262_HIPPO_1] = {
7969 .mixers = { alc262_hippo1_mixer },
7970 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7971 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7972 .dac_nids = alc262_dac_nids,
7973 .hp_nid = 0x02,
7974 .dig_out_nid = ALC262_DIGOUT_NID,
7975 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7976 .channel_mode = alc262_modes,
7977 .input_mux = &alc262_capture_source,
7978 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02007979 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02007980 },
Takashi Iwai834be882006-03-01 14:16:17 +01007981 [ALC262_FUJITSU] = {
7982 .mixers = { alc262_fujitsu_mixer },
7983 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7984 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7985 .dac_nids = alc262_dac_nids,
7986 .hp_nid = 0x03,
7987 .dig_out_nid = ALC262_DIGOUT_NID,
7988 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7989 .channel_mode = alc262_modes,
7990 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007991 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007992 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007993 [ALC262_HP_BPC] = {
7994 .mixers = { alc262_HP_BPC_mixer },
7995 .init_verbs = { alc262_HP_BPC_init_verbs },
7996 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7997 .dac_nids = alc262_dac_nids,
7998 .hp_nid = 0x03,
7999 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8000 .channel_mode = alc262_modes,
8001 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008002 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008003 [ALC262_HP_BPC_D7000_WF] = {
8004 .mixers = { alc262_HP_BPC_WildWest_mixer },
8005 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8006 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8007 .dac_nids = alc262_dac_nids,
8008 .hp_nid = 0x03,
8009 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8010 .channel_mode = alc262_modes,
8011 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008012 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008013 [ALC262_HP_BPC_D7000_WL] = {
8014 .mixers = { alc262_HP_BPC_WildWest_mixer,
8015 alc262_HP_BPC_WildWest_option_mixer },
8016 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8017 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8018 .dac_nids = alc262_dac_nids,
8019 .hp_nid = 0x03,
8020 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8021 .channel_mode = alc262_modes,
8022 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008023 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008024 [ALC262_BENQ_ED8] = {
8025 .mixers = { alc262_base_mixer },
8026 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8027 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8028 .dac_nids = alc262_dac_nids,
8029 .hp_nid = 0x03,
8030 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8031 .channel_mode = alc262_modes,
8032 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008033 },
Kailang Yang272a5272007-05-14 11:00:38 +02008034 [ALC262_SONY_ASSAMD] = {
8035 .mixers = { alc262_sony_mixer },
8036 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8037 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8038 .dac_nids = alc262_dac_nids,
8039 .hp_nid = 0x02,
8040 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8041 .channel_mode = alc262_modes,
8042 .input_mux = &alc262_capture_source,
8043 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008044 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02008045 },
8046 [ALC262_BENQ_T31] = {
8047 .mixers = { alc262_benq_t31_mixer },
8048 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8049 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8050 .dac_nids = alc262_dac_nids,
8051 .hp_nid = 0x03,
8052 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8053 .channel_mode = alc262_modes,
8054 .input_mux = &alc262_capture_source,
8055 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008056 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02008057 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008058};
8059
8060static int patch_alc262(struct hda_codec *codec)
8061{
8062 struct alc_spec *spec;
8063 int board_config;
8064 int err;
8065
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008066 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008067 if (spec == NULL)
8068 return -ENOMEM;
8069
8070 codec->spec = spec;
8071#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008072 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8073 * under-run
8074 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008075 {
8076 int tmp;
8077 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8078 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8079 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8080 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8081 }
8082#endif
8083
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008084 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8085 alc262_models,
8086 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01008087
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008088 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008089 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8090 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008091 board_config = ALC262_AUTO;
8092 }
8093
8094 if (board_config == ALC262_AUTO) {
8095 /* automatic parse from the BIOS config */
8096 err = alc262_parse_auto_config(codec);
8097 if (err < 0) {
8098 alc_free(codec);
8099 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008100 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008101 printk(KERN_INFO
8102 "hda_codec: Cannot set up configuration "
8103 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008104 board_config = ALC262_BASIC;
8105 }
8106 }
8107
8108 if (board_config != ALC262_AUTO)
8109 setup_preset(spec, &alc262_presets[board_config]);
8110
8111 spec->stream_name_analog = "ALC262 Analog";
8112 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8113 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8114
8115 spec->stream_name_digital = "ALC262 Digital";
8116 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8117 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8118
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008119 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008120 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01008121 unsigned int wcap = get_wcaps(codec, 0x07);
8122
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008123 /* get type */
8124 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01008125 if (wcap != AC_WID_AUD_IN) {
8126 spec->adc_nids = alc262_adc_nids_alt;
8127 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008128 spec->mixers[spec->num_mixers] =
8129 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01008130 spec->num_mixers++;
8131 } else {
8132 spec->adc_nids = alc262_adc_nids;
8133 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8134 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8135 spec->num_mixers++;
8136 }
8137 }
8138
8139 codec->patch_ops = alc_patch_ops;
8140 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008141 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01008142
Kailang Yangdf694da2005-12-05 19:42:22 +01008143 return 0;
8144}
8145
Kailang Yangdf694da2005-12-05 19:42:22 +01008146/*
Kailang Yanga361d842007-06-05 12:30:55 +02008147 * ALC268 channel source setting (2 channel)
8148 */
8149#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8150#define alc268_modes alc260_modes
8151
8152static hda_nid_t alc268_dac_nids[2] = {
8153 /* front, hp */
8154 0x02, 0x03
8155};
8156
8157static hda_nid_t alc268_adc_nids[2] = {
8158 /* ADC0-1 */
8159 0x08, 0x07
8160};
8161
8162static hda_nid_t alc268_adc_nids_alt[1] = {
8163 /* ADC0 */
8164 0x08
8165};
8166
8167static struct snd_kcontrol_new alc268_base_mixer[] = {
8168 /* output mixer control */
8169 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8170 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8173 { }
8174};
8175
8176/*
8177 * generic initialization of ADC, input mixers and output mixers
8178 */
8179static struct hda_verb alc268_base_init_verbs[] = {
8180 /* Unmute DAC0-1 and set vol = 0 */
8181 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8182 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8184 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8185 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8186 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8187
8188 /*
8189 * Set up output mixers (0x0c - 0x0e)
8190 */
8191 /* set vol=0 to output mixers */
8192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8193 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8195 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8196
8197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8198 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8199
8200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8204 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8207 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8208
8209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8211 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8212 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8213 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8215 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8216 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8217
8218 /* FIXME: use matrix-type input source selection */
8219 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8220 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8221 /* Input mixer2 */
8222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8223 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8226
8227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8231 { }
8232};
8233
8234/*
8235 * generic initialization of ADC, input mixers and output mixers
8236 */
8237static struct hda_verb alc268_volume_init_verbs[] = {
8238 /* set output DAC */
8239 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8241 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8242 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8243
8244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8247 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8248 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8249
8250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255
8256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8259 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8260
8261 /* set PCBEEP vol = 0 */
8262 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8263
8264 { }
8265};
8266
8267#define alc268_mux_enum_info alc_mux_enum_info
8268#define alc268_mux_enum_get alc_mux_enum_get
8269
8270static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8271 struct snd_ctl_elem_value *ucontrol)
8272{
8273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8274 struct alc_spec *spec = codec->spec;
8275 const struct hda_input_mux *imux = spec->input_mux;
8276 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8277 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8278 hda_nid_t nid = capture_mixers[adc_idx];
8279 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8280 unsigned int i, idx;
8281
8282 idx = ucontrol->value.enumerated.item[0];
8283 if (idx >= imux->num_items)
8284 idx = imux->num_items - 1;
8285 if (*cur_val == idx && !codec->in_resume)
8286 return 0;
8287 for (i = 0; i < imux->num_items; i++) {
8288 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8289 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8290 v | (imux->items[i].index << 8));
8291 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8292 idx );
8293 }
8294 *cur_val = idx;
8295 return 1;
8296}
8297
8298static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8299 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8300 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8301 {
8302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8303 /* The multiple "Capture Source" controls confuse alsamixer
8304 * So call somewhat different..
8305 * FIXME: the controls appear in the "playback" view!
8306 */
8307 /* .name = "Capture Source", */
8308 .name = "Input Source",
8309 .count = 1,
8310 .info = alc268_mux_enum_info,
8311 .get = alc268_mux_enum_get,
8312 .put = alc268_mux_enum_put,
8313 },
8314 { } /* end */
8315};
8316
8317static struct snd_kcontrol_new alc268_capture_mixer[] = {
8318 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8319 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8320 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8321 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8322 {
8323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8324 /* The multiple "Capture Source" controls confuse alsamixer
8325 * So call somewhat different..
8326 * FIXME: the controls appear in the "playback" view!
8327 */
8328 /* .name = "Capture Source", */
8329 .name = "Input Source",
8330 .count = 2,
8331 .info = alc268_mux_enum_info,
8332 .get = alc268_mux_enum_get,
8333 .put = alc268_mux_enum_put,
8334 },
8335 { } /* end */
8336};
8337
8338static struct hda_input_mux alc268_capture_source = {
8339 .num_items = 4,
8340 .items = {
8341 { "Mic", 0x0 },
8342 { "Front Mic", 0x1 },
8343 { "Line", 0x2 },
8344 { "CD", 0x3 },
8345 },
8346};
8347
8348/* create input playback/capture controls for the given pin */
8349static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8350 const char *ctlname, int idx)
8351{
8352 char name[32];
8353 int err;
8354
8355 sprintf(name, "%s Playback Volume", ctlname);
8356 if (nid == 0x14) {
8357 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8358 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8359 HDA_OUTPUT));
8360 if (err < 0)
8361 return err;
8362 } else if (nid == 0x15) {
8363 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8364 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8365 HDA_OUTPUT));
8366 if (err < 0)
8367 return err;
8368 } else
8369 return -1;
8370 sprintf(name, "%s Playback Switch", ctlname);
8371 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8372 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8373 if (err < 0)
8374 return err;
8375 return 0;
8376}
8377
8378/* add playback controls from the parsed DAC table */
8379static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8380 const struct auto_pin_cfg *cfg)
8381{
8382 hda_nid_t nid;
8383 int err;
8384
8385 spec->multiout.num_dacs = 2; /* only use one dac */
8386 spec->multiout.dac_nids = spec->private_dac_nids;
8387 spec->multiout.dac_nids[0] = 2;
8388 spec->multiout.dac_nids[1] = 3;
8389
8390 nid = cfg->line_out_pins[0];
8391 if (nid)
8392 alc268_new_analog_output(spec, nid, "Front", 0);
8393
8394 nid = cfg->speaker_pins[0];
8395 if (nid == 0x1d) {
8396 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8397 "Speaker Playback Volume",
8398 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8399 if (err < 0)
8400 return err;
8401 }
8402 nid = cfg->hp_pins[0];
8403 if (nid)
8404 alc268_new_analog_output(spec, nid, "Headphone", 0);
8405
8406 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8407 if (nid == 0x16) {
8408 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8409 "Mono Playback Switch",
8410 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8411 if (err < 0)
8412 return err;
8413 }
8414 return 0;
8415}
8416
8417/* create playback/capture controls for input pins */
8418static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8419 const struct auto_pin_cfg *cfg)
8420{
8421 struct hda_input_mux *imux = &spec->private_imux;
8422 int i, idx1;
8423
8424 for (i = 0; i < AUTO_PIN_LAST; i++) {
8425 switch(cfg->input_pins[i]) {
8426 case 0x18:
8427 idx1 = 0; /* Mic 1 */
8428 break;
8429 case 0x19:
8430 idx1 = 1; /* Mic 2 */
8431 break;
8432 case 0x1a:
8433 idx1 = 2; /* Line In */
8434 break;
8435 case 0x1c:
8436 idx1 = 3; /* CD */
8437 break;
8438 default:
8439 continue;
8440 }
8441 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8442 imux->items[imux->num_items].index = idx1;
8443 imux->num_items++;
8444 }
8445 return 0;
8446}
8447
8448static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8449{
8450 struct alc_spec *spec = codec->spec;
8451 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8452 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8453 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8454 unsigned int dac_vol1, dac_vol2;
8455
8456 if (speaker_nid) {
8457 snd_hda_codec_write(codec, speaker_nid, 0,
8458 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8459 snd_hda_codec_write(codec, 0x0f, 0,
8460 AC_VERB_SET_AMP_GAIN_MUTE,
8461 AMP_IN_UNMUTE(1));
8462 snd_hda_codec_write(codec, 0x10, 0,
8463 AC_VERB_SET_AMP_GAIN_MUTE,
8464 AMP_IN_UNMUTE(1));
8465 } else {
8466 snd_hda_codec_write(codec, 0x0f, 0,
8467 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8468 snd_hda_codec_write(codec, 0x10, 0,
8469 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8470 }
8471
8472 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8473 if (line_nid == 0x14)
8474 dac_vol2 = AMP_OUT_ZERO;
8475 else if (line_nid == 0x15)
8476 dac_vol1 = AMP_OUT_ZERO;
8477 if (hp_nid == 0x14)
8478 dac_vol2 = AMP_OUT_ZERO;
8479 else if (hp_nid == 0x15)
8480 dac_vol1 = AMP_OUT_ZERO;
8481 if (line_nid != 0x16 || hp_nid != 0x16 ||
8482 spec->autocfg.line_out_pins[1] != 0x16 ||
8483 spec->autocfg.line_out_pins[2] != 0x16)
8484 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8485
8486 snd_hda_codec_write(codec, 0x02, 0,
8487 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8488 snd_hda_codec_write(codec, 0x03, 0,
8489 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8490}
8491
8492/* pcm configuration: identiacal with ALC880 */
8493#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8494#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8495#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8496
8497/*
8498 * BIOS auto configuration
8499 */
8500static int alc268_parse_auto_config(struct hda_codec *codec)
8501{
8502 struct alc_spec *spec = codec->spec;
8503 int err;
8504 static hda_nid_t alc268_ignore[] = { 0 };
8505
8506 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8507 alc268_ignore);
8508 if (err < 0)
8509 return err;
8510 if (!spec->autocfg.line_outs)
8511 return 0; /* can't find valid BIOS pin config */
8512
8513 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8514 if (err < 0)
8515 return err;
8516 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8517 if (err < 0)
8518 return err;
8519
8520 spec->multiout.max_channels = 2;
8521
8522 /* digital only support output */
8523 if (spec->autocfg.dig_out_pin)
8524 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8525
8526 if (spec->kctl_alloc)
8527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8528
8529 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8530 spec->num_mux_defs = 1;
8531 spec->input_mux = &spec->private_imux;
8532
8533 return 1;
8534}
8535
8536#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8537#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8538#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8539
8540/* init callback for auto-configuration model -- overriding the default init */
8541static void alc268_auto_init(struct hda_codec *codec)
8542{
8543 alc268_auto_init_multi_out(codec);
8544 alc268_auto_init_hp_out(codec);
8545 alc268_auto_init_mono_speaker_out(codec);
8546 alc268_auto_init_analog_input(codec);
8547}
8548
8549/*
8550 * configuration and preset
8551 */
8552static const char *alc268_models[ALC268_MODEL_LAST] = {
8553 [ALC268_3ST] = "3stack",
8554 [ALC268_AUTO] = "auto",
8555};
8556
8557static struct snd_pci_quirk alc268_cfg_tbl[] = {
8558 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8559 {}
8560};
8561
8562static struct alc_config_preset alc268_presets[] = {
8563 [ALC268_3ST] = {
8564 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8565 .init_verbs = { alc268_base_init_verbs },
8566 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8567 .dac_nids = alc268_dac_nids,
8568 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8569 .adc_nids = alc268_adc_nids_alt,
8570 .hp_nid = 0x03,
8571 .dig_out_nid = ALC268_DIGOUT_NID,
8572 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8573 .channel_mode = alc268_modes,
8574 .input_mux = &alc268_capture_source,
8575 },
8576};
8577
8578static int patch_alc268(struct hda_codec *codec)
8579{
8580 struct alc_spec *spec;
8581 int board_config;
8582 int err;
8583
8584 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8585 if (spec == NULL)
8586 return -ENOMEM;
8587
8588 codec->spec = spec;
8589
8590 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8591 alc268_models,
8592 alc268_cfg_tbl);
8593
8594 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8595 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8596 "trying auto-probe from BIOS...\n");
8597 board_config = ALC268_AUTO;
8598 }
8599
8600 if (board_config == ALC268_AUTO) {
8601 /* automatic parse from the BIOS config */
8602 err = alc268_parse_auto_config(codec);
8603 if (err < 0) {
8604 alc_free(codec);
8605 return err;
8606 } else if (!err) {
8607 printk(KERN_INFO
8608 "hda_codec: Cannot set up configuration "
8609 "from BIOS. Using base mode...\n");
8610 board_config = ALC268_3ST;
8611 }
8612 }
8613
8614 if (board_config != ALC268_AUTO)
8615 setup_preset(spec, &alc268_presets[board_config]);
8616
8617 spec->stream_name_analog = "ALC268 Analog";
8618 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8619 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8620
8621 spec->stream_name_digital = "ALC268 Digital";
8622 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8623
8624 if (board_config == ALC268_AUTO) {
8625 if (!spec->adc_nids && spec->input_mux) {
8626 /* check whether NID 0x07 is valid */
8627 unsigned int wcap = get_wcaps(codec, 0x07);
8628
8629 /* get type */
8630 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8631 if (wcap != AC_WID_AUD_IN) {
8632 spec->adc_nids = alc268_adc_nids_alt;
8633 spec->num_adc_nids =
8634 ARRAY_SIZE(alc268_adc_nids_alt);
8635 spec->mixers[spec->num_mixers] =
8636 alc268_capture_alt_mixer;
8637 spec->num_mixers++;
8638 } else {
8639 spec->adc_nids = alc268_adc_nids;
8640 spec->num_adc_nids =
8641 ARRAY_SIZE(alc268_adc_nids);
8642 spec->mixers[spec->num_mixers] =
8643 alc268_capture_mixer;
8644 spec->num_mixers++;
8645 }
8646 }
8647 }
8648 codec->patch_ops = alc_patch_ops;
8649 if (board_config == ALC268_AUTO)
8650 spec->init_hook = alc268_auto_init;
8651
8652 return 0;
8653}
8654
8655/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008656 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8657 */
8658
8659/*
8660 * set the path ways for 2 channel output
8661 * need to set the codec line out and mic 1 pin widgets to inputs
8662 */
8663static struct hda_verb alc861_threestack_ch2_init[] = {
8664 /* set pin widget 1Ah (line in) for input */
8665 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008666 /* set pin widget 18h (mic1/2) for input, for mic also enable
8667 * the vref
8668 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008669 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8670
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8672#if 0
8673 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8674 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8675#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008676 { } /* end */
8677};
8678/*
8679 * 6ch mode
8680 * need to set the codec line out and mic 1 pin widgets to outputs
8681 */
8682static struct hda_verb alc861_threestack_ch6_init[] = {
8683 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8684 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8685 /* set pin widget 18h (mic1) for output (CLFE)*/
8686 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8687
8688 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008689 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008690
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008691 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8692#if 0
8693 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8694 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8695#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01008696 { } /* end */
8697};
8698
8699static struct hda_channel_mode alc861_threestack_modes[2] = {
8700 { 2, alc861_threestack_ch2_init },
8701 { 6, alc861_threestack_ch6_init },
8702};
Takashi Iwai22309c32006-08-09 16:57:28 +02008703/* Set mic1 as input and unmute the mixer */
8704static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8705 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8706 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8707 { } /* end */
8708};
8709/* Set mic1 as output and mute mixer */
8710static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8711 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8712 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8713 { } /* end */
8714};
8715
8716static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8717 { 2, alc861_uniwill_m31_ch2_init },
8718 { 4, alc861_uniwill_m31_ch4_init },
8719};
Kailang Yangdf694da2005-12-05 19:42:22 +01008720
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008721/* Set mic1 and line-in as input and unmute the mixer */
8722static struct hda_verb alc861_asus_ch2_init[] = {
8723 /* set pin widget 1Ah (line in) for input */
8724 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008725 /* set pin widget 18h (mic1/2) for input, for mic also enable
8726 * the vref
8727 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008728 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8729
8730 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8731#if 0
8732 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8733 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8734#endif
8735 { } /* end */
8736};
8737/* Set mic1 nad line-in as output and mute mixer */
8738static struct hda_verb alc861_asus_ch6_init[] = {
8739 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8740 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8741 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8742 /* set pin widget 18h (mic1) for output (CLFE)*/
8743 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8744 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8745 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8746 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8747
8748 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8749#if 0
8750 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8751 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8752#endif
8753 { } /* end */
8754};
8755
8756static struct hda_channel_mode alc861_asus_modes[2] = {
8757 { 2, alc861_asus_ch2_init },
8758 { 6, alc861_asus_ch6_init },
8759};
8760
Kailang Yangdf694da2005-12-05 19:42:22 +01008761/* patch-ALC861 */
8762
8763static struct snd_kcontrol_new alc861_base_mixer[] = {
8764 /* output mixer control */
8765 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8766 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8767 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8768 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8769 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8770
8771 /*Input mixer control */
8772 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8773 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8774 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8775 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8777 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8779 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008782
Kailang Yangdf694da2005-12-05 19:42:22 +01008783 /* Capture mixer control */
8784 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8785 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8786 {
8787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8788 .name = "Capture Source",
8789 .count = 1,
8790 .info = alc_mux_enum_info,
8791 .get = alc_mux_enum_get,
8792 .put = alc_mux_enum_put,
8793 },
8794 { } /* end */
8795};
8796
8797static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8798 /* output mixer control */
8799 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8800 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8801 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8802 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8803 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8804
8805 /* Input mixer control */
8806 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8807 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8808 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8809 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8810 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8811 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8813 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008816
Kailang Yangdf694da2005-12-05 19:42:22 +01008817 /* Capture mixer control */
8818 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8819 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8820 {
8821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8822 .name = "Capture Source",
8823 .count = 1,
8824 .info = alc_mux_enum_info,
8825 .get = alc_mux_enum_get,
8826 .put = alc_mux_enum_put,
8827 },
8828 {
8829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8830 .name = "Channel Mode",
8831 .info = alc_ch_mode_info,
8832 .get = alc_ch_mode_get,
8833 .put = alc_ch_mode_put,
8834 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8835 },
8836 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008837};
8838
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008839static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008840 /* output mixer control */
8841 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8843 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8844
8845 /*Capture mixer control */
8846 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8847 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8848 {
8849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8850 .name = "Capture Source",
8851 .count = 1,
8852 .info = alc_mux_enum_info,
8853 .get = alc_mux_enum_get,
8854 .put = alc_mux_enum_put,
8855 },
8856
8857 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008858};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008859
Takashi Iwai22309c32006-08-09 16:57:28 +02008860static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8861 /* output mixer control */
8862 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8863 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8864 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8865 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8866 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8867
8868 /* Input mixer control */
8869 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8870 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8871 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8872 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8873 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8874 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8876 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008879
Takashi Iwai22309c32006-08-09 16:57:28 +02008880 /* Capture mixer control */
8881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8883 {
8884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8885 .name = "Capture Source",
8886 .count = 1,
8887 .info = alc_mux_enum_info,
8888 .get = alc_mux_enum_get,
8889 .put = alc_mux_enum_put,
8890 },
8891 {
8892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8893 .name = "Channel Mode",
8894 .info = alc_ch_mode_info,
8895 .get = alc_ch_mode_get,
8896 .put = alc_ch_mode_put,
8897 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8898 },
8899 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008900};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008901
8902static struct snd_kcontrol_new alc861_asus_mixer[] = {
8903 /* output mixer control */
8904 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8905 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8907 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8908 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8909
8910 /* Input mixer control */
8911 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8912 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8913 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8914 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8915 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8916 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8918 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8919 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8921
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008922 /* Capture mixer control */
8923 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8924 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8925 {
8926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8927 .name = "Capture Source",
8928 .count = 1,
8929 .info = alc_mux_enum_info,
8930 .get = alc_mux_enum_get,
8931 .put = alc_mux_enum_put,
8932 },
8933 {
8934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8935 .name = "Channel Mode",
8936 .info = alc_ch_mode_info,
8937 .get = alc_ch_mode_get,
8938 .put = alc_ch_mode_put,
8939 .private_value = ARRAY_SIZE(alc861_asus_modes),
8940 },
8941 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008942};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008943
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008944/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008945static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008946 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8947 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8948 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8949 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8950 { }
8951};
8952
Kailang Yangdf694da2005-12-05 19:42:22 +01008953/*
8954 * generic initialization of ADC, input mixers and output mixers
8955 */
8956static struct hda_verb alc861_base_init_verbs[] = {
8957 /*
8958 * Unmute ADC0 and set the default input to mic-in
8959 */
8960 /* port-A for surround (rear panel) */
8961 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8962 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8963 /* port-B for mic-in (rear panel) with vref */
8964 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8965 /* port-C for line-in (rear panel) */
8966 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8967 /* port-D for Front */
8968 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8969 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8970 /* port-E for HP out (front panel) */
8971 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8972 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008973 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008974 /* port-F for mic-in (front panel) with vref */
8975 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8976 /* port-G for CLFE (rear panel) */
8977 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8978 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8979 /* port-H for side (rear panel) */
8980 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8981 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8982 /* CD-in */
8983 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8984 /* route front mic to ADC1*/
8985 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8987
8988 /* Unmute DAC0~3 & spdif out*/
8989 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8990 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8991 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8992 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8994
8995 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8996 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8997 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8998 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8999 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9000
9001 /* Unmute Stereo Mixer 15 */
9002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009006
9007 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9008 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9009 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9010 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9011 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9012 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9014 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009015 /* hp used DAC 3 (Front) */
9016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9018
9019 { }
9020};
9021
9022static struct hda_verb alc861_threestack_init_verbs[] = {
9023 /*
9024 * Unmute ADC0 and set the default input to mic-in
9025 */
9026 /* port-A for surround (rear panel) */
9027 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9028 /* port-B for mic-in (rear panel) with vref */
9029 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9030 /* port-C for line-in (rear panel) */
9031 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9032 /* port-D for Front */
9033 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9034 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9035 /* port-E for HP out (front panel) */
9036 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9037 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009038 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009039 /* port-F for mic-in (front panel) with vref */
9040 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9041 /* port-G for CLFE (rear panel) */
9042 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9043 /* port-H for side (rear panel) */
9044 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9045 /* CD-in */
9046 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9047 /* route front mic to ADC1*/
9048 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9049 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9050 /* Unmute DAC0~3 & spdif out*/
9051 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9052 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9053 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9054 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9056
9057 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9058 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9059 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9060 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9061 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9062
9063 /* Unmute Stereo Mixer 15 */
9064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009068
9069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9071 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9072 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009077 /* hp used DAC 3 (Front) */
9078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9080 { }
9081};
Takashi Iwai22309c32006-08-09 16:57:28 +02009082
9083static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9084 /*
9085 * Unmute ADC0 and set the default input to mic-in
9086 */
9087 /* port-A for surround (rear panel) */
9088 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9089 /* port-B for mic-in (rear panel) with vref */
9090 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9091 /* port-C for line-in (rear panel) */
9092 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9093 /* port-D for Front */
9094 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9095 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9096 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009097 /* this has to be set to VREF80 */
9098 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009099 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009100 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009101 /* port-F for mic-in (front panel) with vref */
9102 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9103 /* port-G for CLFE (rear panel) */
9104 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9105 /* port-H for side (rear panel) */
9106 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9107 /* CD-in */
9108 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9109 /* route front mic to ADC1*/
9110 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9112 /* Unmute DAC0~3 & spdif out*/
9113 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9114 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9115 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9116 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9118
9119 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9120 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9121 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9122 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9123 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9124
9125 /* Unmute Stereo Mixer 15 */
9126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02009130
9131 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9133 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9134 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9135 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009139 /* hp used DAC 3 (Front) */
9140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9142 { }
9143};
9144
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009145static struct hda_verb alc861_asus_init_verbs[] = {
9146 /*
9147 * Unmute ADC0 and set the default input to mic-in
9148 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009149 /* port-A for surround (rear panel)
9150 * according to codec#0 this is the HP jack
9151 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009152 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9153 /* route front PCM to HP */
9154 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9155 /* port-B for mic-in (rear panel) with vref */
9156 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9157 /* port-C for line-in (rear panel) */
9158 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9159 /* port-D for Front */
9160 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9161 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9162 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009163 /* this has to be set to VREF80 */
9164 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009165 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009166 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009167 /* port-F for mic-in (front panel) with vref */
9168 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9169 /* port-G for CLFE (rear panel) */
9170 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9171 /* port-H for side (rear panel) */
9172 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9173 /* CD-in */
9174 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9175 /* route front mic to ADC1*/
9176 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 /* Unmute DAC0~3 & spdif out*/
9179 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9180 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9181 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9182 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9184 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9185 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9186 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9187 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9188 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9189
9190 /* Unmute Stereo Mixer 15 */
9191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009195
9196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9198 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9199 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9202 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009204 /* hp used DAC 3 (Front) */
9205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9207 { }
9208};
9209
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009210/* additional init verbs for ASUS laptops */
9211static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9212 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9213 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9214 { }
9215};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009216
Kailang Yangdf694da2005-12-05 19:42:22 +01009217/*
9218 * generic initialization of ADC, input mixers and output mixers
9219 */
9220static struct hda_verb alc861_auto_init_verbs[] = {
9221 /*
9222 * Unmute ADC0 and set the default input to mic-in
9223 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009224 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9226
9227 /* Unmute DAC0~3 & spdif out*/
9228 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9230 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9231 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9233
9234 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9235 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9236 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9237 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9238 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9239
9240 /* Unmute Stereo Mixer 15 */
9241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9245
9246 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9247 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9248 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9249 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9250 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9254
9255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9262 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009263
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009265
9266 { }
9267};
9268
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009269static struct hda_verb alc861_toshiba_init_verbs[] = {
9270 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009271
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009272 { }
9273};
9274
9275/* toggle speaker-output according to the hp-jack state */
9276static void alc861_toshiba_automute(struct hda_codec *codec)
9277{
9278 unsigned int present;
9279
9280 present = snd_hda_codec_read(codec, 0x0f, 0,
9281 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9282 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
9283 0x80, present ? 0x80 : 0);
9284 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
9285 0x80, present ? 0x80 : 0);
9286 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
9287 0x80, present ? 0 : 0x80);
9288 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
9289 0x80, present ? 0 : 0x80);
9290}
9291
9292static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9293 unsigned int res)
9294{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009295 if ((res >> 26) == ALC880_HP_EVENT)
9296 alc861_toshiba_automute(codec);
9297}
9298
Kailang Yangdf694da2005-12-05 19:42:22 +01009299/* pcm configuration: identiacal with ALC880 */
9300#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9301#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9302#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9303#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9304
9305
9306#define ALC861_DIGOUT_NID 0x07
9307
9308static struct hda_channel_mode alc861_8ch_modes[1] = {
9309 { 8, NULL }
9310};
9311
9312static hda_nid_t alc861_dac_nids[4] = {
9313 /* front, surround, clfe, side */
9314 0x03, 0x06, 0x05, 0x04
9315};
9316
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009317static hda_nid_t alc660_dac_nids[3] = {
9318 /* front, clfe, surround */
9319 0x03, 0x05, 0x06
9320};
9321
Kailang Yangdf694da2005-12-05 19:42:22 +01009322static hda_nid_t alc861_adc_nids[1] = {
9323 /* ADC0-2 */
9324 0x08,
9325};
9326
9327static struct hda_input_mux alc861_capture_source = {
9328 .num_items = 5,
9329 .items = {
9330 { "Mic", 0x0 },
9331 { "Front Mic", 0x3 },
9332 { "Line", 0x1 },
9333 { "CD", 0x4 },
9334 { "Mixer", 0x5 },
9335 },
9336};
9337
9338/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009339static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9340 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009341{
9342 int i;
9343 hda_nid_t nid;
9344
9345 spec->multiout.dac_nids = spec->private_dac_nids;
9346 for (i = 0; i < cfg->line_outs; i++) {
9347 nid = cfg->line_out_pins[i];
9348 if (nid) {
9349 if (i >= ARRAY_SIZE(alc861_dac_nids))
9350 continue;
9351 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9352 }
9353 }
9354 spec->multiout.num_dacs = cfg->line_outs;
9355 return 0;
9356}
9357
9358/* add playback controls from the parsed DAC table */
9359static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9360 const struct auto_pin_cfg *cfg)
9361{
9362 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009363 static const char *chname[4] = {
9364 "Front", "Surround", NULL /*CLFE*/, "Side"
9365 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009366 hda_nid_t nid;
9367 int i, idx, err;
9368
9369 for (i = 0; i < cfg->line_outs; i++) {
9370 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009371 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009372 continue;
9373 if (nid == 0x05) {
9374 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009375 err = add_control(spec, ALC_CTL_BIND_MUTE,
9376 "Center Playback Switch",
9377 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9378 HDA_OUTPUT));
9379 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009380 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009381 err = add_control(spec, ALC_CTL_BIND_MUTE,
9382 "LFE Playback Switch",
9383 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9384 HDA_OUTPUT));
9385 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009386 return err;
9387 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009388 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9389 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009390 if (nid == alc861_dac_nids[idx])
9391 break;
9392 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009393 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9394 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9395 HDA_OUTPUT));
9396 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009397 return err;
9398 }
9399 }
9400 return 0;
9401}
9402
9403static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9404{
9405 int err;
9406 hda_nid_t nid;
9407
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009408 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009409 return 0;
9410
9411 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9412 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009413 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9414 "Headphone Playback Switch",
9415 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9416 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009417 return err;
9418 spec->multiout.hp_nid = nid;
9419 }
9420 return 0;
9421}
9422
9423/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009424static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9425 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009426{
Kailang Yangdf694da2005-12-05 19:42:22 +01009427 struct hda_input_mux *imux = &spec->private_imux;
9428 int i, err, idx, idx1;
9429
9430 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009431 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009432 case 0x0c:
9433 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009434 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009435 break;
9436 case 0x0f:
9437 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009438 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009439 break;
9440 case 0x0d:
9441 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009442 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009443 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009444 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009445 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009446 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009447 break;
9448 case 0x11:
9449 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009450 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009451 break;
9452 default:
9453 continue;
9454 }
9455
Takashi Iwai4a471b72005-12-07 13:56:29 +01009456 err = new_analog_input(spec, cfg->input_pins[i],
9457 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009458 if (err < 0)
9459 return err;
9460
Takashi Iwai4a471b72005-12-07 13:56:29 +01009461 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009462 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009463 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 }
9465 return 0;
9466}
9467
9468static struct snd_kcontrol_new alc861_capture_mixer[] = {
9469 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9470 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9471
9472 {
9473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9474 /* The multiple "Capture Source" controls confuse alsamixer
9475 * So call somewhat different..
9476 *FIXME: the controls appear in the "playback" view!
9477 */
9478 /* .name = "Capture Source", */
9479 .name = "Input Source",
9480 .count = 1,
9481 .info = alc_mux_enum_info,
9482 .get = alc_mux_enum_get,
9483 .put = alc_mux_enum_put,
9484 },
9485 { } /* end */
9486};
9487
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009488static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9489 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009490 int pin_type, int dac_idx)
9491{
9492 /* set as output */
9493
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9495 pin_type);
9496 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9497 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009498
9499}
9500
9501static void alc861_auto_init_multi_out(struct hda_codec *codec)
9502{
9503 struct alc_spec *spec = codec->spec;
9504 int i;
9505
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009506 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009507 for (i = 0; i < spec->autocfg.line_outs; i++) {
9508 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009509 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009510 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009511 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009512 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009513 }
9514}
9515
9516static void alc861_auto_init_hp_out(struct hda_codec *codec)
9517{
9518 struct alc_spec *spec = codec->spec;
9519 hda_nid_t pin;
9520
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009521 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009522 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009523 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9524 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009525}
9526
9527static void alc861_auto_init_analog_input(struct hda_codec *codec)
9528{
9529 struct alc_spec *spec = codec->spec;
9530 int i;
9531
9532 for (i = 0; i < AUTO_PIN_LAST; i++) {
9533 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009534 if (nid >= 0x0c && nid <= 0x11) {
9535 snd_hda_codec_write(codec, nid, 0,
9536 AC_VERB_SET_PIN_WIDGET_CONTROL,
9537 i <= AUTO_PIN_FRONT_MIC ?
9538 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009539 }
9540 }
9541}
9542
9543/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009544/* return 1 if successful, 0 if the proper config is not found,
9545 * or a negative error code
9546 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009547static int alc861_parse_auto_config(struct hda_codec *codec)
9548{
9549 struct alc_spec *spec = codec->spec;
9550 int err;
9551 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9552
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9554 alc861_ignore);
9555 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009557 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009558 return 0; /* can't find valid BIOS pin config */
9559
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009560 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9561 if (err < 0)
9562 return err;
9563 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9564 if (err < 0)
9565 return err;
9566 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9567 if (err < 0)
9568 return err;
9569 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9570 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009571 return err;
9572
9573 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9574
9575 if (spec->autocfg.dig_out_pin)
9576 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9577
9578 if (spec->kctl_alloc)
9579 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9580
9581 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9582
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009583 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009584 spec->input_mux = &spec->private_imux;
9585
9586 spec->adc_nids = alc861_adc_nids;
9587 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9588 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9589 spec->num_mixers++;
9590
9591 return 1;
9592}
9593
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009594/* additional initialization for auto-configuration model */
9595static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009596{
Kailang Yangdf694da2005-12-05 19:42:22 +01009597 alc861_auto_init_multi_out(codec);
9598 alc861_auto_init_hp_out(codec);
9599 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009600}
9601
9602
9603/*
9604 * configuration and preset
9605 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009606static const char *alc861_models[ALC861_MODEL_LAST] = {
9607 [ALC861_3ST] = "3stack",
9608 [ALC660_3ST] = "3stack-660",
9609 [ALC861_3ST_DIG] = "3stack-dig",
9610 [ALC861_6ST_DIG] = "6stack-dig",
9611 [ALC861_UNIWILL_M31] = "uniwill-m31",
9612 [ALC861_TOSHIBA] = "toshiba",
9613 [ALC861_ASUS] = "asus",
9614 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9615 [ALC861_AUTO] = "auto",
9616};
9617
9618static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01009619 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009620 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9621 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02009622 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +02009623 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009624 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +02009625 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +01009626 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +02009627 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9628 * Any other models that need this preset?
9629 */
9630 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009631 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +02009632 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01009633 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01009634 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009635 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Claudio Matsuokaef64adb2007-07-14 00:26:16 +02009636 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9637 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01009638 {}
9639};
9640
9641static struct alc_config_preset alc861_presets[] = {
9642 [ALC861_3ST] = {
9643 .mixers = { alc861_3ST_mixer },
9644 .init_verbs = { alc861_threestack_init_verbs },
9645 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9646 .dac_nids = alc861_dac_nids,
9647 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9648 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009649 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009650 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9651 .adc_nids = alc861_adc_nids,
9652 .input_mux = &alc861_capture_source,
9653 },
9654 [ALC861_3ST_DIG] = {
9655 .mixers = { alc861_base_mixer },
9656 .init_verbs = { alc861_threestack_init_verbs },
9657 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9658 .dac_nids = alc861_dac_nids,
9659 .dig_out_nid = ALC861_DIGOUT_NID,
9660 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9661 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009662 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01009663 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9664 .adc_nids = alc861_adc_nids,
9665 .input_mux = &alc861_capture_source,
9666 },
9667 [ALC861_6ST_DIG] = {
9668 .mixers = { alc861_base_mixer },
9669 .init_verbs = { alc861_base_init_verbs },
9670 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9671 .dac_nids = alc861_dac_nids,
9672 .dig_out_nid = ALC861_DIGOUT_NID,
9673 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9674 .channel_mode = alc861_8ch_modes,
9675 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9676 .adc_nids = alc861_adc_nids,
9677 .input_mux = &alc861_capture_source,
9678 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009679 [ALC660_3ST] = {
9680 .mixers = { alc861_3ST_mixer },
9681 .init_verbs = { alc861_threestack_init_verbs },
9682 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9683 .dac_nids = alc660_dac_nids,
9684 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9685 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009686 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009687 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9688 .adc_nids = alc861_adc_nids,
9689 .input_mux = &alc861_capture_source,
9690 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009691 [ALC861_UNIWILL_M31] = {
9692 .mixers = { alc861_uniwill_m31_mixer },
9693 .init_verbs = { alc861_uniwill_m31_init_verbs },
9694 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9695 .dac_nids = alc861_dac_nids,
9696 .dig_out_nid = ALC861_DIGOUT_NID,
9697 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9698 .channel_mode = alc861_uniwill_m31_modes,
9699 .need_dac_fix = 1,
9700 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9701 .adc_nids = alc861_adc_nids,
9702 .input_mux = &alc861_capture_source,
9703 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009704 [ALC861_TOSHIBA] = {
9705 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009706 .init_verbs = { alc861_base_init_verbs,
9707 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009708 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9709 .dac_nids = alc861_dac_nids,
9710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9711 .channel_mode = alc883_3ST_2ch_modes,
9712 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9713 .adc_nids = alc861_adc_nids,
9714 .input_mux = &alc861_capture_source,
9715 .unsol_event = alc861_toshiba_unsol_event,
9716 .init_hook = alc861_toshiba_automute,
9717 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009718 [ALC861_ASUS] = {
9719 .mixers = { alc861_asus_mixer },
9720 .init_verbs = { alc861_asus_init_verbs },
9721 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9722 .dac_nids = alc861_dac_nids,
9723 .dig_out_nid = ALC861_DIGOUT_NID,
9724 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9725 .channel_mode = alc861_asus_modes,
9726 .need_dac_fix = 1,
9727 .hp_nid = 0x06,
9728 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9729 .adc_nids = alc861_adc_nids,
9730 .input_mux = &alc861_capture_source,
9731 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009732 [ALC861_ASUS_LAPTOP] = {
9733 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9734 .init_verbs = { alc861_asus_init_verbs,
9735 alc861_asus_laptop_init_verbs },
9736 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9737 .dac_nids = alc861_dac_nids,
9738 .dig_out_nid = ALC861_DIGOUT_NID,
9739 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9740 .channel_mode = alc883_3ST_2ch_modes,
9741 .need_dac_fix = 1,
9742 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9743 .adc_nids = alc861_adc_nids,
9744 .input_mux = &alc861_capture_source,
9745 },
9746};
Kailang Yangdf694da2005-12-05 19:42:22 +01009747
9748
9749static int patch_alc861(struct hda_codec *codec)
9750{
9751 struct alc_spec *spec;
9752 int board_config;
9753 int err;
9754
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009755 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009756 if (spec == NULL)
9757 return -ENOMEM;
9758
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009759 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009760
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009761 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9762 alc861_models,
9763 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009764
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009765 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009766 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9767 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009768 board_config = ALC861_AUTO;
9769 }
9770
9771 if (board_config == ALC861_AUTO) {
9772 /* automatic parse from the BIOS config */
9773 err = alc861_parse_auto_config(codec);
9774 if (err < 0) {
9775 alc_free(codec);
9776 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009777 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009778 printk(KERN_INFO
9779 "hda_codec: Cannot set up configuration "
9780 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009781 board_config = ALC861_3ST_DIG;
9782 }
9783 }
9784
9785 if (board_config != ALC861_AUTO)
9786 setup_preset(spec, &alc861_presets[board_config]);
9787
9788 spec->stream_name_analog = "ALC861 Analog";
9789 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9790 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9791
9792 spec->stream_name_digital = "ALC861 Digital";
9793 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9794 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9795
9796 codec->patch_ops = alc_patch_ops;
9797 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009798 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01009799
9800 return 0;
9801}
9802
9803/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009804 * ALC861-VD support
9805 *
9806 * Based on ALC882
9807 *
9808 * In addition, an independent DAC
9809 */
9810#define ALC861VD_DIGOUT_NID 0x06
9811
9812static hda_nid_t alc861vd_dac_nids[4] = {
9813 /* front, surr, clfe, side surr */
9814 0x02, 0x03, 0x04, 0x05
9815};
9816
9817/* dac_nids for ALC660vd are in a different order - according to
9818 * Realtek's driver.
9819 * This should probably tesult in a different mixer for 6stack models
9820 * of ALC660vd codecs, but for now there is only 3stack mixer
9821 * - and it is the same as in 861vd.
9822 * adc_nids in ALC660vd are (is) the same as in 861vd
9823 */
9824static hda_nid_t alc660vd_dac_nids[3] = {
9825 /* front, rear, clfe, rear_surr */
9826 0x02, 0x04, 0x03
9827};
9828
9829static hda_nid_t alc861vd_adc_nids[1] = {
9830 /* ADC0 */
9831 0x09,
9832};
9833
9834/* input MUX */
9835/* FIXME: should be a matrix-type input source selection */
9836static struct hda_input_mux alc861vd_capture_source = {
9837 .num_items = 4,
9838 .items = {
9839 { "Mic", 0x0 },
9840 { "Front Mic", 0x1 },
9841 { "Line", 0x2 },
9842 { "CD", 0x4 },
9843 },
9844};
9845
Kailang Yang272a5272007-05-14 11:00:38 +02009846static struct hda_input_mux alc861vd_dallas_capture_source = {
9847 .num_items = 3,
9848 .items = {
9849 { "Front Mic", 0x0 },
9850 { "ATAPI Mic", 0x1 },
9851 { "Line In", 0x5 },
9852 },
9853};
9854
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009855#define alc861vd_mux_enum_info alc_mux_enum_info
9856#define alc861vd_mux_enum_get alc_mux_enum_get
9857
9858static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9859 struct snd_ctl_elem_value *ucontrol)
9860{
9861 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9862 struct alc_spec *spec = codec->spec;
9863 const struct hda_input_mux *imux = spec->input_mux;
9864 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9865 static hda_nid_t capture_mixers[1] = { 0x22 };
9866 hda_nid_t nid = capture_mixers[adc_idx];
9867 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9868 unsigned int i, idx;
9869
9870 idx = ucontrol->value.enumerated.item[0];
9871 if (idx >= imux->num_items)
9872 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009873 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009874 return 0;
9875 for (i = 0; i < imux->num_items; i++) {
9876 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9877 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9878 v | (imux->items[i].index << 8));
9879 }
9880 *cur_val = idx;
9881 return 1;
9882}
9883
9884/*
9885 * 2ch mode
9886 */
9887static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9888 { 2, NULL }
9889};
9890
9891/*
9892 * 6ch mode
9893 */
9894static struct hda_verb alc861vd_6stack_ch6_init[] = {
9895 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9896 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9897 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9898 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9899 { } /* end */
9900};
9901
9902/*
9903 * 8ch mode
9904 */
9905static struct hda_verb alc861vd_6stack_ch8_init[] = {
9906 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9907 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9908 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9909 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9910 { } /* end */
9911};
9912
9913static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9914 { 6, alc861vd_6stack_ch6_init },
9915 { 8, alc861vd_6stack_ch8_init },
9916};
9917
9918static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9919 {
9920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9921 .name = "Channel Mode",
9922 .info = alc_ch_mode_info,
9923 .get = alc_ch_mode_get,
9924 .put = alc_ch_mode_put,
9925 },
9926 { } /* end */
9927};
9928
9929static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9930 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9931 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9932
9933 {
9934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9935 /* The multiple "Capture Source" controls confuse alsamixer
9936 * So call somewhat different..
9937 *FIXME: the controls appear in the "playback" view!
9938 */
9939 /* .name = "Capture Source", */
9940 .name = "Input Source",
9941 .count = 1,
9942 .info = alc861vd_mux_enum_info,
9943 .get = alc861vd_mux_enum_get,
9944 .put = alc861vd_mux_enum_put,
9945 },
9946 { } /* end */
9947};
9948
9949/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9950 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9951 */
9952static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9953 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9954 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9955
9956 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9957 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9958
9959 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9960 HDA_OUTPUT),
9961 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9962 HDA_OUTPUT),
9963 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9964 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9965
9966 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9967 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9968
9969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9970
9971 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9974
9975 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9976 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9977 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9978
9979 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9980 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9981
9982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9984
9985 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9986 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9987
9988 { } /* end */
9989};
9990
9991static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9992 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9994
9995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9996
9997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10000
10001 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10004
10005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10007
10008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10010
10011 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10012 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10013
10014 { } /* end */
10015};
10016
Kailang Yangbdd148a2007-05-08 15:19:08 +020010017static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10018 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10019 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10020 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10021
10022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10023
10024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10027
10028 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10029 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10030 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10031
10032 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10033 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10034
10035 { } /* end */
10036};
10037
Kailang Yang272a5272007-05-14 11:00:38 +020010038/* Pin assignment: Front=0x14, HP = 0x15,
10039 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10040 */
10041static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10042 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10044 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10045 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10046 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10048 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10049 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10052 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10053 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10054 {
10055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10056 /* .name = "Capture Source", */
10057 .name = "Input Source",
10058 .count = 1,
10059 .info = alc882_mux_enum_info,
10060 .get = alc882_mux_enum_get,
10061 .put = alc882_mux_enum_put,
10062 },
10063 { } /* end */
10064};
10065
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010066/*
10067 * generic initialization of ADC, input mixers and output mixers
10068 */
10069static struct hda_verb alc861vd_volume_init_verbs[] = {
10070 /*
10071 * Unmute ADC0 and set the default input to mic-in
10072 */
10073 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10075
10076 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10077 * the analog-loopback mixer widget
10078 */
10079 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10085
10086 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020010087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010091
10092 /*
10093 * Set up output mixers (0x02 - 0x05)
10094 */
10095 /* set vol=0 to output mixers */
10096 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10097 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10098 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10099 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10100
10101 /* set up input amps for analog loopback */
10102 /* Amp Indices: DAC = 0, mixer = 1 */
10103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10108 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10109 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10110 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10111
10112 { }
10113};
10114
10115/*
10116 * 3-stack pin configuration:
10117 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10118 */
10119static struct hda_verb alc861vd_3stack_init_verbs[] = {
10120 /*
10121 * Set pin mode and muting
10122 */
10123 /* set front pin widgets 0x14 for output */
10124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10126 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10127
10128 /* Mic (rear) pin: input vref at 80% */
10129 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10131 /* Front Mic pin: input vref at 80% */
10132 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10134 /* Line In pin: input */
10135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10137 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10140 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10141 /* CD pin widget for input */
10142 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10143
10144 { }
10145};
10146
10147/*
10148 * 6-stack pin configuration:
10149 */
10150static struct hda_verb alc861vd_6stack_init_verbs[] = {
10151 /*
10152 * Set pin mode and muting
10153 */
10154 /* set front pin widgets 0x14 for output */
10155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10157 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10158
10159 /* Rear Pin: output 1 (0x0d) */
10160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10163 /* CLFE Pin: output 2 (0x0e) */
10164 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10165 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10166 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10167 /* Side Pin: output 3 (0x0f) */
10168 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10169 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10170 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10171
10172 /* Mic (rear) pin: input vref at 80% */
10173 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10174 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10175 /* Front Mic pin: input vref at 80% */
10176 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10177 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10178 /* Line In pin: input */
10179 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10180 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10181 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10183 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10184 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10185 /* CD pin widget for input */
10186 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10187
10188 { }
10189};
10190
Kailang Yangbdd148a2007-05-08 15:19:08 +020010191static struct hda_verb alc861vd_eapd_verbs[] = {
10192 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10193 { }
10194};
10195
10196static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10200 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10201 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10202 {}
10203};
10204
10205/* toggle speaker-output according to the hp-jack state */
10206static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10207{
10208 unsigned int present;
10209 unsigned char bits;
10210
10211 present = snd_hda_codec_read(codec, 0x1b, 0,
10212 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10213 bits = present ? 0x80 : 0;
10214 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10215 0x80, bits);
10216 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10217 0x80, bits);
10218}
10219
10220static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10221{
10222 unsigned int present;
10223 unsigned char bits;
10224
10225 present = snd_hda_codec_read(codec, 0x18, 0,
10226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10227 bits = present ? 0x80 : 0;
10228 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10229 0x80, bits);
10230 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10231 0x80, bits);
10232}
10233
10234static void alc861vd_lenovo_automute(struct hda_codec *codec)
10235{
10236 alc861vd_lenovo_hp_automute(codec);
10237 alc861vd_lenovo_mic_automute(codec);
10238}
10239
10240static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10241 unsigned int res)
10242{
10243 switch (res >> 26) {
10244 case ALC880_HP_EVENT:
10245 alc861vd_lenovo_hp_automute(codec);
10246 break;
10247 case ALC880_MIC_EVENT:
10248 alc861vd_lenovo_mic_automute(codec);
10249 break;
10250 }
10251}
10252
Kailang Yang272a5272007-05-14 11:00:38 +020010253static struct hda_verb alc861vd_dallas_verbs[] = {
10254 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10256 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10257 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10258
10259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10267
10268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10276
10277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10279 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10280 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10284 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10285
10286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10290
10291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10292 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10294
10295 { } /* end */
10296};
10297
10298/* toggle speaker-output according to the hp-jack state */
10299static void alc861vd_dallas_automute(struct hda_codec *codec)
10300{
10301 unsigned int present;
10302
10303 present = snd_hda_codec_read(codec, 0x15, 0,
10304 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10305 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10306 0x80, present ? 0x80 : 0);
10307 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10308 0x80, present ? 0x80 : 0);
10309}
10310
10311static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10312{
10313 if ((res >> 26) == ALC880_HP_EVENT)
10314 alc861vd_dallas_automute(codec);
10315}
10316
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010317/* pcm configuration: identiacal with ALC880 */
10318#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10319#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10320#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10321#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10322
10323/*
10324 * configuration and preset
10325 */
10326static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10327 [ALC660VD_3ST] = "3stack-660",
Mike Crash6963f842007-06-25 12:12:51 +020010328 [ALC660VD_3ST_DIG]= "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010329 [ALC861VD_3ST] = "3stack",
10330 [ALC861VD_3ST_DIG] = "3stack-digout",
10331 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010332 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010333 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010334 [ALC861VD_AUTO] = "auto",
10335};
10336
10337static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010338 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010340 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010341 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10342 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10343
Kailang Yang272a5272007-05-14 11:00:38 +020010344 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10345 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010346 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10347 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010348 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010349 {}
10350};
10351
10352static struct alc_config_preset alc861vd_presets[] = {
10353 [ALC660VD_3ST] = {
10354 .mixers = { alc861vd_3st_mixer },
10355 .init_verbs = { alc861vd_volume_init_verbs,
10356 alc861vd_3stack_init_verbs },
10357 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10358 .dac_nids = alc660vd_dac_nids,
10359 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10360 .adc_nids = alc861vd_adc_nids,
10361 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10362 .channel_mode = alc861vd_3stack_2ch_modes,
10363 .input_mux = &alc861vd_capture_source,
10364 },
Mike Crash6963f842007-06-25 12:12:51 +020010365 [ALC660VD_3ST_DIG] = {
10366 .mixers = { alc861vd_3st_mixer },
10367 .init_verbs = { alc861vd_volume_init_verbs,
10368 alc861vd_3stack_init_verbs },
10369 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10370 .dac_nids = alc660vd_dac_nids,
10371 .dig_out_nid = ALC861VD_DIGOUT_NID,
10372 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10373 .adc_nids = alc861vd_adc_nids,
10374 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10375 .channel_mode = alc861vd_3stack_2ch_modes,
10376 .input_mux = &alc861vd_capture_source,
10377 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010378 [ALC861VD_3ST] = {
10379 .mixers = { alc861vd_3st_mixer },
10380 .init_verbs = { alc861vd_volume_init_verbs,
10381 alc861vd_3stack_init_verbs },
10382 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10383 .dac_nids = alc861vd_dac_nids,
10384 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10385 .channel_mode = alc861vd_3stack_2ch_modes,
10386 .input_mux = &alc861vd_capture_source,
10387 },
10388 [ALC861VD_3ST_DIG] = {
10389 .mixers = { alc861vd_3st_mixer },
10390 .init_verbs = { alc861vd_volume_init_verbs,
10391 alc861vd_3stack_init_verbs },
10392 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10393 .dac_nids = alc861vd_dac_nids,
10394 .dig_out_nid = ALC861VD_DIGOUT_NID,
10395 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10396 .channel_mode = alc861vd_3stack_2ch_modes,
10397 .input_mux = &alc861vd_capture_source,
10398 },
10399 [ALC861VD_6ST_DIG] = {
10400 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10401 .init_verbs = { alc861vd_volume_init_verbs,
10402 alc861vd_6stack_init_verbs },
10403 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10404 .dac_nids = alc861vd_dac_nids,
10405 .dig_out_nid = ALC861VD_DIGOUT_NID,
10406 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10407 .channel_mode = alc861vd_6stack_modes,
10408 .input_mux = &alc861vd_capture_source,
10409 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010410 [ALC861VD_LENOVO] = {
10411 .mixers = { alc861vd_lenovo_mixer },
10412 .init_verbs = { alc861vd_volume_init_verbs,
10413 alc861vd_3stack_init_verbs,
10414 alc861vd_eapd_verbs,
10415 alc861vd_lenovo_unsol_verbs },
10416 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10417 .dac_nids = alc660vd_dac_nids,
10418 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10419 .adc_nids = alc861vd_adc_nids,
10420 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10421 .channel_mode = alc861vd_3stack_2ch_modes,
10422 .input_mux = &alc861vd_capture_source,
10423 .unsol_event = alc861vd_lenovo_unsol_event,
10424 .init_hook = alc861vd_lenovo_automute,
10425 },
Kailang Yang272a5272007-05-14 11:00:38 +020010426 [ALC861VD_DALLAS] = {
10427 .mixers = { alc861vd_dallas_mixer },
10428 .init_verbs = { alc861vd_dallas_verbs },
10429 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10430 .dac_nids = alc861vd_dac_nids,
10431 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10432 .adc_nids = alc861vd_adc_nids,
10433 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10434 .channel_mode = alc861vd_3stack_2ch_modes,
10435 .input_mux = &alc861vd_dallas_capture_source,
10436 .unsol_event = alc861vd_dallas_unsol_event,
10437 .init_hook = alc861vd_dallas_automute,
10438 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010439};
10440
10441/*
10442 * BIOS auto configuration
10443 */
10444static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10445 hda_nid_t nid, int pin_type, int dac_idx)
10446{
10447 /* set as output */
10448 snd_hda_codec_write(codec, nid, 0,
10449 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10450 snd_hda_codec_write(codec, nid, 0,
10451 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10452}
10453
10454static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10455{
10456 struct alc_spec *spec = codec->spec;
10457 int i;
10458
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010459 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010460 for (i = 0; i <= HDA_SIDE; i++) {
10461 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010462 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010463 if (nid)
10464 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010465 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010466 }
10467}
10468
10469
10470static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10471{
10472 struct alc_spec *spec = codec->spec;
10473 hda_nid_t pin;
10474
10475 pin = spec->autocfg.hp_pins[0];
10476 if (pin) /* connect to front and use dac 0 */
10477 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10478}
10479
10480#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10481#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10482
10483static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10484{
10485 struct alc_spec *spec = codec->spec;
10486 int i;
10487
10488 for (i = 0; i < AUTO_PIN_LAST; i++) {
10489 hda_nid_t nid = spec->autocfg.input_pins[i];
10490 if (alc861vd_is_input_pin(nid)) {
10491 snd_hda_codec_write(codec, nid, 0,
10492 AC_VERB_SET_PIN_WIDGET_CONTROL,
10493 i <= AUTO_PIN_FRONT_MIC ?
10494 PIN_VREF80 : PIN_IN);
10495 if (nid != ALC861VD_PIN_CD_NID)
10496 snd_hda_codec_write(codec, nid, 0,
10497 AC_VERB_SET_AMP_GAIN_MUTE,
10498 AMP_OUT_MUTE);
10499 }
10500 }
10501}
10502
10503#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10504#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10505
10506/* add playback controls from the parsed DAC table */
10507/* Based on ALC880 version. But ALC861VD has separate,
10508 * different NIDs for mute/unmute switch and volume control */
10509static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10510 const struct auto_pin_cfg *cfg)
10511{
10512 char name[32];
10513 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10514 hda_nid_t nid_v, nid_s;
10515 int i, err;
10516
10517 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010518 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010519 continue;
10520 nid_v = alc861vd_idx_to_mixer_vol(
10521 alc880_dac_to_idx(
10522 spec->multiout.dac_nids[i]));
10523 nid_s = alc861vd_idx_to_mixer_switch(
10524 alc880_dac_to_idx(
10525 spec->multiout.dac_nids[i]));
10526
10527 if (i == 2) {
10528 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010529 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10530 "Center Playback Volume",
10531 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10532 HDA_OUTPUT));
10533 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010534 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010535 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10536 "LFE Playback Volume",
10537 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10538 HDA_OUTPUT));
10539 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010540 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010541 err = add_control(spec, ALC_CTL_BIND_MUTE,
10542 "Center Playback Switch",
10543 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10544 HDA_INPUT));
10545 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010547 err = add_control(spec, ALC_CTL_BIND_MUTE,
10548 "LFE Playback Switch",
10549 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10550 HDA_INPUT));
10551 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010552 return err;
10553 } else {
10554 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010555 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10556 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10557 HDA_OUTPUT));
10558 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010559 return err;
10560 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010561 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010562 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010563 HDA_INPUT));
10564 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010565 return err;
10566 }
10567 }
10568 return 0;
10569}
10570
10571/* add playback controls for speaker and HP outputs */
10572/* Based on ALC880 version. But ALC861VD has separate,
10573 * different NIDs for mute/unmute switch and volume control */
10574static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10575 hda_nid_t pin, const char *pfx)
10576{
10577 hda_nid_t nid_v, nid_s;
10578 int err;
10579 char name[32];
10580
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010581 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010582 return 0;
10583
10584 if (alc880_is_fixed_pin(pin)) {
10585 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10586 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010587 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010588 spec->multiout.hp_nid = nid_v;
10589 else
10590 spec->multiout.extra_out_nid[0] = nid_v;
10591 /* control HP volume/switch on the output mixer amp */
10592 nid_v = alc861vd_idx_to_mixer_vol(
10593 alc880_fixed_pin_idx(pin));
10594 nid_s = alc861vd_idx_to_mixer_switch(
10595 alc880_fixed_pin_idx(pin));
10596
10597 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010598 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10599 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10600 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010601 return err;
10602 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010603 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10604 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10605 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010606 return err;
10607 } else if (alc880_is_multi_pin(pin)) {
10608 /* set manual connection */
10609 /* we have only a switch on HP-out PIN */
10610 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010611 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10612 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10613 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010614 return err;
10615 }
10616 return 0;
10617}
10618
10619/* parse the BIOS configuration and set up the alc_spec
10620 * return 1 if successful, 0 if the proper config is not found,
10621 * or a negative error code
10622 * Based on ALC880 version - had to change it to override
10623 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10624static int alc861vd_parse_auto_config(struct hda_codec *codec)
10625{
10626 struct alc_spec *spec = codec->spec;
10627 int err;
10628 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10629
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010630 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10631 alc861vd_ignore);
10632 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010634 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010635 return 0; /* can't find valid BIOS pin config */
10636
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010637 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10638 if (err < 0)
10639 return err;
10640 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10641 if (err < 0)
10642 return err;
10643 err = alc861vd_auto_create_extra_out(spec,
10644 spec->autocfg.speaker_pins[0],
10645 "Speaker");
10646 if (err < 0)
10647 return err;
10648 err = alc861vd_auto_create_extra_out(spec,
10649 spec->autocfg.hp_pins[0],
10650 "Headphone");
10651 if (err < 0)
10652 return err;
10653 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10654 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010655 return err;
10656
10657 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10658
10659 if (spec->autocfg.dig_out_pin)
10660 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10661
10662 if (spec->kctl_alloc)
10663 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10664
10665 spec->init_verbs[spec->num_init_verbs++]
10666 = alc861vd_volume_init_verbs;
10667
10668 spec->num_mux_defs = 1;
10669 spec->input_mux = &spec->private_imux;
10670
10671 return 1;
10672}
10673
10674/* additional initialization for auto-configuration model */
10675static void alc861vd_auto_init(struct hda_codec *codec)
10676{
10677 alc861vd_auto_init_multi_out(codec);
10678 alc861vd_auto_init_hp_out(codec);
10679 alc861vd_auto_init_analog_input(codec);
10680}
10681
10682static int patch_alc861vd(struct hda_codec *codec)
10683{
10684 struct alc_spec *spec;
10685 int err, board_config;
10686
10687 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10688 if (spec == NULL)
10689 return -ENOMEM;
10690
10691 codec->spec = spec;
10692
10693 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10694 alc861vd_models,
10695 alc861vd_cfg_tbl);
10696
10697 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10698 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10699 "ALC861VD, trying auto-probe from BIOS...\n");
10700 board_config = ALC861VD_AUTO;
10701 }
10702
10703 if (board_config == ALC861VD_AUTO) {
10704 /* automatic parse from the BIOS config */
10705 err = alc861vd_parse_auto_config(codec);
10706 if (err < 0) {
10707 alc_free(codec);
10708 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010709 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010710 printk(KERN_INFO
10711 "hda_codec: Cannot set up configuration "
10712 "from BIOS. Using base mode...\n");
10713 board_config = ALC861VD_3ST;
10714 }
10715 }
10716
10717 if (board_config != ALC861VD_AUTO)
10718 setup_preset(spec, &alc861vd_presets[board_config]);
10719
10720 spec->stream_name_analog = "ALC861VD Analog";
10721 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10722 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10723
10724 spec->stream_name_digital = "ALC861VD Digital";
10725 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10726 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10727
10728 spec->adc_nids = alc861vd_adc_nids;
10729 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10730
10731 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10732 spec->num_mixers++;
10733
10734 codec->patch_ops = alc_patch_ops;
10735
10736 if (board_config == ALC861VD_AUTO)
10737 spec->init_hook = alc861vd_auto_init;
10738
10739 return 0;
10740}
10741
10742/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010743 * ALC662 support
10744 *
10745 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10746 * configuration. Each pin widget can choose any input DACs and a mixer.
10747 * Each ADC is connected from a mixer of all inputs. This makes possible
10748 * 6-channel independent captures.
10749 *
10750 * In addition, an independent DAC for the multi-playback (not used in this
10751 * driver yet).
10752 */
10753#define ALC662_DIGOUT_NID 0x06
10754#define ALC662_DIGIN_NID 0x0a
10755
10756static hda_nid_t alc662_dac_nids[4] = {
10757 /* front, rear, clfe, rear_surr */
10758 0x02, 0x03, 0x04
10759};
10760
10761static hda_nid_t alc662_adc_nids[1] = {
10762 /* ADC1-2 */
10763 0x09,
10764};
10765/* input MUX */
10766/* FIXME: should be a matrix-type input source selection */
10767
10768static struct hda_input_mux alc662_capture_source = {
10769 .num_items = 4,
10770 .items = {
10771 { "Mic", 0x0 },
10772 { "Front Mic", 0x1 },
10773 { "Line", 0x2 },
10774 { "CD", 0x4 },
10775 },
10776};
10777
10778static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10779 .num_items = 2,
10780 .items = {
10781 { "Mic", 0x1 },
10782 { "Line", 0x2 },
10783 },
10784};
10785#define alc662_mux_enum_info alc_mux_enum_info
10786#define alc662_mux_enum_get alc_mux_enum_get
10787
10788static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10789 struct snd_ctl_elem_value *ucontrol)
10790{
10791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10792 struct alc_spec *spec = codec->spec;
10793 const struct hda_input_mux *imux = spec->input_mux;
10794 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10795 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10796 hda_nid_t nid = capture_mixers[adc_idx];
10797 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10798 unsigned int i, idx;
10799
10800 idx = ucontrol->value.enumerated.item[0];
10801 if (idx >= imux->num_items)
10802 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010803 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010804 return 0;
10805 for (i = 0; i < imux->num_items; i++) {
10806 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10807 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10808 v | (imux->items[i].index << 8));
10809 }
10810 *cur_val = idx;
10811 return 1;
10812}
10813/*
10814 * 2ch mode
10815 */
10816static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10817 { 2, NULL }
10818};
10819
10820/*
10821 * 2ch mode
10822 */
10823static struct hda_verb alc662_3ST_ch2_init[] = {
10824 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10825 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10828 { } /* end */
10829};
10830
10831/*
10832 * 6ch mode
10833 */
10834static struct hda_verb alc662_3ST_ch6_init[] = {
10835 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10836 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10837 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10840 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10841 { } /* end */
10842};
10843
10844static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10845 { 2, alc662_3ST_ch2_init },
10846 { 6, alc662_3ST_ch6_init },
10847};
10848
10849/*
10850 * 2ch mode
10851 */
10852static struct hda_verb alc662_sixstack_ch6_init[] = {
10853 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10854 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10855 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10856 { } /* end */
10857};
10858
10859/*
10860 * 6ch mode
10861 */
10862static struct hda_verb alc662_sixstack_ch8_init[] = {
10863 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10864 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10865 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10866 { } /* end */
10867};
10868
10869static struct hda_channel_mode alc662_5stack_modes[2] = {
10870 { 2, alc662_sixstack_ch6_init },
10871 { 6, alc662_sixstack_ch8_init },
10872};
10873
10874/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10875 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10876 */
10877
10878static struct snd_kcontrol_new alc662_base_mixer[] = {
10879 /* output mixer control */
10880 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10881 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10883 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10889
10890 /*Input mixer control */
10891 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10892 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10893 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10894 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10895 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10896 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10897 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10899
10900 /* Capture mixer control */
10901 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10902 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10903 {
10904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10905 .name = "Capture Source",
10906 .count = 1,
10907 .info = alc_mux_enum_info,
10908 .get = alc_mux_enum_get,
10909 .put = alc_mux_enum_put,
10910 },
10911 { } /* end */
10912};
10913
10914static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10915 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10916 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10918 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10919 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10926 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10927 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10928 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10929 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10930 {
10931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10932 /* .name = "Capture Source", */
10933 .name = "Input Source",
10934 .count = 1,
10935 .info = alc662_mux_enum_info,
10936 .get = alc662_mux_enum_get,
10937 .put = alc662_mux_enum_put,
10938 },
10939 { } /* end */
10940};
10941
10942static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10944 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10946 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10960 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10961 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10962 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10963 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10964 {
10965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10966 /* .name = "Capture Source", */
10967 .name = "Input Source",
10968 .count = 1,
10969 .info = alc662_mux_enum_info,
10970 .get = alc662_mux_enum_get,
10971 .put = alc662_mux_enum_put,
10972 },
10973 { } /* end */
10974};
10975
10976static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10977 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10978 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10979 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10980 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10986 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10987 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10988 {
10989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10990 /* .name = "Capture Source", */
10991 .name = "Input Source",
10992 .count = 1,
10993 .info = alc662_mux_enum_info,
10994 .get = alc662_mux_enum_get,
10995 .put = alc662_mux_enum_put,
10996 },
10997 { } /* end */
10998};
10999
11000static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11001 {
11002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11003 .name = "Channel Mode",
11004 .info = alc_ch_mode_info,
11005 .get = alc_ch_mode_get,
11006 .put = alc_ch_mode_put,
11007 },
11008 { } /* end */
11009};
11010
11011static struct hda_verb alc662_init_verbs[] = {
11012 /* ADC: mute amp left and right */
11013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11014 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11015 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11016
11017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11022
11023 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11025 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11026 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11027 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11029
11030 /* Front Pin: output 0 (0x0c) */
11031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11033
11034 /* Rear Pin: output 1 (0x0d) */
11035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11037
11038 /* CLFE Pin: output 2 (0x0e) */
11039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11041
11042 /* Mic (rear) pin: input vref at 80% */
11043 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11045 /* Front Mic pin: input vref at 80% */
11046 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11048 /* Line In pin: input */
11049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11051 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11054 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11055 /* CD pin widget for input */
11056 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11057
11058 /* FIXME: use matrix-type input source selection */
11059 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11060 /* Input mixer */
11061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11065 { }
11066};
11067
11068static struct hda_verb alc662_sue_init_verbs[] = {
11069 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11070 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11071 {}
11072};
11073
11074/*
11075 * generic initialization of ADC, input mixers and output mixers
11076 */
11077static struct hda_verb alc662_auto_init_verbs[] = {
11078 /*
11079 * Unmute ADC and set the default input to mic-in
11080 */
11081 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11083
11084 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11085 * mixer widget
11086 * Note: PASD motherboards uses the Line In 2 as the input for front
11087 * panel mic (mic 2)
11088 */
11089 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11095
11096 /*
11097 * Set up output mixers (0x0c - 0x0f)
11098 */
11099 /* set vol=0 to output mixers */
11100 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11101 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11103
11104 /* set up input amps for analog loopback */
11105 /* Amp Indices: DAC = 0, mixer = 1 */
11106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11107 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11108 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11109 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11110 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11111 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11112
11113
11114 /* FIXME: use matrix-type input source selection */
11115 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11116 /* Input mixer */
11117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11120 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
11121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11122
11123 { }
11124};
11125
11126/* capture mixer elements */
11127static struct snd_kcontrol_new alc662_capture_mixer[] = {
11128 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11129 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11130 {
11131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11132 /* The multiple "Capture Source" controls confuse alsamixer
11133 * So call somewhat different..
11134 * FIXME: the controls appear in the "playback" view!
11135 */
11136 /* .name = "Capture Source", */
11137 .name = "Input Source",
11138 .count = 1,
11139 .info = alc882_mux_enum_info,
11140 .get = alc882_mux_enum_get,
11141 .put = alc882_mux_enum_put,
11142 },
11143 { } /* end */
11144};
11145
11146static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11147{
11148 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011149 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011150
11151 present = snd_hda_codec_read(codec, 0x14, 0,
11152 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011153 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011154 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011155 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011156 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011157 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011158}
11159
11160static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11161{
11162 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011163 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011164
11165 present = snd_hda_codec_read(codec, 0x1b, 0,
11166 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011167 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011168 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011169 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011170 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011171 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011172 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011173 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011174 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011175 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011176}
11177
11178static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11179 unsigned int res)
11180{
11181 if ((res >> 26) == ALC880_HP_EVENT)
11182 alc662_lenovo_101e_all_automute(codec);
11183 if ((res >> 26) == ALC880_FRONT_EVENT)
11184 alc662_lenovo_101e_ispeaker_automute(codec);
11185}
11186
11187
11188/* pcm configuration: identiacal with ALC880 */
11189#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11190#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11191#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11192#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11193
11194/*
11195 * configuration and preset
11196 */
11197static const char *alc662_models[ALC662_MODEL_LAST] = {
11198 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11199 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11200 [ALC662_3ST_6ch] = "3stack-6ch",
11201 [ALC662_5ST_DIG] = "6stack-dig",
11202 [ALC662_LENOVO_101E] = "lenovo-101e",
11203 [ALC662_AUTO] = "auto",
11204};
11205
11206static struct snd_pci_quirk alc662_cfg_tbl[] = {
11207 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11208 {}
11209};
11210
11211static struct alc_config_preset alc662_presets[] = {
11212 [ALC662_3ST_2ch_DIG] = {
11213 .mixers = { alc662_3ST_2ch_mixer },
11214 .init_verbs = { alc662_init_verbs },
11215 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11216 .dac_nids = alc662_dac_nids,
11217 .dig_out_nid = ALC662_DIGOUT_NID,
11218 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11219 .adc_nids = alc662_adc_nids,
11220 .dig_in_nid = ALC662_DIGIN_NID,
11221 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11222 .channel_mode = alc662_3ST_2ch_modes,
11223 .input_mux = &alc662_capture_source,
11224 },
11225 [ALC662_3ST_6ch_DIG] = {
11226 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11227 .init_verbs = { alc662_init_verbs },
11228 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11229 .dac_nids = alc662_dac_nids,
11230 .dig_out_nid = ALC662_DIGOUT_NID,
11231 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11232 .adc_nids = alc662_adc_nids,
11233 .dig_in_nid = ALC662_DIGIN_NID,
11234 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11235 .channel_mode = alc662_3ST_6ch_modes,
11236 .need_dac_fix = 1,
11237 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011238 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011239 [ALC662_3ST_6ch] = {
11240 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11241 .init_verbs = { alc662_init_verbs },
11242 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11243 .dac_nids = alc662_dac_nids,
11244 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11245 .adc_nids = alc662_adc_nids,
11246 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11247 .channel_mode = alc662_3ST_6ch_modes,
11248 .need_dac_fix = 1,
11249 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011250 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011251 [ALC662_5ST_DIG] = {
11252 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11253 .init_verbs = { alc662_init_verbs },
11254 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11255 .dac_nids = alc662_dac_nids,
11256 .dig_out_nid = ALC662_DIGOUT_NID,
11257 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11258 .adc_nids = alc662_adc_nids,
11259 .dig_in_nid = ALC662_DIGIN_NID,
11260 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11261 .channel_mode = alc662_5stack_modes,
11262 .input_mux = &alc662_capture_source,
11263 },
11264 [ALC662_LENOVO_101E] = {
11265 .mixers = { alc662_lenovo_101e_mixer },
11266 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11267 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11268 .dac_nids = alc662_dac_nids,
11269 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11270 .adc_nids = alc662_adc_nids,
11271 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11272 .channel_mode = alc662_3ST_2ch_modes,
11273 .input_mux = &alc662_lenovo_101e_capture_source,
11274 .unsol_event = alc662_lenovo_101e_unsol_event,
11275 .init_hook = alc662_lenovo_101e_all_automute,
11276 },
11277
11278};
11279
11280
11281/*
11282 * BIOS auto configuration
11283 */
11284
11285/* add playback controls from the parsed DAC table */
11286static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11287 const struct auto_pin_cfg *cfg)
11288{
11289 char name[32];
11290 static const char *chname[4] = {
11291 "Front", "Surround", NULL /*CLFE*/, "Side"
11292 };
11293 hda_nid_t nid;
11294 int i, err;
11295
11296 for (i = 0; i < cfg->line_outs; i++) {
11297 if (!spec->multiout.dac_nids[i])
11298 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011299 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011300 if (i == 2) {
11301 /* Center/LFE */
11302 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11303 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011304 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11305 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011306 if (err < 0)
11307 return err;
11308 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11309 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011310 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11311 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011312 if (err < 0)
11313 return err;
11314 err = add_control(spec, ALC_CTL_BIND_MUTE,
11315 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011316 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11317 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011318 if (err < 0)
11319 return err;
11320 err = add_control(spec, ALC_CTL_BIND_MUTE,
11321 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011322 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11323 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011324 if (err < 0)
11325 return err;
11326 } else {
11327 sprintf(name, "%s Playback Volume", chname[i]);
11328 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011329 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11330 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011331 if (err < 0)
11332 return err;
11333 sprintf(name, "%s Playback Switch", chname[i]);
11334 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011335 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11336 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011337 if (err < 0)
11338 return err;
11339 }
11340 }
11341 return 0;
11342}
11343
11344/* add playback controls for speaker and HP outputs */
11345static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11346 const char *pfx)
11347{
11348 hda_nid_t nid;
11349 int err;
11350 char name[32];
11351
11352 if (!pin)
11353 return 0;
11354
11355 if (alc880_is_fixed_pin(pin)) {
11356 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11357 /* printk("DAC nid=%x\n",nid); */
11358 /* specify the DAC as the extra output */
11359 if (!spec->multiout.hp_nid)
11360 spec->multiout.hp_nid = nid;
11361 else
11362 spec->multiout.extra_out_nid[0] = nid;
11363 /* control HP volume/switch on the output mixer amp */
11364 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11365 sprintf(name, "%s Playback Volume", pfx);
11366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11367 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11368 if (err < 0)
11369 return err;
11370 sprintf(name, "%s Playback Switch", pfx);
11371 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11372 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11373 if (err < 0)
11374 return err;
11375 } else if (alc880_is_multi_pin(pin)) {
11376 /* set manual connection */
11377 /* we have only a switch on HP-out PIN */
11378 sprintf(name, "%s Playback Switch", pfx);
11379 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11380 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11381 if (err < 0)
11382 return err;
11383 }
11384 return 0;
11385}
11386
11387/* create playback/capture controls for input pins */
11388static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11389 const struct auto_pin_cfg *cfg)
11390{
11391 struct hda_input_mux *imux = &spec->private_imux;
11392 int i, err, idx;
11393
11394 for (i = 0; i < AUTO_PIN_LAST; i++) {
11395 if (alc880_is_input_pin(cfg->input_pins[i])) {
11396 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11397 err = new_analog_input(spec, cfg->input_pins[i],
11398 auto_pin_cfg_labels[i],
11399 idx, 0x0b);
11400 if (err < 0)
11401 return err;
11402 imux->items[imux->num_items].label =
11403 auto_pin_cfg_labels[i];
11404 imux->items[imux->num_items].index =
11405 alc880_input_pin_idx(cfg->input_pins[i]);
11406 imux->num_items++;
11407 }
11408 }
11409 return 0;
11410}
11411
11412static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11413 hda_nid_t nid, int pin_type,
11414 int dac_idx)
11415{
11416 /* set as output */
11417 snd_hda_codec_write(codec, nid, 0,
11418 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11419 snd_hda_codec_write(codec, nid, 0,
11420 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11421 /* need the manual connection? */
11422 if (alc880_is_multi_pin(nid)) {
11423 struct alc_spec *spec = codec->spec;
11424 int idx = alc880_multi_pin_idx(nid);
11425 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11426 AC_VERB_SET_CONNECT_SEL,
11427 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11428 }
11429}
11430
11431static void alc662_auto_init_multi_out(struct hda_codec *codec)
11432{
11433 struct alc_spec *spec = codec->spec;
11434 int i;
11435
11436 for (i = 0; i <= HDA_SIDE; i++) {
11437 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011438 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011439 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011440 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011441 i);
11442 }
11443}
11444
11445static void alc662_auto_init_hp_out(struct hda_codec *codec)
11446{
11447 struct alc_spec *spec = codec->spec;
11448 hda_nid_t pin;
11449
11450 pin = spec->autocfg.hp_pins[0];
11451 if (pin) /* connect to front */
11452 /* use dac 0 */
11453 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11454}
11455
11456#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11457#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11458
11459static void alc662_auto_init_analog_input(struct hda_codec *codec)
11460{
11461 struct alc_spec *spec = codec->spec;
11462 int i;
11463
11464 for (i = 0; i < AUTO_PIN_LAST; i++) {
11465 hda_nid_t nid = spec->autocfg.input_pins[i];
11466 if (alc662_is_input_pin(nid)) {
11467 snd_hda_codec_write(codec, nid, 0,
11468 AC_VERB_SET_PIN_WIDGET_CONTROL,
11469 (i <= AUTO_PIN_FRONT_MIC ?
11470 PIN_VREF80 : PIN_IN));
11471 if (nid != ALC662_PIN_CD_NID)
11472 snd_hda_codec_write(codec, nid, 0,
11473 AC_VERB_SET_AMP_GAIN_MUTE,
11474 AMP_OUT_MUTE);
11475 }
11476 }
11477}
11478
11479static int alc662_parse_auto_config(struct hda_codec *codec)
11480{
11481 struct alc_spec *spec = codec->spec;
11482 int err;
11483 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11484
11485 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11486 alc662_ignore);
11487 if (err < 0)
11488 return err;
11489 if (!spec->autocfg.line_outs)
11490 return 0; /* can't find valid BIOS pin config */
11491
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011492 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11493 if (err < 0)
11494 return err;
11495 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11496 if (err < 0)
11497 return err;
11498 err = alc662_auto_create_extra_out(spec,
11499 spec->autocfg.speaker_pins[0],
11500 "Speaker");
11501 if (err < 0)
11502 return err;
11503 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11504 "Headphone");
11505 if (err < 0)
11506 return err;
11507 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11508 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011509 return err;
11510
11511 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11512
11513 if (spec->autocfg.dig_out_pin)
11514 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11515
11516 if (spec->kctl_alloc)
11517 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11518
11519 spec->num_mux_defs = 1;
11520 spec->input_mux = &spec->private_imux;
11521
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011522 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011523 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11524 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011525 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011526}
11527
11528/* additional initialization for auto-configuration model */
11529static void alc662_auto_init(struct hda_codec *codec)
11530{
11531 alc662_auto_init_multi_out(codec);
11532 alc662_auto_init_hp_out(codec);
11533 alc662_auto_init_analog_input(codec);
11534}
11535
11536static int patch_alc662(struct hda_codec *codec)
11537{
11538 struct alc_spec *spec;
11539 int err, board_config;
11540
11541 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11542 if (!spec)
11543 return -ENOMEM;
11544
11545 codec->spec = spec;
11546
11547 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11548 alc662_models,
11549 alc662_cfg_tbl);
11550 if (board_config < 0) {
11551 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11552 "trying auto-probe from BIOS...\n");
11553 board_config = ALC662_AUTO;
11554 }
11555
11556 if (board_config == ALC662_AUTO) {
11557 /* automatic parse from the BIOS config */
11558 err = alc662_parse_auto_config(codec);
11559 if (err < 0) {
11560 alc_free(codec);
11561 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011562 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011563 printk(KERN_INFO
11564 "hda_codec: Cannot set up configuration "
11565 "from BIOS. Using base mode...\n");
11566 board_config = ALC662_3ST_2ch_DIG;
11567 }
11568 }
11569
11570 if (board_config != ALC662_AUTO)
11571 setup_preset(spec, &alc662_presets[board_config]);
11572
11573 spec->stream_name_analog = "ALC662 Analog";
11574 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11575 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11576
11577 spec->stream_name_digital = "ALC662 Digital";
11578 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11579 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11580
11581 if (!spec->adc_nids && spec->input_mux) {
11582 spec->adc_nids = alc662_adc_nids;
11583 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11584 }
11585
11586 codec->patch_ops = alc_patch_ops;
11587 if (board_config == ALC662_AUTO)
11588 spec->init_hook = alc662_auto_init;
11589
11590 return 0;
11591}
11592
11593/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011594 * patch entries
11595 */
11596struct hda_codec_preset snd_hda_preset_realtek[] = {
11597 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011598 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020011599 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011600 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011601 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011602 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11603 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11604 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011605 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11606 .patch = patch_alc883 },
11607 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11608 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011609 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011610 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011611 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011612 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011613 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070011614 {} /* terminator */
11615};